def _GenerateTypePropertyConvinience(self, file, ctype, indent_level): for member in ctype.getDataMembers(): if member.isSequence: m = re.search(r'\<(.*)\>', member.jtypename) if m: innertype = m.group(1) else: print 'Unable to determine inner type for Collection: ' + member.jtypename continue methodname = CamelCase(member.membername) decl = """ public List<%(typename)s> get%(caml)s() { return %(field)s; } """ % { 'caml': methodname, 'typename': innertype, 'field': member.membername } self._FileWrite(file, decl, indent_level) if methodname.endswith('List'): methodname = methodname[:-len('List')] decl = """ public void add%(caml)s(%(typename)s obj) { if (%(field)s == null) { %(field)s = new ArrayList<%(typename)s>(); } %(field)s.add(obj); } public void clear%(caml)s() { %(field)s = null; } """ % {'caml': methodname, 'typename': innertype, 'field': member.membername} self._FileWrite(file, decl, indent_level) # convinience method that uses the inner type constructor # arguments inner = self._type_map.get(innertype) if not inner or len(inner.getDataMembers()) > 4: continue decl = """ public void add%(caml)s(%(argdecl)s) { if (%(field)s == null) { %(field)s = new ArrayList<%(typename)s>(); } %(field)s.add(new %(typename)s(%(arglist)s)); } """ % {'caml': methodname, 'typename': innertype, 'field': member.membername, 'argdecl': ', '.join( map(lambda x: self._InnerPropertyArgument(inner, x), inner.getDataMembers())), 'arglist': ', '.join( map(lambda x: x.membername, inner.getDataMembers())) } self._FileWrite(file, decl, indent_level)
def _GenerateTypePropertyConvinience(self, file, ctype, indent_level): for member in ctype.getDataMembers(): if member.isSequence: m = re.search(r'\<(.*)\>', member.jtypename) if m: innertype = m.group(1) else: print 'Unable to determine inner type for Collection: ' + member.jtypename continue methodname = CamelCase(member.membername) decl = """ public List<%(typename)s> get%(caml)s() { return %(field)s; } """ % { 'caml': methodname, 'typename': innertype, 'field': member.membername } self._FileWrite(file, decl, indent_level) if methodname.endswith('List'): methodname = methodname[:-len('List')] decl = """ public void add%(caml)s(%(typename)s obj) { if (%(field)s == null) { %(field)s = new ArrayList<%(typename)s>(); } %(field)s.add(obj); } public void clear%(caml)s() { %(field)s = null; } """ % {'caml': methodname, 'typename': innertype, 'field': member.membername} self._FileWrite(file, decl, indent_level) # convinience method that uses the inner type constructor # arguments inner = self._type_map.get(innertype) if not inner or len(inner.getDataMembers()) > 4: continue decl = """ public void add%(caml)s(%(argdecl)s) { if (%(field)s == null) { %(field)s = new ArrayList<%(typename)s>(); } %(field)s.add(new %(typename)s(%(arglist)s)); } """ % {'caml': methodname, 'typename': innertype, 'field': member.membername, 'argdecl': ', '.join( map(lambda x: self._InnerPropertyArgument(inner, x), inner.getDataMembers())), 'arglist': ', '.join( map(lambda x: x.membername, inner.getDataMembers())) } self._FileWrite(file, decl, indent_level)
def _GenerateCType(self, ctype, file): for deptype in ctype.getDependentTypes(): if deptype.getName() in self._top_level_map: continue self._GenerateCType(deptype, file) decl = """ type %(camel)s struct { """ % {'camel': ctype.getName()} file.write(decl) for member in ctype.getDataMembers(): camel = CamelCase(member.membername) ptrType = False if member.isComplex: mtype = member.xsd_object.getType() if not member.isSequence: ptrType = True else: mtype = getGoLangType(member.xsd_object.getType()) if member.isSequence: mtype = '[]' + mtype decl = '\t%s %s%s `json:"%s,omitempty"`\n' % \ (camel, '*' if ptrType else '', mtype, member.membername) file.write(decl) file.write('}\n') # Generate methods (add/delete/clear/set) for sequence fields for member in ctype.getDataMembers(): if not member.isSequence: continue membertype = member.xsd_object.getType() if not member.isComplex: membertype = getGoLangType(membertype) decl = """ func (obj *%(typecamel)s) Add%(fieldcamel)s(value %(ptr)s%(fieldtype)s) { obj.%(member)s = append(obj.%(member)s, %(ptr)svalue) } """ \ % {'typecamel': ctype.getName(), 'fieldcamel': CamelCase(member.membername), 'fieldtype': membertype, 'ptr': '*' if member.isComplex else '', 'member': CamelCase(member.membername), } file.write(decl) # mark as generated ctypename = ctype.getName() self._top_level_map[ctypename] = self._type_map[ctypename]
def __init__(self, name): super(IFMapIdentifier, self).__init__(name) self._cppname = CamelCase(name) self._properties = [] # list of IFMapProperty elements self._key_members = [] self._data_members = [] self._data_types = [] self._links = [] self._back_links = [] self._parents = None self._children = [] self._references = [] self._back_references = []
def _GenerateTypePropertyAccessors(self, file, ctype, indent_level): for prop in ctype.getDataMembers(): if prop.isSequence: continue decl = """ public %(type)s get%(caml)s() { return %(field)s; } public void set%(caml)s(%(type)s %(field)s) { this.%(field)s = %(field)s; } """ % {'caml': CamelCase(prop.membername), 'type': prop.jtypename, 'field': prop.membername} self._FileWrite(file, decl, indent_level)
def __init__(self, name): super(IFMapLinkAttr, self).__init__(name) self._cppname = CamelCase(name) self._complexType = None
def __init__(self, name): super(IFMapProperty, self).__init__(name) self._parent = None self._cppname = CamelCase(name) self._complexType = None self._memberinfo = None
def __init__(self, name): super(IFMapMetadata, self).__init__(name) self._cppname = CamelCase(name) self._complexType = None