Ejemplo n.º 1
0
    def generate(self, categoryList, enumerationList):
        """Generate source code for ValueObjects."""

        self.categoryList_ = categoryList
        self.enumerationList_ = enumerationList

        allIncludes = ''

        log.Log.instance().logMessage(' begin generating ValueObjects ...')

        for cat in self.categoryList_.categories('*', self.coreCategories_,
                                                 self.addinCategories_):
            if cat.generateVOs():
                allIncludes += ValueObjects.VO_INCLUDE % {
                    'categoryName': cat.name(),
                    'libRootDirectory':
                    environment.config().libRootDirectory()
                }
                if self.headersInline_:
                    self.generateHeadersInline(cat)
                else:
                    self.generateHeaders(cat)
                    self.generateFunctions(cat)

        self.bufferAll_.set({
            'allIncludes':
            allIncludes,
            'libRootDirectory':
            environment.config().libRootDirectory()
        })
        allFilename = self.rootPath_ + 'vo_all.hpp'
        outputfile.OutputFile(self, allFilename, self.copyright_,
                              self.bufferAll_)

        log.Log.instance().logMessage(' done generating ValueObjects.')
Ejemplo n.º 2
0
    def generate(self, categoryList, enumerationList):
        """Generate source code for ValueObjects."""

        self.categoryList_ = categoryList
        self.enumerationList_ = enumerationList

        allIncludes = ''

        log.Log.instance().logMessage(' begin generating ValueObjects ...')

        for cat in self.categoryList_.categories('*', self.coreCategories_, self.addinCategories_):
            if cat.generateVOs():
                allIncludes += ValueObjects.VO_INCLUDE % {
                    'categoryName' : cat.name(),
                    'libRootDirectory' : environment.config().libRootDirectory() }
                if self.headersInline_:
                    self.generateHeadersInline(cat)
                else:
                    self.generateHeaders(cat)
                    self.generateFunctions(cat)

        self.bufferAll_.set({
            'allIncludes' : allIncludes,
            'libRootDirectory' : environment.config().libRootDirectory() })
        allFilename = self.rootPath_ + 'vo_all.hpp'
        outputfile.OutputFile(self, allFilename, self.copyright_, self.bufferAll_)

        log.Log.instance().logMessage(' done generating ValueObjects.')
Ejemplo n.º 3
0
    def init(self, enumerationList):
        """Generate list of #include directives necessary to compile code
        in this category."""

        self.addinIncludeList_ = self.enumIncludes(enumerationList, False)

        if self.addinIncludes_ == None:
            self.addinIncludeList_ += "#include <%s/%s.hpp>\n" % (environment.config().libRootDirectory(), self.name_)
        else:
            for includeFile in self.addinIncludes_:
                self.addinIncludeList_ += "#include <%s>\n" % includeFile

        if self.generateVOs_:
            self.addinIncludeList_ += "#include <%s/valueobjects/vo_%s.hpp>\n" % (
                environment.config().libRootDirectory(),
                self.name_,
            )

        self.serializationIncludeList_ = self.enumIncludes(enumerationList, True)

        if self.serializationIncludes_ == None:
            self.serializationIncludeList_ += Category.SERIALIZATION_INCLUDES % {
                "categoryName": self.name_,
                "libRootDirectory": environment.config().libRootDirectory(),
            }
        else:
            for includeFile in self.serializationIncludes_:
                self.serializationIncludeList_ += "#include <%s>\n" % includeFile
Ejemplo n.º 4
0
    def generateFunctions(self):
        """Generate source code for all functions in all categories."""
        self.bufferAll_.set({ 'path' : self.relativePath_ })
        loopIncludes = '''\
#include <%s/loop/loop_%s.hpp>
#include <''' + self.relativePath_ + '''/loop.hpp>\n'''
        for cat in self.categoryList_.categories(self.name_,
            self.coreCategories_, self.addinCategories_):
            categoryIncludes = cat.includeList(loopIncludes)
            self.bufferAll_.append("#include <Addins/Cpp/%s.hpp>\n" % cat.name())
            bufferCpp = ''
            bufferHpp = ''
            for func in cat.functions(self.name_): 
                bufferCpp += self.generateFunction(func)
                bufferHpp += self.generateDeclaration(func)
            self.bufferBody_.set({
                'bufferCpp' : bufferCpp,
                'namespaceObjects' : environment.config().namespaceObjects(),
                'categoryIncludes' : categoryIncludes })
            self.bufferHeader_.set({
                'categoryName' : cat.name(),
                'namespaceObjects' : environment.config().namespaceObjects(),
                'bufferHpp' : bufferHpp })
            fileNameCpp = '%scpp_%s.cpp' % ( self.rootPath_, cat.name())
            outputfile.OutputFile(self, fileNameCpp, cat.copyright(), self.bufferBody_)
            fileNameHpp = '%scpp_%s.hpp' % ( self.rootPath_, cat.name())
            outputfile.OutputFile(self, fileNameHpp, cat.copyright(), self.bufferHeader_)
        self.bufferAll_.append("\n")
        fileNameAll = '%saddincpp.hpp' % self.rootPath_
        outputfile.OutputFile(self, fileNameAll, self.copyright_, self.bufferAll_)
