From: <mh...@us...> - 2010-12-31 04:50:30
|
Revision: 12496 http://sbml.svn.sourceforge.net/sbml/?rev=12496&view=rev Author: mhucka Date: 2010-12-31 04:50:24 +0000 (Fri, 31 Dec 2010) Log Message: ----------- 1) Added the src/extension classes to the list of SBML classes. 2) Reworked some of the method signature parsing so that it would handle complicated ones like the constructor for SBMLExtensionNamespaces. Modified Paths: -------------- branches/libsbml-5/src/bindings/swig/swigdoc.py Modified: branches/libsbml-5/src/bindings/swig/swigdoc.py =================================================================== --- branches/libsbml-5/src/bindings/swig/swigdoc.py 2010-12-30 21:51:07 UTC (rev 12495) +++ branches/libsbml-5/src/bindings/swig/swigdoc.py 2010-12-31 04:50:24 UTC (rev 12496) @@ -74,19 +74,29 @@ "OStream", "OStringStream", "Parameter", + "RDFAnnotationParser", "RateRule", - "RDFAnnotationParser", "Reaction", "Rule", "SBMLDocument", + "SBMLDocumentPlugin", "SBMLError", "SBMLErrorLog", + "SBMLExtension", + "SBMLExtensionException", + "SBMLExtensionNamespaces", + "SBMLExtensionRegister", + "SBMLExtensionRegistry", "SBMLNamespaces", "SBMLReader", "SBMLVisitor", "SBMLWriter", "SBO", "SBase", + "SBaseExtensionPoint", + "SBasePlugin", + "SBasePluginCreator", + "SBasePluginCreatorBase", "SimpleSpeciesReference", "Species", "SpeciesReference", @@ -154,16 +164,12 @@ if stripped.startswith('#endif') and (stripped.find('SWIG') >= 0): inSkip = False if inSkip: continue - # HACK: swigdoc.py does not recognize initializations like: - # FunctionName(int value = staticFunctionCall()) this is used by the extensions - # and causes invalid documentation files to be written, thus i skip them for now - if (stripped.find('SBMLExtensionType') >= 0): continue # Track things that we flag as internal, so that we can # remove them from the documentation. - if (stripped.find('@cond doxygen-libsbml-internal') >= 0): isInternal = True - if (stripped.find('@endcond') >= 0): isInternal = False + if (stripped.find('@cond doxygen-libsbml-internal') >= 0): isInternal = True + if (stripped.find('@endcond') >= 0): isInternal = False # Watch for class description, usually at top of file. @@ -216,6 +222,7 @@ if stripped == '/**': docstring = '' lines = '' + nextstart = 0 ignoreThis = False inDocs = True @@ -238,9 +245,9 @@ lines += stripped + ' ' # Space avoids jamming code together. # Keep an eye out for the end of the declaration. - if not stripped.startswith('*') and \ (stripped.endswith(';') or stripped.endswith(')') or stripped.endswith('}')): + # It might be a forward declaration. Skip it. if lines.startswith('class'): continue @@ -252,28 +259,46 @@ # It might be an enum. Skip it. if stripped.endswith('}'): lines = lines[:lines.rfind('{')] + + # If it's not an enum at this point, parse it. if not stripped.startswith('enum'): - stop = lines.rfind('(') - name = lines[:stop].split()[-1] - args = lines[stop:lines.rfind(')')+1] - isConst = lines[lines.rfind(')'):].rfind('const') - - # Swig doesn't seem to mind C++ argument lists, even though they - # have "const", "&", etc. So I'm leaving the arg list unmodified. - func = Method(forLanguage, isInternal, docstring, name, args, (isConst > 0)) + # If this segment begins with a comment, we need to skip over it. + searchstart = lines.rfind('*/') + if (searchstart < 0): + searchstart = 0 - if inClass: - c = self.classes[-1] - c.methods.append(func) - if c.methodVariants.get(name) == None: - c.methodVariants[name] = {} - c.methodVariants[name][name + args] = c.methodVariants[name].get(name + args, 0) + 1 - else: - self.functions.append(func) - # FIXME need do nc variants + # Find (we hope) the end of the method name. + stop = lines[searchstart:].find('(') + # Pull out the method name & signature. + if (stop > 0): + name = lines[searchstart : searchstart + stop].split()[-1] + endparen = lines.rfind(')') + args = lines[searchstart + stop : endparen + 1] + isConst = lines[endparen:].rfind('const') + # Swig doesn't seem to mind C++ argument lists, even though they + # have "const", "&", etc. So I'm leaving the arg list unmodified. + func = Method(forLanguage, isInternal, docstring, name, args, (isConst > 0)) + +# print name + args + + # Reset buffer for the next iteration, to skip the part seen. + lines = lines[endparen + 2:] + + if inClass: + c = self.classes[-1] + c.methods.append(func) + if c.methodVariants.get(name) == None: + c.methodVariants[name] = {} + c.methodVariants[name][name + args] = c.methodVariants[name].get(name + args, 0) + 1 + else: + self.functions.append(func) + # FIXME need do nc variants + + + class CClass: """A CClass encapsulates a C++ class. It has the following public attributes: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |