def writeLocal(fileOut, name, classes): capName = name.upper() fileOut.write('#ifdef USE_{0}\n\n'.format(capName)) fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0}PkgNamespaces)\n'.format( strFunctions.cap(name))) for i in range(0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0})\n'.format( classes[i]['name'])) for i in range(0, len(classes)): if (classes[i]['hasListOf'] == True): loName = strFunctions.listOfName(classes[i]['name']) fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0})\n'.format( strFunctions.cap(loName))) fileOut.write('\n') for i in range(0, len(classes)): if (classes[i]['abstract'] == True or isBaseClassForOthers(classes[i], classes)): fileOut.write('/**\n') fileOut.write( ' * Convert {0} objects into the most specific object possible.\n' .format(classes[i]['name'])) fileOut.write(' */\n') fileOut.write('%typemap(out) {0}*\n'.format(classes[i]['name'])) fileOut.write('{\n') fileOut.write( ' $result = SWIG_NewPointerObj($1, GetDowncastSwigTypeForPackage($1, "{0}"), $owner | %newpointer_flags);\n' .format(name)) fileOut.write('}\n') fileOut.write('\n') fileOut.write('\n') fileOut.write('#endif // USE_{0} \n\n'.format(capName))
def writePkg(fileOut, name, classes): capName = name.upper() fileOut.write('#ifdef USE_{0}\n'.format(capName)) fileOut.write('else if (pkgName == "{0}")\n'.format(name)) fileOut.write('{\n') fileOut.write(' switch (sb->getTypeCode() )\n') fileOut.write(' {\n') fileOut.write(' case SBML_LIST_OF:\n') fileOut.write(' name = sb->getElementName();\n') for i in range(0, len(classes)): if (classes[i]['hasListOf'] == True): loName = strFunctions.listOfName(classes[i]['name']) if classes[i].has_key('lo_elementName'): loName = classes[i]['lo_elementName'] if (i == 0): fileOut.write(' if (name == "{0}")\n'.format(loName)) else: fileOut.write(' else if (name == "{0}")\n'.format(loName)) fileOut.write(' {\n') fileOut.write(' return SWIGTYPE_p_{0};\n'.format( generalFunctions.getListOfClassName(classes[i], classes[i]['name']))) fileOut.write(' }\n') fileOut.write('\n return SWIGTYPE_p_ListOf;\n\n') for i in range(0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write(' case {0}:\n'.format(classes[i]['typecode'])) fileOut.write(' return SWIGTYPE_p_{0};\n\n'.format( classes[i]['name'])) fileOut.write(' default:\n') fileOut.write(' return SWIGTYPE_p_SBase;\n') fileOut.write(' }\n') fileOut.write('}\n\n') fileOut.write('#endif // USE_{0} \n\n'.format(capName))
def writeLocal(fileOut, name, classes): capName = name.upper() fileOut.write('#ifdef USE_{0}\n\n'.format(capName)) fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0}PkgNamespaces)\n'.format(strFunctions.cap(name))) for i in range (0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0})\n'.format(classes[i]['name'])) for i in range (0, len(classes)): if (classes[i]['hasListOf'] == True): loName = strFunctions.listOfName(classes[i]['name']) fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0})\n'.format(strFunctions.cap(loName))) fileOut.write('\n') for i in range (0, len(classes)): if (classes[i]['abstract'] == True or isBaseClassForOthers(classes[i], classes)): fileOut.write('/**\n') fileOut.write(' * Convert {0} objects into the most specific object possible.\n'.format(classes[i]['name'])) fileOut.write(' */\n') fileOut.write('%typemap(out) {0}*\n'.format(classes[i]['name'])) fileOut.write('{\n') fileOut.write(' $result = SWIG_NewPointerObj($1, GetDowncastSwigTypeForPackage($1, "{0}"), $owner | %newpointer_flags);\n'.format(name)) fileOut.write('}\n') fileOut.write('\n') fileOut.write('\n') fileOut.write('#endif // USE_{0} \n\n'.format(capName))
def writePkg(fileOut, name, classes): capName = name.upper() fileOut.write('#ifdef USE_{0}\n'.format(capName)) fileOut.write('else if (pkgName == "{0}")\n'.format(name)) fileOut.write('{\n') fileOut.write(' switch (sb->getTypeCode() )\n') fileOut.write(' {\n') fileOut.write(' case SBML_LIST_OF:\n') fileOut.write(' name = sb->getElementName();\n') for i in range (0, len(classes)): if (classes[i]['hasListOf'] == True): loName = strFunctions.listOfName(classes[i]['name']) if classes[i].has_key('lo_elementName'): loName = classes[i]['lo_elementName'] if (i==0): fileOut.write(' if (name == "{0}")\n'.format(loName)) else : fileOut.write(' else if (name == "{0}")\n'.format(loName)) fileOut.write(' {\n') fileOut.write(' return SWIGTYPE_p_{0};\n'.format(generalFunctions.getListOfClassName (classes[i], classes[i]['name']))) fileOut.write(' }\n') fileOut.write('\n return SWIGTYPE_p_ListOf;\n\n') for i in range (0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write(' case {0}:\n'.format(classes[i]['typecode'])) fileOut.write(' return SWIGTYPE_p_{0};\n\n'.format(classes[i]['name'])) fileOut.write(' default:\n') fileOut.write(' return SWIGTYPE_p_SBase;\n') fileOut.write(' }\n') fileOut.write('}\n\n') fileOut.write('#endif // USE_{0} \n\n'.format(capName))
def writeJava(fileOut, name, plugins, classes): capName = name.upper() fileOut.write('#ifdef USE_{0}\n'.format(capName)) fileOut.write('/**\n') fileOut.write( ' * Adds DownCastBase(long cPtr, boolean owner) method for the {0} package extension\n' .format(name)) fileOut.write(' */\n') fileOut.write('%typemap(javacode) {0}Extension\n'.format( strFunctions.cap(name))) fileOut.write('%{\n') fileOut.write( ' public SBasePlugin DowncastSBasePlugin(long cPtr, boolean owner)\n') fileOut.write(' {\n') fileOut.write(' if (cPtr == 0) return null;\n\n') fileOut.write(' SBasePlugin sbp = new SBasePlugin(cPtr, false);\n') fileOut.write(' SBase sb = sbp.getParentSBMLObject();\n\n') fileOut.write(' switch( sb.getTypeCode() )\n') fileOut.write(' {\n') listOfPlugins = [] for plugin in plugins: typecode = 'SBML_{0}'.format(createSBase(plugin['sbase'].upper())) if plugin.has_key('typecode') and plugin['typecode'] != None: typecode = plugin['typecode'] if typecode != 'SBML_LIST_OF': fileOut.write(' case (int) libsbml.{0}:\n'.format(typecode)) fileOut.write( ' return new {0}{1}Plugin(cPtr, owner);\n\n'.format( strFunctions.cap(name), plugin['sbase'])) else: listOfPlugins.append(plugin) if len(listOfPlugins) > 0: fileOut.write(' case (int) libsbml.SBML_LIST_OF:\n') fileOut.write(' {\n') fileOut.write(' String name = sb.getElementName();\n') for plugin in listOfPlugins: fileOut.write(' if (name.equals("{0}"))\n'.format( strFunctions.lowerFirst(plugin['sbase']))) fileOut.write( ' return new {0}{1}Plugin(cPtr, owner);\n\n'.format( strFunctions.cap(name), plugin['sbase'])) fileOut.write(' return new SBasePlugin(cPtr, owner);\n') fileOut.write(' }\n') fileOut.write(' default:\n') fileOut.write(' return new SBasePlugin(cPtr, owner);\n') fileOut.write(' }\n') fileOut.write(' }\n\n') fileOut.write(' public SBase DowncastSBase(long cPtr, boolean owner)\n') fileOut.write(' {\n') fileOut.write(' if (cPtr == 0) return null;\n\n') fileOut.write(' SBase sb = new SBase(cPtr, false);\n') fileOut.write(' switch( sb.getTypeCode() )\n') fileOut.write(' {\n') fileOut.write(' case (int) libsbml.SBML_LIST_OF:\n') fileOut.write(' String name = sb.getElementName();\n') for i in range(0, len(classes)): if (classes[i]['hasListOf'] == True): loName = strFunctions.listOfName(classes[i]['name']) if classes[i].has_key('lo_elementName'): loName = classes[i]['lo_elementName'] if (i == 0): fileOut.write( ' if (name.equals("{0}"))\n'.format(loName)) else: fileOut.write( ' else if (name.equals("{0}"))\n'.format(loName)) fileOut.write(' {\n') fileOut.write(' return new {0}(cPtr, owner);\n'.format( generalFunctions.getListOfClassName(classes[i], classes[i]['name']))) fileOut.write(' }\n') fileOut.write('\n return new ListOf(cPtr, owner);\n\n') for i in range(0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write(' case (int) libsbml.{0}:\n'.format( classes[i]['typecode'])) fileOut.write(' return new {0}(cPtr, owner);\n\n'.format( classes[i]['name'])) fileOut.write(' default:\n') fileOut.write(' return new SBase(cPtr, owner);\n') fileOut.write(' }\n') fileOut.write(' }\n\n') fileOut.write('%}\n\n') fileOut.write('COVARIANT_RTYPE_CLONE({0}Extension)\n'.format( strFunctions.cap(name))) for i in range(0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write('COVARIANT_RTYPE_CLONE({0})\n'.format( classes[i]['name'])) for i in range(0, len(classes)): if (classes[i]['hasListOf'] == True): loName = generalFunctions.getListOfClassName( classes[i], classes[i]['name']) fileOut.write('COVARIANT_RTYPE_CLONE({0})\n'.format( strFunctions.cap(loName))) fileOut.write('\n') for i in range(0, len(classes)): if (classes[i]['hasListOf'] == True): fileOut.write('COVARIANT_RTYPE_LISTOF_GET_REMOVE({0})\n'.format( classes[i]['name'])) fileOut.write('\n') fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0}PkgNamespaces)\n'.format( strFunctions.cap(name))) for i in range(0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0})\n'.format( classes[i]['name'])) for i in range(0, len(classes)): if (classes[i]['hasListOf'] == True): loName = generalFunctions.getListOfClassName( classes[i], classes[i]['name']) fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0})\n'.format( strFunctions.cap(loName))) fileOut.write('\n') for i in range(0, len(classes)): if (classes[i]['abstract'] == True or isBaseClassForOthers(classes[i], classes)): fileOut.write('//\n') fileOut.write( '// Convert {0} objects into the most specific object possible.\n' .format(classes[i]['name'])) fileOut.write('//\n') fileOut.write('%typemap("javaout") {0}*\n'.format( classes[i]['name'])) fileOut.write('{\n') fileOut.write( ' return ({0}) libsbml.DowncastSBase($jnicall, $owner);\n'. format(classes[i]['name'])) fileOut.write('}\n') fileOut.write('\n') fileOut.write('\n') fileOut.write('#endif /* USE_{0} */\n\n'.format(capName))
def writeJava(fileOut, name, plugins, classes): capName = name.upper() fileOut.write('#ifdef USE_{0}\n'.format(capName)) fileOut.write('/**\n') fileOut.write(' * Adds DownCastBase(long cPtr, boolean owner) method for the {0} package extension\n'.format(name)) fileOut.write(' */\n') fileOut.write('%typemap(javacode) {0}Extension\n'.format(strFunctions.cap(name))) fileOut.write('%{\n') fileOut.write(' public SBasePlugin DowncastSBasePlugin(long cPtr, boolean owner)\n') fileOut.write(' {\n') fileOut.write(' if (cPtr == 0) return null;\n\n') fileOut.write(' SBasePlugin sbp = new SBasePlugin(cPtr, false);\n') fileOut.write(' SBase sb = sbp.getParentSBMLObject();\n\n') fileOut.write(' switch( sb.getTypeCode() )\n') fileOut.write(' {\n') listOfPlugins = [] for plugin in plugins: typecode = 'SBML_{0}'.format(createSBase(plugin['sbase'].upper())) if plugin.has_key('typecode') and plugin['typecode'] != None: typecode = plugin['typecode'] if typecode != 'SBML_LIST_OF': fileOut.write(' case (int) libsbml.{0}:\n'.format(typecode)) fileOut.write(' return new {0}{1}Plugin(cPtr, owner);\n\n'.format(strFunctions.cap(name), plugin['sbase'])) else: listOfPlugins.append(plugin) if len(listOfPlugins) > 0: fileOut.write(' case (int) libsbml.SBML_LIST_OF:\n') fileOut.write(' {\n') fileOut.write(' String name = sb.getElementName();\n') for plugin in listOfPlugins: fileOut.write(' if (name.equals("{0}"))\n'.format(strFunctions.lowerFirst(plugin['sbase']))) fileOut.write(' return new {0}{1}Plugin(cPtr, owner);\n\n'.format(strFunctions.cap(name), plugin['sbase'])) fileOut.write(' return new SBasePlugin(cPtr, owner);\n') fileOut.write(' }\n') fileOut.write(' default:\n') fileOut.write(' return new SBasePlugin(cPtr, owner);\n') fileOut.write(' }\n') fileOut.write(' }\n\n') fileOut.write(' public SBase DowncastSBase(long cPtr, boolean owner)\n') fileOut.write(' {\n') fileOut.write(' if (cPtr == 0) return null;\n\n') fileOut.write(' SBase sb = new SBase(cPtr, false);\n') fileOut.write(' switch( sb.getTypeCode() )\n') fileOut.write(' {\n') fileOut.write(' case (int) libsbml.SBML_LIST_OF:\n') fileOut.write(' String name = sb.getElementName();\n') for i in range (0, len(classes)): if (classes[i]['hasListOf'] == True): loName = strFunctions.listOfName(classes[i]['name']) if classes[i].has_key('lo_elementName'): loName = classes[i]['lo_elementName'] if (i==0): fileOut.write(' if (name.equals("{0}"))\n'.format(loName)) else : fileOut.write(' else if (name.equals("{0}"))\n'.format(loName)) fileOut.write(' {\n') fileOut.write(' return new {0}(cPtr, owner);\n'.format(generalFunctions.getListOfClassName (classes[i], classes[i]['name']))) fileOut.write(' }\n') fileOut.write('\n return new ListOf(cPtr, owner);\n\n') for i in range (0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write(' case (int) libsbml.{0}:\n'.format(classes[i]['typecode'])) fileOut.write(' return new {0}(cPtr, owner);\n\n'.format(classes[i]['name'])) fileOut.write(' default:\n') fileOut.write(' return new SBase(cPtr, owner);\n') fileOut.write(' }\n') fileOut.write(' }\n\n') fileOut.write('%}\n\n') fileOut.write('COVARIANT_RTYPE_CLONE({0}Extension)\n'.format(strFunctions.cap(name))) for i in range (0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write('COVARIANT_RTYPE_CLONE({0})\n'.format(classes[i]['name'])) for i in range (0, len(classes)): if (classes[i]['hasListOf'] == True): loName = generalFunctions.getListOfClassName (classes[i], classes[i]['name']) fileOut.write('COVARIANT_RTYPE_CLONE({0})\n'.format(strFunctions.cap(loName))) fileOut.write('\n') for i in range (0, len(classes)): if (classes[i]['hasListOf'] == True): fileOut.write('COVARIANT_RTYPE_LISTOF_GET_REMOVE({0})\n'.format(classes[i]['name'])) fileOut.write('\n') fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0}PkgNamespaces)\n'.format(strFunctions.cap(name))) for i in range (0, len(classes)): if classes[i]['typecode'] != 'HACK': fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0})\n'.format(classes[i]['name'])) for i in range (0, len(classes)): if (classes[i]['hasListOf'] == True): loName = generalFunctions.getListOfClassName (classes[i], classes[i]['name']) fileOut.write('SBMLCONSTRUCTOR_EXCEPTION({0})\n'.format(strFunctions.cap(loName))) fileOut.write('\n') for i in range (0, len(classes)): if (classes[i]['abstract'] == True or isBaseClassForOthers(classes[i], classes)): fileOut.write('//\n') fileOut.write('// Convert {0} objects into the most specific object possible.\n'.format(classes[i]['name'])) fileOut.write('//\n') fileOut.write('%typemap("javaout") {0}*\n'.format(classes[i]['name'])) fileOut.write('{\n') fileOut.write(' return ({0}) libsbml.DowncastSBase($jnicall, $owner);\n'.format(classes[i]['name'])) fileOut.write('}\n') fileOut.write('\n') fileOut.write('\n') fileOut.write('#endif /* USE_{0} */\n\n'.format(capName))