Ejemplo n.º 5
0
    def generateCreators(self):
        """Generate source code for all functions in all categories."""

        bufferAll = ''

        for cat in self.categoryList_.categories('*', self.coreCategories_, self.addinCategories_):
            if not cat.generateVOs(): continue

            bufferDeclarations = ''
            bufferCreators = ''

            bufferAll += Serialization.INCLUDE_CREATOR % {
                'categoryName' : cat.name(),
                'libRootDirectory' : environment.config().libRootDirectory() }

            for func in cat.functions('*'):
                if not func.generateVOs(): continue
                bufferDeclarations += Serialization.DECLARE_CREATOR % {
                    'functionName' : func.name() }
                bufferCreators += self.bufferCreator_.set({
                    'cppConversions' : func.parameterList().generate(
                        self.cppConversions_),
                    'enumConversions' : func.parameterList().generate(
                        self.enumConversions_),
                    'functionName' : func.name(),
                    'libraryCall' : func.parameterList().generate(
                        self.libraryCall_),
                    'libraryConversions' : func.parameterList().generate(
                        self.libraryConversions_),
                    'libraryFunction' : func.libraryFunction(),
                    'objectConversions' : func.parameterList().generate(
                        self.objectConversions_),
                    'namespaceObjects' : environment.config().namespaceObjects(),
                    'referenceConversions' : func.parameterList().generate(
                        self.referenceConversions_),
                    'populateObjectIDs' : func.parameterList().generate(
                        self.populateObjectIDs_) })

            self.bufferHeader_.set({
                'categoryName' : cat.name(),
                'bufferDeclarations' : bufferDeclarations,
                'libRootDirectory' : environment.config().libRootDirectory(),
                'namespaceObjects' : environment.config().namespaceObjects() })
            createHeaderFile = self.rootPath_ + 'create/create_' + cat.name() + '.hpp'
            outputfile.OutputFile(self, createHeaderFile, self.copyright_, self.bufferHeader_)

            self.bufferIncludes_.set({
                'bufferCreators' : bufferCreators,
                'serializationIncludes' : cat.serializationIncludes(),
                'categoryName' : cat.name() })
            createBodyFile = self.rootPath_ + 'create/create_' + cat.name() + '.cpp'
            outputfile.OutputFile(self, createBodyFile, self.copyright_, self.bufferIncludes_)

        self.bufferAll_.set({
            'bufferAll' : bufferAll,
            'libRootDirectory' : environment.config().libRootDirectory() })
        createAllFile = self.rootPath_ + 'create/create_all.hpp'
        outputfile.OutputFile(self, createAllFile, self.copyright_, self.bufferAll_)
Ejemplo n.º 6
0
 def generateAutoHeader(self):
     """Generate header file that lists all other headers."""
     bufHeader = ''
     for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
         bufHeader += '#include <Addins/Calc/%s.hpp>\n' % cat.name()
     buf = self.bufferHeader_.text() % { 
         'prefix' : environment.config().prefix(),
         'buffer' : bufHeader }
     fileName = self.rootPath_ + environment.config().libRootDirectory() + '_all.hpp'
     outputfile.OutputFile(self, fileName, self.copyright_, buf, True)
Ejemplo n.º 7
0
 def generateFunctions(self, cat):
     """Generate source for function implementations."""
     codeBuffer = ''
     for func in cat.functions(self.name_): 
         codeBuffer += self.generateHeader(func, ' {')
         codeBuffer += self.generateFunction(func)
     buf = self.bufferIncludes_.text() % {
         'includes' : cat.includeList(),
         'name' : cat.name(),
         'prefix' : environment.config().prefix(),
         'libRoot' : environment.config().libRootDirectory(),
         'code' : codeBuffer }
     fileName = self.rootPath_ + cat.name() + '.cpp'
     outputfile.OutputFile(self, fileName, None, buf, False)
Ejemplo n.º 8
0
    def generateHeaders(self, cat):
        """Generate class source for constructor function prototypes."""
        bufHeader = ''
        for func in cat.functions('*'):
            if func.generateVOs():
                bufHeader += self.generateHeader(func)

        self.bufferIncludesDecl_.set({
            'categoryName' : cat.name(),
            'headers' : bufHeader,
            'libRoot' : environment.config().libRootDirectory(),
            'namespaceObjects' : environment.config().namespaceObjects() })
        fileName = self.rootPath_ + 'vo_' + cat.name() + '.hpp'
        outputfile.OutputFile(self, fileName, self.copyright_, self.bufferIncludesDecl_)
Ejemplo n.º 9
0
 def generateFunctions(self):
     """Generate source for function implementations."""
     for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
         buf = ''
         for func in cat.functions(self.name_): 
             buf += self.generateFunction(func)
         categoryIncludes = cat.includeList(LOOP_INCLUDES)
         buf2 = self.bufferIncludes_.text() % {
             'categoryIncludes' : categoryIncludes,
             'prefix' : environment.config().prefix(),
             'libRoot' : environment.config().libRootDirectory(),
             'buffer' : buf }
         fileName = self.rootPath_ + cat.name() + '.cpp'
         outputfile.OutputFile(self, fileName, cat.copyright(), buf2, True)
Ejemplo n.º 10
0
    def generateFunctions(self, cat):
        """Generate source for function implementations."""
        bufFunc = ''
        for func in cat.functions('*'): 
            if func.generateVOs():
                bufFunc += self.generateFunction(func)

        self.bufferIncludes_.set({
            'categoryName' : cat.name(),
            'functions' : bufFunc,
            'libRoot' : environment.config().libRootDirectory(),
            'namespaceObjects' : environment.config().namespaceObjects() })
        fileName = self.rootPath_ + 'vo_' + cat.name() + '.cpp'
        outputfile.OutputFile(self, fileName, self.copyright_, self.bufferIncludes_)
Ejemplo n.º 11
0
    def __init__(self, addinIds):
        """Initialize the AddinList object."""

        self.categoryList_ = categorylist.CategoryList()
        if environment.config().usingEnumerations():
            self.enumerationList_ = enumerationlist.EnumerationList()
            self.enumerationList_.update(environment.config())
        else:
            self.enumerationList_ = None
        self.categoryList_.init(self.enumerationList_)

        self.addins_ = []
        for addinId in addinIds:
            creator, fileName = AddinList.creators[addinId]
            self.addins_.append(utilities.serializeObject(creator, 'metadata/addins/' + fileName))
Ejemplo n.º 12
0
 def generateFunctions(self):
     """Generate source for function implementations."""
     for cat in self.categoryList_.categories(self.name_):
         self.generateFuncHeaders(cat)
         code = ''
         for func in cat.functions(self.name_): 
             code += GuileAddin.BUF_HEADER % (func.name(), ' {')
             code += self.generateFunction(func)
         buf = self.bufferIncludes_.text() % {
             'includes' : cat.includeList(),
             'categoryName' : cat.name,
             'libRoot' : environment.config().libRootDirectory,
             'prefix' : environment.config().prefix,
             'code' : code }
         fileName= self.rootPath_ + cat.name() + '.cpp'
         outputfile.OutputFile(self, fileName, cat.copyright, buf, False)
Ejemplo n.º 13
0
    def generateFuncMap(self):
        """Generate help text for function wizard."""
        buf = ''
        for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
            buf += '    // %s\n\n' % cat.displayName()
            for func in cat.functions(self.name_, supportedplatform.MANUAL): 
                buf += '    // %s\n\n' % func.name()
                buf += MAPLINE % ('funcMap', func.name(), func.name())
                buf += MAPLINE % ('funcDesc', func.name(), func.description())
                for param in func.parameterList().parameters():
                    buf += PARMLINE % ('argName', func.name(), param.name())
                    buf += PARMLINE % ('argDesc', func.name(), param.description())
                buf += '\n'
# replaced
#        buf2 =''
#        buf2 = self.bufferMap_.text() % { 
#            'prefix' : environment.config().prefix(),
#            'addinClassName' : 'QLAddin',
#            'buffer' : buf }
#        fileName = self.rootPath_ + MAPFILE
#        outputfile.OutputFile(self, fileName, self.copyright_, buf2, True)
# by
        self.bufferMap_.set({
                'prefix' : environment.config().prefix(),
                'addinClassName' : 'CalcAddins_impl',
                'buffer' : buf })
        fileName = self.rootPath_ + MAPFILE
        outputfile.OutputFile(self, fileName, self.copyright_, self.bufferMap_, True)
Ejemplo n.º 14
0
 def includeList(self, loopBuffer=None):
     """Return the list of #include directives required for source code
     relating to this Category."""
     ret = self.addinIncludeList_
     if loopBuffer and self.containsLoopFunction_:
         ret += loopBuffer % (environment.config().libRootDirectory(), self.name_)
     return ret
Ejemplo n.º 15
0
    def __init__(self):
        """Configure the function to loop."""

        # Save a reference to the input parameter on which the function loops.
        self.loopParamRef_ = None
        for param in self.func_.parameterList().parameters():
            if param.name() == self.func_.loopParameter():
                self.loopParamRef_ = param
                break
        if not self.loopParamRef_:
            raise exceptions.BehaviorLoopParameterException(self.func_.name(), self.func_.loopParameter())
        if self.loopParamRef_.default():
            raise exceptions.BehaviorLoopDefaultException(self.func_.name(), self.func_.loopParameter())

        # Try to trap a few of the common problems that would prevent
        # the generated source code of the loop function from compiling.
        if self.loopParamRef_.tensorRank() != common.VECTOR:
            raise exceptions.BehaviorLoopNonVectorException(self.func_.name(), self.func_.loopParameter())
        if self.func_.returnValue().tensorRank() != common.VECTOR:
            raise exceptions.BehaviorReturnNonVectorException(self.func_.name(), self.func_.loopParameter())

        # Configure the function to loop on the given parameter.
        self.loopParamRef_.setLoop(True)
        self.func_.returnValue().setLoop(True)
        self.functionName_ = environment.config().namespaceObjects() + '::' + self.func_.name()
        self.functionSignature_ = ''
Ejemplo n.º 16
0
    def generateAutoHeader(self):
        """Generate header file that lists all other headers."""
        bufHeader = ''
        for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
            bufHeader += '#include <%s.hpp>\n' % cat.name()
# replaced
#        buf = self.bufferHeader_.text() % { 
#            'prefix' : environment.config().prefix(),
#            'buffer' : bufHeader }
#        fileName = self.rootPath_ + environment.config().libRootDirectory() + '_all.hpp'
#        outputfile.OutputFile(self, fileName, self.copyright_, buf, True)
# by
        self.bufferHeader_.set({ 
            'prefix' : environment.config().prefix(),
            'buffer' : bufHeader })
        fileName = self.rootPath_ + environment.config().libRootDirectory() + '_all.hpp'
        outputfile.OutputFile(self, fileName, self.copyright_, self.bufferHeader_, True)
Ejemplo n.º 17
0
 def generateFunctions(self):
     """Generate source for function implementations."""
     for cat in self.categoryList_.categories(self.name_):
         self.generateFuncHeaders(cat)
         code = ''
         for func in cat.functions(self.name_):
             code += GuileAddin.BUF_HEADER % (func.name(), ' {')
             code += self.generateFunction(func)
         buf = self.bufferIncludes_.text() % {
             'includes': cat.includeList(),
             'categoryName': cat.name,
             'libRoot': environment.config().libRootDirectory,
             'prefix': environment.config().prefix,
             'code': code
         }
         fileName = self.rootPath_ + cat.name() + '.cpp'
         outputfile.OutputFile(self, fileName, cat.copyright, buf, False)
Ejemplo n.º 18
0
    def generate(self, categoryList, enumerationList):
        """Generate source code for C addin."""

        self.categoryList_ = categoryList
        self.enumerationList_ = enumerationList

        log.Log.instance().logMessage(' begin generating C ...')
        summaryHeaders = ''
        for cat in self.categoryList_.categories(self.name_):
            self.generateHeaders(cat)
            self.generateFunctions(cat)
            summaryHeaders += '#include <Addins/C/%s.h>\n' % cat.name()
        buf = self.bufferHeader_.text() % {
            'prefix' : environment.config().prefix(),
            'headers' : summaryHeaders }
        fileName = self.rootPath_ + environment.config().prefix() + 'addin.h'
        outputfile.OutputFile(self, fileName, self.copyright_, buf, False)
        log.Log.instance().logMessage(' done generating C.')
Ejemplo n.º 19
0
 def serialize(self, serializer):
     """Load/unload class state to/from serializer object."""
     serializer.serializeAttribute(self, common.NAME)
     serializer.serializeProperty(self, common.DESCRIPTION)
     serializer.serializeProperty(self, common.LONG_DESC, self.description_)
     serializer.serializeObjectDict(self, supportedplatform.SupportedPlatform)
     serializer.serializeProperty(self, common.ALIAS, environment.config().namespaceObjects() + '::' + self.name_)
     serializer.serializeObject(self, parameterlist.ParameterList)
     serializer.serializeBoolean(self, common.DOCUMENTATION_ONLY)
     serializer.serializeAttributeBoolean(self, common.DEPENDENCY_TRIGGER, True)
     serializer.serializeAttributeBoolean(self, 'visible', True)
Ejemplo n.º 20
0
 def generateHeaders(self, cat):
     """Generate source for function prototypes."""
     bufHeader = ''
     for func in cat.functions(self.name_): 
         bufHeader += self.generateHeader(func, ';\n')
     buf = CAddin.BUFFER_HEADER % {
         'cat_name' : cat.name(),
         'func_headers' : bufHeader,
         'lib_name' : environment.config().prefix() }
     fileName = self.rootPath_ + cat.name() + '.h'
     fileHeader = outputfile.OutputFile(self, fileName, None, buf, False)
Ejemplo n.º 21
0
 def generateLoops(self, cat):
     """Generate type definitions required for source code for loop functions."""
     buf = ''
     for func in cat.functions('*'): 
         if func.loopParameter():
             buf += self.generateLoop(func)
     self.bufferFile_.set({
         'buffer' : buf,
         'namespace' : environment.config().namespaceObjects() })
     fileName = self.rootPath_ + 'loop_' + cat.name() + '.hpp'
     outputfile.OutputFile(self, fileName, self.copyright_, self.bufferFile_)
Ejemplo n.º 22
0
    def invokeRule(self):

        return self.ruleResult_ % {
            'classname' : self.param_.fullType().classname(),
            common.DEFAULT_VALUE : self.param_.default(),
            common.DESC_LEN : len(self.paramDesc_),
            common.DESCRIPTION : self.paramDesc_,
            common.ERROR_VALUE : self.param_.errorValue(),
            common.INDENT2 : self.indent_ + '    ',
            common.INDENT : self.indent_,
            common.NAME : self.param_.name(),
            common.NAME_CONVERTED : self.param_.nameConverted(),
            common.NAME_UPPER : self.param_.name().upper(),
            common.NAMESPACE_LIB : environment.config().namespaceLibrary(),
            common.NAMESPACE_OBJ : environment.config().namespaceObjects(),
            common.NATIVE_TYPE : self.param_.fullType().nativeType(),
            common.OBJECT_REFERENCE : self.param_.fullType().objectReference(),
            common.SUPER_TYPE : self.param_.fullType().superType(),
            common.TENSOR_RANK : self.param_.tensorRank(),
            common.TYPE : self.param_.fullType().value() }
Ejemplo n.º 23
0
    def generateHeaders(self, cat):
        """Generate class source for constructor function prototypes."""
        bufHeader = ''
        for func in cat.functions('*'):
            if func.generateVOs():
                bufHeader += self.generateHeader(func)

        self.bufferIncludesDecl_.set({
            'categoryName':
            cat.name(),
            'headers':
            bufHeader,
            'libRoot':
            environment.config().libRootDirectory(),
            'namespaceObjects':
            environment.config().namespaceObjects()
        })
        fileName = self.rootPath_ + 'vo_' + cat.name() + '.hpp'
        outputfile.OutputFile(self, fileName, self.copyright_,
                              self.bufferIncludesDecl_)
Ejemplo n.º 24
0
 def generateFuncHeaders(self, cat):
     """Generate source for function prototypes."""
     prototypes = ''
     for func in cat.functions(self.name): 
         prototypes += GuileAddin.BUF_HEADER % (func.name, ';\n')
     buf = self.bufferHeader.text % {
         'categoryName' : cat.name,
         'prefix' : environment.config().prefix,
         'prototypes' : prototypes }
     fileName =  self.rootPath_ + cat.name() + '.h'
     outputfile.OutputFile(self, fileName, cat.copyright, buf, False)
Ejemplo n.º 25
0
    def generateFunctions(self, cat):
        """Generate source for function implementations."""
        bufFunc = ''
        for func in cat.functions('*'):
            if func.generateVOs():
                bufFunc += self.generateFunction(func)

        self.bufferIncludes_.set({
            'categoryName':
            cat.name(),
            'functions':
            bufFunc,
            'libRoot':
            environment.config().libRootDirectory(),
            'namespaceObjects':
            environment.config().namespaceObjects()
        })
        fileName = self.rootPath_ + 'vo_' + cat.name() + '.cpp'
        outputfile.OutputFile(self, fileName, self.copyright_,
                              self.bufferIncludes_)
Ejemplo n.º 26
0
    def generate(self, categoryList, enumerationList):
        """Generate doxygen documentation files."""

        self.categoryList_ = categoryList
        self.enumerationList_ = enumerationList

        log.Log.instance().logMessage(' begin generating Doxygen ...')
        self.generateDocs()
        if environment.config().usingEnumerations():
            self.generateEnums()
        self.generateCategoryDoc()
        log.Log.instance().logMessage(' done generating Doxygen.')
Ejemplo n.º 27
0
 def generateFuncHeaders(self, cat):
     """Generate source for function prototypes."""
     prototypes = ''
     for func in cat.functions(self.name):
         prototypes += GuileAddin.BUF_HEADER % (func.name, ';\n')
     buf = self.bufferHeader.text % {
         'categoryName': cat.name,
         'prefix': environment.config().prefix,
         'prototypes': prototypes
     }
     fileName = self.rootPath_ + cat.name() + '.h'
     outputfile.OutputFile(self, fileName, cat.copyright, buf, False)
Ejemplo n.º 28
0
 def generateHeaders(self):
     """Generate source for function prototypes."""
     for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
         buf = ''
         for func in cat.functions(self.name_, supportedplatform.MANUAL): 
             buf += self.generateHeader(func)
         buf2 = self.bufferCategory_.text() % {
             'prefix' : environment.config().prefix(),
             'categoryName' : cat.name(),
             'buffer' : buf }
         fileName = self.rootPath_ + cat.name() + '.hpp'
         outputfile.OutputFile(self, fileName, cat.copyright(), buf2, True)
Ejemplo n.º 29
0
    def invokeRule(self):

        return self.ruleResult_ % {
            'classname': self.param_.fullType().classname(),
            common.DEFAULT_VALUE: self.param_.default(),
            common.DESC_LEN: len(self.paramDesc_),
            common.DESCRIPTION: self.paramDesc_,
            common.ERROR_VALUE: self.param_.errorValue(),
            common.INDENT2: self.indent_ + '    ',
            common.INDENT: self.indent_,
            common.NAME: self.param_.name(),
            common.NAME_CONVERTED: self.param_.nameConverted(),
            common.NAME_UPPER: self.param_.name().upper(),
            common.NAMESPACE_LIB: environment.config().namespaceLibrary(),
            common.NAMESPACE_OBJ: environment.config().namespaceObjects(),
            common.NATIVE_TYPE: self.param_.fullType().nativeType(),
            common.OBJECT_REFERENCE: self.param_.fullType().objectReference(),
            common.SUPER_TYPE: self.param_.fullType().superType(),
            common.TENSOR_RANK: self.param_.tensorRank(),
            common.TYPE: self.param_.fullType().value()
        }
Ejemplo n.º 30
0
 def generateFunctionList(self, allFuncs):
     """Generate alphabetical list of links to all functions."""
     allFuncs.sort()
     bufList = ''
     for func in allFuncs:
         bufList += '\\ref %s ()\\n\n' % func
     self.bufferHeader_.set({
         'application' : environment.config().namespaceObjects(),
         'count' : len(allFuncs),
         'list' : bufList })
     fileName = self.rootPath_ + 'allfunctions.docs'
     outputfile.OutputFile(self, fileName, self.copyright_, self.bufferHeader_)
Ejemplo n.º 31
0
 def generateBody(self, addin):
     """Generate source code for function body."""
     return Constructor.funcCtorBuffer_ % {
         'functionName' : self.name_,
         'idStrip' : addin.idStrip(self.parameterList_),
         'idSuffix' : addin.objectIdSuffix(),
         'libraryFunction' : self.libraryFunction_,
         'libraryParameters' : self.parameterList_.generate(addin.libraryCall()),
         'namespaceObjects' : environment.config().namespaceObjects(),
         'overwriteVariable' : addin.overwriteVariable(),
         'repositoryClass' : addin.repositoryClass(),
         'voParameters' : self.parameterList_.generate(addin.voCall()) }
Ejemplo n.º 32
0
 def enumIncludes(self, enumerationList, constructorOnly):
     ret = ""
     if environment.config().usingEnumerations():
         enumIncludes = []
         for func in self.functions_.values():
             if constructorOnly and not func.generateVOs():
                 continue
             enumIncludes.extend(enumerationList.enumIncludes(func.parameterList().parameters()))
         enumIncludesUnique = self.sort_uniq(enumIncludes)
         for enumInclude in enumIncludesUnique:
             ret += "#include <%s>\n" % enumInclude
     return ret
Ejemplo n.º 33
0
    def generate(self, categoryList, enumerationList):
        """Generate doxygen documentation files."""

        self.categoryList_ = categoryList
        self.enumerationList_ = enumerationList

        log.Log.instance().logMessage(' begin generating Doxygen ...')
        self.generateDocs()
        if environment.config().usingEnumerations():
            self.generateEnums()
        self.generateCategoryDoc()
        log.Log.instance().logMessage(' done generating Doxygen.')
Ejemplo n.º 34
0
 def generateFunctionList(self, allFuncs):
     """Generate alphabetical list of links to all functions."""
     allFuncs.sort()
     bufList = ''
     for func in allFuncs:
         bufList += '\\ref %s ()\\n\n' % func
     self.bufferHeader_.set({
         'application' : environment.config().namespaceObjects(),
         'count' : len(allFuncs),
         'list' : bufList })
     fileName = self.rootPath_ + 'allfunctions.docs'
     outputfile.OutputFile(self, fileName, self.copyright_, self.bufferHeader_)
Ejemplo n.º 35
0
    def generateFactory(self):
        """Generate source code for all functions in all categories."""

        bufferCreators = ''

        for cat in self.categoryList_.categories('*', self.coreCategories_, self.addinCategories_):
            if not cat.generateVOs(): continue

            bufferCreators += '\n        // %s\n\n' % cat.displayName()

            for func in cat.functions('*'):
                if not func.generateVOs(): continue

                bufferCreators += Serialization.REGISTER_CREATOR % {
                    'functionName' : func.name() }

        self.bufferFactory_.set({
            'bufferCreators' : bufferCreators,
            'libRootDirectory' : environment.config().libRootDirectory(),
            'namespaceObjects' : environment.config().namespaceObjects() })
        factoryFile = self.rootPath_ + 'register_creators.cpp'
        outputfile.OutputFile(self, factoryFile, self.copyright_, self.bufferFactory_)
Ejemplo n.º 36
0
    def generateFactory(self):
        """Generate source code for all functions in all categories."""

        bufferCreators = ''

        for cat in self.categoryList_.categories('*', self.coreCategories_, self.addinCategories_):
            if not cat.generateVOs(): continue

            bufferCreators += '\n        // %s\n\n' % cat.displayName()

            for func in cat.functions('*'):
                if not func.generateVOs(): continue

                bufferCreators += Serialization.REGISTER_CREATOR % {
                    'functionName' : func.name() }

        self.bufferFactory_.set({
            'bufferCreators' : bufferCreators,
            'libRootDirectory' : environment.config().libRootDirectory(),
            'namespaceObjects' : environment.config().namespaceObjects() })
        factoryFile = self.rootPath_ + 'register_creators.cpp'
        outputfile.OutputFile(self, factoryFile, self.copyright_, self.bufferFactory_)
Ejemplo n.º 37
0
    def generateFunctions(self):
        """Generate source for function implementations."""
        for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
            buf = ''
            for func in cat.functions(self.name_): 
                buf += self.generateFunction(func)
            categoryIncludes = cat.includeList(LOOP_INCLUDES)
# replaced
#            buf2 = self.bufferIncludes_.text() % {
#                'categoryIncludes' : categoryIncludes,
#                'prefix' : environment.config().prefix(),
#                'libRoot' : environment.config().libRootDirectory(),
#                'buffer' : buf }
#            fileName = self.rootPath_ + cat.name() + '.cpp'
#            outputfile.OutputFile(self, fileName, cat.copyright(), buf2, True)
# by
            self.bufferIncludes_.set({
                'categoryIncludes' : categoryIncludes,
                'prefix' : environment.config().prefix(),
                'libRoot' : environment.config().libRootDirectory(),
                'buffer' : buf })
            fileName = self.rootPath_ + cat.name() + '.cpp'
            outputfile.OutputFile(self, fileName, cat.copyright(), self.bufferIncludes_, True)
Ejemplo n.º 38
0
 def generateInitFunc(self):
     """Generate initialisation function."""
     headers = ''
     registrations = ''
     i = 0
     for cat in self.categoryList_.categories(self.name_):
         i += 1
         headers += '#include <' + cat.name() + '.h>\n'
         registrations += self.generateRegistrations(cat)
         #if i < len(self.categoryList_.categoryNames()):
         #    registrations += '\n'
     buf = self.bufferInitFunc.text % (headers, registrations)
     fileName = self.rootPath + environment.config().prefix + 'addin.c'
     outputfile.OutputFile(self, fileName, self.copyright, buf, False)
Ejemplo n.º 39
0
 def generateBody(self, addin):
     """Generate source code for function body."""
     return Constructor.funcCtorBuffer_ % {
         'functionName': self.name_,
         'idStrip': addin.idStrip(self.parameterList_),
         'idSuffix': addin.objectIdSuffix(),
         'libraryFunction': self.libraryFunction_,
         'libraryParameters': self.parameterList_.generate(
             addin.libraryCall()),
         'namespaceObjects': environment.config().namespaceObjects(),
         'overwriteVariable': addin.overwriteVariable(),
         'repositoryClass': addin.repositoryClass(),
         'voParameters': self.parameterList_.generate(addin.voCall())
     }
Ejemplo n.º 40
0
 def generateInitFunc(self):
     """Generate initialisation function."""
     headers = ''
     registrations = ''
     i = 0
     for cat in self.categoryList_.categories(self.name_):
         i += 1
         headers += '#include <' + cat.name() + '.h>\n'
         registrations += self.generateRegistrations(cat)
         #if i < len(self.categoryList_.categoryNames()):
         #    registrations += '\n'
     buf = self.bufferInitFunc.text % (headers, registrations)
     fileName = self.rootPath + environment.config().prefix + 'addin.c'
     outputfile.OutputFile(self, fileName, self.copyright, buf, False)
Ejemplo n.º 41
0
 def generateIDL(self):
     """Generate the IDL file for the addin."""
     buf = ''
     for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
         buf += '                // %s\n\n' % cat.name()
         for func in cat.functions(self.name_, supportedplatform.MANUAL): 
             parameterList = func.parameterList().generate(self.ruleIDL_)
             returnTypeIDL = self.returnTypeIDL_.apply(func.returnValue())
             buf += self.bufferIdlFunction_.text() % (returnTypeIDL, 
                 func.name(), parameterList)
     buf2 = self.bufferIdlHeader_.text() % { 'buffer' : buf }
     idlFile = environment.config().namespaceLibrary() + 'AddinCalc.idl'
     fileName = self.rootPath_ + idlFile
     outputfile.OutputFile(self, fileName, self.copyright_, buf2, True)
Ejemplo n.º 42
0
 def generateBody(self, addin):
     """Generate source code for the body of the function."""
     if self.functionSignature_:
         functionSignature = '(' + environment.config().namespaceObjects() + '::' + self.functionSignature_ + ')'
     else:
         functionSignature = ''
     addin.bufferLoop().set({
         'inputList' : self.func_.parameterList().generate(addin.loopInputs()),
         'inputParam' : addin.loopName(self.loopParamRef_),
         'functionCodeName' : self.functionCodeName_,
         'functionName' : self.functionName_,
         'functionSignature' : functionSignature,
         'inputType' : addin.loopReturnType().apply(self.loopParamRef_),
         'returnType' : addin.loopReturnType().apply(self.func_.returnValue()) })
     return addin.bufferLoop().text()
Ejemplo n.º 43
0
 def serialize(self, serializer):
     """Load/unload class state to/from serializer object."""
     serializer.serializeAttribute(self, common.NAME)
     serializer.serializeProperty(self, common.DESCRIPTION)
     serializer.serializeProperty(self, common.LONG_DESC, self.description_)
     serializer.serializeObjectDict(self,
                                    supportedplatform.SupportedPlatform)
     serializer.serializeProperty(
         self, common.ALIAS,
         environment.config().namespaceObjects() + '::' + self.name_)
     serializer.serializeObject(self, parameterlist.ParameterList)
     serializer.serializeBoolean(self, common.DOCUMENTATION_ONLY)
     serializer.serializeAttributeBoolean(self, common.DEPENDENCY_TRIGGER,
                                          True)
     serializer.serializeAttributeBoolean(self, 'visible', True)
Ejemplo n.º 44
0
    def __init__(self, addinIds):
        """Initialize the AddinList object."""

        self.categoryList_ = categorylist.CategoryList()
        if environment.config().usingEnumerations():
            self.enumerationList_ = enumerationlist.EnumerationList()
        else:
            self.enumerationList_ = None
        self.categoryList_.init(self.enumerationList_)

        self.addins_ = []
        for addinId in addinIds:
            creator, fileName = AddinList.creators[addinId]
            self.addins_.append(
                utilities.serializeObject(creator,
                                          'metadata/addins/' + fileName))
Ejemplo n.º 45
0
 def generateCategoryDoc(self):
     """Generate page listing function categories."""
     # ensure list of links is sorted alphabetically by display name
     dispNmToCatNm = {}
     displayNames = []
     for cat in self.categoryList_.categories(
         '*', self.coreCategories_, self.addinCategories_):
         dispNmToCatNm[cat.displayName()] = cat.name()
         displayNames.append(cat.displayName())
     displayNames.sort()
     bufCat = ''
     for displayKey in displayNames:
         bufCat += '    \\ref func_%s\\n\n' % dispNmToCatNm[displayKey]
     self.bufferCategories_.set({
         'application' : environment.config().namespaceObjects(),
         'categories' : bufCat })
     fileName = self.rootPath_ + 'categories.docs'
     outputfile.OutputFile(self, fileName, self.copyright_, self.bufferCategories_)
Ejemplo n.º 46
0
 def generateCategoryDoc(self):
     """Generate page listing function categories."""
     # ensure list of links is sorted alphabetically by display name
     dispNmToCatNm = {}
     displayNames = []
     for cat in self.categoryList_.categories(
         '*', self.coreCategories_, self.addinCategories_):
         dispNmToCatNm[cat.displayName()] = cat.name()
         displayNames.append(cat.displayName())
     displayNames.sort()
     bufCat = ''
     for displayKey in displayNames:
         bufCat += '\\ref func_%s\\n\n' % dispNmToCatNm[displayKey]
     self.bufferCategories_.set({
         'application' : environment.config().namespaceObjects(),
         'categories' : bufCat })
     fileName = self.rootPath_ + 'categories.docs'
     outputfile.OutputFile(self, fileName, self.copyright_, self.bufferCategories_)
Ejemplo n.º 47
0
    def generateHeaders(self):
        """Generate source for function prototypes."""
        for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
            buf = ''
            for func in cat.functions(self.name_, supportedplatform.MANUAL): 
                buf += self.generateHeader(func)
# replaced
#            buf2 = self.bufferCategory_.text() % {
#                'prefix' : environment.config().prefix(),
#                'categoryName' : cat.name(),
#                'buffer' : buf }
#            fileName = self.rootPath_ + cat.name() + '.hpp'
#            outputfile.OutputFile(self, fileName, cat.copyright(), buf2, True)
# by
            self.bufferCategory_.set({
                'prefix' : environment.config().prefix(),
                'categoryName' : cat.name(),
                'buffer' : buf })
            fileName = self.rootPath_ + cat.name() + '.hpp'
            outputfile.OutputFile(self, fileName, cat.copyright(), self.bufferCategory_, True)
Ejemplo n.º 48
0
    def generateAddin(self):
        """Generate source code to register functions."""
        registerCalls = ''
        unregisterCalls = ''
        registerDeclarations = ''
        unregisterDeclarations = ''
        self.functionCount_ = 0
        for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_, supportedplatform.MANUAL):
            categoryName = cat.name().capitalize()
            registerCalls += 8 * ' ' + 'register' + categoryName + '(xDll);\n'
            unregisterCalls += 8 * ' ' + 'unregister' + categoryName + '(xDll);\n'
            registerDeclarations += 'extern void register' + categoryName + '(const XLOPER&);\n'
            unregisterDeclarations += 'extern void unregister' + categoryName + '(const XLOPER&);\n'
            self.generateRegisterFunctions(cat)

        self.bufferRegisterCall_.set({
            'prefix' : environment.config().prefix().capitalize(),
            'registerCalls' : registerCalls,
            'unregisterCalls' : unregisterCalls,
            'registerDeclarations' : registerDeclarations,
            'unregisterDeclarations' : unregisterDeclarations })
        registerCall = self.rootPath_ + 'register/register_all.cpp'
        outputfile.OutputFile(self, registerCall, self.copyright_, self.bufferRegisterCall_)
Ejemplo n.º 49
0
    def generateIDL(self):
        """Generate the IDL file for the addin."""
        buf = ''
        for cat in self.categoryList_.categories(self.name_, self.coreCategories_, self.addinCategories_):
            buf += '                // %s\n\n' % cat.name()
            for func in cat.functions(self.name_, supportedplatform.MANUAL): 
                parameterList = func.parameterList().generate(self.ruleIDL_)
                returnTypeIDL = self.returnTypeIDL_.apply(func.returnValue())
# replaced
#                buf += self.bufferIdlFunction_.text() % (returnTypeIDL, 
#                    func.name(), parameterList)
# by
                buf += '                ' + returnTypeIDL + ' ' + func.name() + '(' + parameterList + ');\n\n' 
# replaced
#        buf2 = self.bufferIdlHeader_.text() % { 'buffer' : buf }
#        idlFile = environment.config().namespaceLibrary() + 'AddinCalc.idl'
#        fileName = self.rootPath_ + idlFile
#        outputfile.OutputFile(self, fileName, self.copyright_, buf2, True)
# by
        self.bufferIdlHeader_.set({ 'buffer' : buf })
        idlFile = environment.config().namespaceLibrary() + 'AddinCalc.idl'
        fileName = self.rootPath_ + idlFile
        outputfile.OutputFile(self, fileName, self.copyright_, self.bufferIdlHeader_, True)
Ejemplo n.º 50
0
 def printCopyright(self, copyright):
     """Print the copyright message relevant for this source code file."""
     copyrightTrim = OutputFile.TRIM_WHITESPACE.sub(' ', copyright)
     self.outFile_.write(environment.config().copyrightBuffer() %
                         {'copyright': copyrightTrim})
Ejemplo n.º 51
0
    def generateRegister(self):
        """Generate source code for serialization factory."""

        allIncludes = ''
        bufferRegister = ''

        # Keep track of the ID assigned to each Addin class by
        # the boost serialization framework.  This number is initialized to 4
        # because 0-3 are reserved for ObjectHandler as explained in file
        # QuantLibAddin/qlo/serialization/register/serialization_oh.cpp
        classID = 4

        # Initialize the global map with the values reserved for ObjectHandler.
        # 0 and 1 refer respectively to ValueObject and vector of ValueObject,
        # but these are omitted because they never occur in app XML data.
        idMap = { 'ohGroup' : 2, 'ohRange' : 3 }

        for cat in self.categoryList_.categories(
            '*', self.coreCategories_, self.addinCategories_):

            if not cat.generateVOs(): continue

            bufferCpp = ''
            allIncludes += Serialization.REGISTER_INCLUDE % {
                'categoryName' : cat.name(),
                'addinDirectory' : environment.config().libRootDirectory() }

            bufferRegister += Serialization.REGISTER_TYPE % {
                'categoryDisplayName' : cat.displayName(),
                'categoryName' : cat.name() }

            self.bufferSerializeDeclaration_.set({
                'addinDirectory' : environment.config().libRootDirectory(),
                'categoryName' : cat.name(),
                'namespaceAddin' : environment.config().namespaceObjects() })
            headerFile = '%sregister/serialization_%s.hpp' % (
                    self.rootPath_, cat.name() )
            outputfile.OutputFile(self, headerFile, self.copyright_, self.bufferSerializeDeclaration_)

            for func in cat.functions('*'):
                if not func.generateVOs(): continue

                bufferCpp += Serialization.REGISTER_CALL % {
                    'classID' : classID,
                    'functionName' : func.name(),
                    'namespaceObjects' : environment.config().namespaceObjects() }

                idMap[func.name()] = classID
                classID += 1

            self.bufferSerializeBody_.set({
                'addinDirectory' : environment.config().libRootDirectory(),
                'bufferCpp' : bufferCpp,
                'categoryName' : cat.name(),
                'libRootDirectory' : environment.config().libRootDirectory(),
                'namespaceAddin' : environment.config().namespaceObjects() })
            cppFile = '%sregister/serialization_%s.cpp' % ( self.rootPath_, cat.name() )
            outputfile.OutputFile(self, cppFile, self.copyright_, self.bufferSerializeBody_)

        self.bufferSerializeAll_.set({
            'includeGuard' : environment.config().libRootDirectory(),
            'allIncludes' : allIncludes,
            'addinDirectory' : environment.config().libRootDirectory() })
        allFilename = self.rootPath_ + 'register/serialization_all.hpp'
        outputfile.OutputFile(self, allFilename, self.copyright_, self.bufferSerializeAll_)

        self.bufferSerializeRegister_.set({
            'addinDirectory' : environment.config().libRootDirectory(),
            'bufferRegister' : bufferRegister,
            'namespaceAddin' : environment.config().namespaceObjects() })
        factoryFile = self.rootPath_ + 'register/serialization_register.hpp'
        outputfile.OutputFile(self, factoryFile, self.copyright_, self.bufferSerializeRegister_)