コード例 #1
0
 def print_derived_listof_types(self, fileout):
     if self.binding == 'java' or self.binding == 'csharp':
         for element in self.elements:
             if not element['name'].endswith('Document') and \
                     element['hasListOf']:
                 name = strFunctions.lower_list_of_name_no_prefix(
                     element['name'])
                 loname = strFunctions.prefix_name(
                     strFunctions.list_of_name(element['name']))
                 fileout.copy_line_verbatim(
                     '      else if (name == \"{0}\")\n'
                     ''.format(name))
                 fileout.copy_line_verbatim('      {\n')
                 fileout.copy_line_verbatim('         return new {0}(cPtr, '
                                            'owner);\n'.format(loname))
                 fileout.copy_line_verbatim('      }\n')
     else:
         for element in self.elements:
             if not element['name'].endswith('Document') and \
                     element['hasListOf']:
                 name = strFunctions.lower_list_of_name_no_prefix(
                     element['name'])
                 loname = strFunctions.prefix_name(
                     strFunctions.list_of_name(element['name']))
                 fileout.copy_line_verbatim(
                     '      else if (name == \"{0}\")\n'
                     ''.format(name))
                 fileout.copy_line_verbatim('      {\n')
                 fileout.copy_line_verbatim(
                     '         return SWIGTYPE_p_{0};\n'.format(loname))
                 fileout.copy_line_verbatim('      }\n')
コード例 #2
0
 def print_derived_types(self, fileout):
     libname = global_variables.library_name.lower()
     if self.binding == 'java' or self.binding == 'csharp':
         for element in self.elements:
             if not element['name'].endswith('Document'):
                 if not 'document' in element or not element['document']:
                     name = strFunctions.prefix_name(element['name'])
                     fileout.copy_line_verbatim('    case (int) {0}.{1}:'
                                                '\n'.format(
                                                    libname,
                                                    element['typecode']))
                     fileout.copy_line_verbatim(
                         '      return new {0}(cPtr, owner)'
                         ';\n'.format(name))
                     fileout.skip_line()
     else:
         for element in self.elements:
             if not element['name'].endswith('Document'):
                 if not 'document' in element or not element['document']:
                     name = strFunctions.prefix_name(element['name'])
                     fileout.copy_line_verbatim('    case {0}:'
                                                '\n'.format(
                                                    element['typecode']))
                     fileout.copy_line_verbatim(
                         '      return SWIGTYPE_p_{0}'
                         ';\n'.format(name))
                     fileout.skip_line()
コード例 #3
0
ファイル: BaseBindingsFiles.py プロジェクト: hovo1990/deviser
 def print_includes(self, fileout):
     for element in self.elements:
         if not element['name'].endswith('Document'):
             name = strFunctions.prefix_name(element['name'])
             fileout.copy_line_verbatim('%include <{0}/{1}.h>\n'
                                        ''.format(global_variables.language,
                                                  name))
             if element['hasListOf']: 
                 loname = strFunctions.prefix_name(
                     strFunctions.list_of_name(element['name']))
                 fileout.copy_line_verbatim('%include <{0}/{1}.h>\n'
                                            ''.format(global_variables.language,
                                                      loname))
コード例 #4
0
 def print_includes(self, fileout):
     for element in self.elements:
         if not element['name'].endswith('Document'):
             name = strFunctions.prefix_name(element['name'])
             fileout.copy_line_verbatim('%include <{0}/{1}.h>\n'
                                        ''.format(global_variables.language,
                                                  name))
             if element['hasListOf']:
                 loname = strFunctions.prefix_name(
                     strFunctions.list_of_name(element['name']))
                 fileout.copy_line_verbatim('%include <{0}/{1}.h>\n'
                                            ''.format(
                                                global_variables.language,
                                                loname))
コード例 #5
0
 def print_for_all_classes(self, fileout, line, classes=True, lists=True):
     l_len = len(line)
     declaration = line[0:l_len - 1]
     if classes:
         for element in self.elements:
             name = strFunctions.prefix_name(element['name'])
             fileout.copy_line_verbatim('{0}({1})\n'.format(
                 declaration, name))
     if lists:
         for element in self.elements:
             if element['hasListOf']:
                 loname = strFunctions.prefix_name(
                     strFunctions.list_of_name(element['name']))
                 fileout.copy_line_verbatim('{0}({1})\n'.format(
                     declaration, loname))
コード例 #6
0
ファイル: BaseBindingsFiles.py プロジェクト: hovo1990/deviser
 def print_for_all_classes(self, fileout, line, classes=True, lists=True):
     l_len = len(line)
     declaration = line[0:l_len-1]
     if classes:
         for element in self.elements:
             name = strFunctions.prefix_name(element['name'])
             fileout.copy_line_verbatim('{0}({1})\n'.format(declaration,
                                                            name))
     if lists:
         for element in self.elements:
             if element['hasListOf']:
                 loname = strFunctions.prefix_name(
                     strFunctions.list_of_name(element['name']))
                 fileout.copy_line_verbatim('{0}({1})\n'.format(declaration,
                                                                loname))
コード例 #7
0
ファイル: BaseClassFiles.py プロジェクト: hovo1990/deviser
 def print_leave_code(self, fileout):
     fileout.skip_line(2)
     for element in self.elements:
         if not element['name'].endswith('Document'):
             if not 'document' in element or not element['document']:
                 name = strFunctions.prefix_name(element['name'])
                 self.write_leave_code(fileout, name)
コード例 #8
0
 def print_document_errors(self, fileout):
     root = {'baseElements': self.elements}
     doc = query.get_class(global_variables.document_class, root)
     if not doc:
         docname = 'Document'
     else:
         docname = strFunctions.prefix_name(doc['name'])
     libname = strFunctions.get_library_suffix(global_variables.library_name)
     fileout.copy_line_verbatim('          if ( errorId == {0}{1}Allowed'
                                'CoreAttributes\n'.format(libname, docname))
     level = False
     version = False
     if doc and 'attribs' in doc:
         for a in doc['attribs']:
             if a['name'] == 'level':
                 level = True
             elif a['name'] == 'version':
                 version = True
     if level:
         fileout.copy_line_verbatim('            || errorId == {0}{1}'
                                    'LevelMustBeInteger\n'
                                    ''.format(libname, docname))
     if version:
         fileout.copy_line_verbatim('            || errorId == {0}{1}'
                                    'VersionMustBeInteger\n'
                                    ''.format(libname, docname))
     fileout.copy_line_verbatim('            || errorId == InvalidNamespace'
                                'On{0})\n'.format(global_variables.prefix))
コード例 #9
0
 def print_leave_code(self, fileout):
     fileout.skip_line(2)
     for element in self.elements:
         if not element['name'].endswith('Document'):
             if not 'document' in element or not element['document']:
                 name = strFunctions.prefix_name(element['name'])
                 self.write_leave_code(fileout, name)
コード例 #10
0
 def print_visit_header(self, fileout):
     for element in self.elements:
         if not element['name'].endswith('Document'):
             if not 'document' in element or not element['document']:
                 name = strFunctions.prefix_name(element['name'])
                 self.write_visit_header(fileout, name)
                 fileout.skip_line(2)
コード例 #11
0
ファイル: BaseClassFiles.py プロジェクト: hovo1990/deviser
 def print_document_errors(self, fileout):
     root = {'baseElements': self.elements}
     doc = query.get_class(global_variables.document_class, root)
     if not doc:
         docname = 'Document'
     else:
         docname = strFunctions.prefix_name(doc['name'])
     libname = strFunctions.get_library_suffix(global_variables.library_name)
     fileout.copy_line_verbatim('          if ( errorId == {0}{1}Allowed'
                                'CoreAttributes\n'.format(libname, docname))
     level = False
     version = False
     if doc and 'attribs' in doc:
         for a in doc['attribs']:
             if a['name'] == 'level':
                 level = True
             elif a['name'] == 'version':
                 version = True
     if level:
         fileout.copy_line_verbatim('            || errorId == {0}{1}'
                                    'LevelMustBeInteger\n'
                                    ''.format(libname, docname))
     if version:
         fileout.copy_line_verbatim('            || errorId == {0}{1}'
                                    'VersionMustBeInteger\n'
                                    ''.format(libname, docname))
     fileout.copy_line_verbatim('            || errorId == InvalidNamespace'
                                'On{0})\n'.format(global_variables.prefix))
コード例 #12
0
ファイル: BaseClassFiles.py プロジェクト: hovo1990/deviser
 def print_visit_header(self, fileout):
     for element in self.elements:
         if not element['name'].endswith('Document'):
             if not 'document' in element or not element['document']:
                 name = strFunctions.prefix_name(element['name'])
                 self.write_visit_header(fileout, name)
                 fileout.skip_line(2)
コード例 #13
0
    def print_includes(self, fileout):
        """
        Write the #include lines to the output file

        :param fileout: object representing output file we are writing.
        """
        for element in self.elements:
            name = SF.prefix_name(element['name'])
            fileout.copy_line_verbatim('#include <{0}/{1}.h>\n'
                                       ''.format(gv.language, name))
コード例 #14
0
    def print_visitor_forwards(self, fileout):
        """
        Write forward declarations of classes we want to be able to visit.

        :param fileout: object representing output file we are writing.
        """
        for element in self.elements:
            if not element['name'].endswith('Document'):
                name = SF.prefix_name(element['name'])
                fileout.write_line('class {0};'.format(name))
コード例 #15
0
ファイル: BaseBindingsFiles.py プロジェクト: hovo1990/deviser
 def print_derived_types(self, fileout):
     libname = global_variables.library_name.lower()
     for element in self.elements:
         if not element['name'].endswith('Document'):
             if not 'document' in element or not element['document']:
                 name = strFunctions.prefix_name(element['name'])
                 fileout.copy_line_verbatim('    case (int) {0}.{1}:'
                                            '\n'.format(libname,
                                                        element['typecode']))
                 fileout.copy_line_verbatim('      return new {0}(cPtr, owner)'
                                            ';\n'.format(name))
                 fileout.skip_line()
コード例 #16
0
    def print_leave_header(self, fileout):
        """
        Print the leave() header for certain classes.

        :param fileout: object representing output file we are writing.
        """
        for element in self.elements:
            if not element['name'].endswith('Document'):
                if 'document' not in element or not element['document']:
                    name = SF.prefix_name(element['name'])
                    fileout.skip_line(2)
                    self.write_leave_header(fileout, name)
コード例 #17
0
    def print_visit_code(self, fileout):
        """
        Cycle through the list of dictionaries in self.elements,
            which represent classes. Write Visitor code for those
            which .... TODO Sarah please complete this sentence

        :param fileout: object representing output file we are writing.
        """
        for element in self.elements:
            if not element['name'].endswith('Document'):
                if 'document' not in element or not element['document']:
                    name = SF.prefix_name(element['name'])
                    self.write_visit_code(fileout, name)
コード例 #18
0
    def print_visit_header(self, fileout):
        """
        Cycle over all the class dictionaries in self.elements
        Write visitor header to file represented by fileout object

        ::param fileout: object representing output file we are writing.
        """
        for element in self.elements:
            if not element['name'].endswith('Document'):
                if 'document' not in element or not element['document']:
                    name = SF.prefix_name(element['name'])
                    self.write_visit_header(fileout, name)
                    fileout.skip_line(2)
コード例 #19
0
ファイル: BaseBindingsFiles.py プロジェクト: hovo1990/deviser
 def print_derived_listof_types(self, fileout):
     for element in self.elements:
         if not element['name'].endswith('Document') and \
                 element['hasListOf']:
             name = strFunctions.lower_list_of_name_no_prefix(
                 element['name'])
             loname = strFunctions.prefix_name(
                 strFunctions.list_of_name(element['name']))
             fileout.copy_line_verbatim('      else if (name == \"{0}\")\n'
                                        ''.format(name))
             fileout.copy_line_verbatim('      {\n')
             fileout.copy_line_verbatim('         return new {0}(cPtr, '
                                        'owner);\n'.format(loname))
             fileout.copy_line_verbatim('      }\n')
コード例 #20
0
 def create_list_of_description(self):
     # default list of name
     lo_name = strFunctions.list_of_name(self.class_object['name'])
     # check that we have not specified this should be different
     if 'lo_class_name' in self.class_object and \
             len(self.class_object['lo_class_name']) > 0:
         lo_name = self.class_object['lo_class_name']
     descrip = copy.deepcopy(self.class_object)
     descrip['is_list_of'] = True
     descrip['attribs'] = self.class_object['lo_attribs']
     descrip['child_base_class'] = self.class_object['baseClass']
     if global_variables.is_package:
         descrip['baseClass'] = 'ListOf'
     else:
         descrip['baseClass'] = strFunctions.prefix_name('ListOf')
     descrip['list_of_name'] = lo_name
     descrip['lo_child'] = self.class_object['name']
     descrip['name'] = lo_name
     return descrip
コード例 #21
0
ファイル: BaseClassFiles.py プロジェクト: hovo1990/deviser
 def print_visitor_forwards(self, fileout):
     for element in self.elements:
         if not element['name'].endswith('Document'):
             name = strFunctions.prefix_name(element['name'])
             fileout.write_line('class {0};'.format(name))
コード例 #22
0
 def print_includes(self, fileout):
     for element in self.elements:
         name = strFunctions.prefix_name(element['name'])
         fileout.copy_line_verbatim('#include <{0}/{1}.h>\n'
                                    ''.format(global_variables.language,
                                              name))
コード例 #23
0
 def print_visitor_forwards(self, fileout):
     for element in self.elements:
         if not element['name'].endswith('Document'):
             name = strFunctions.prefix_name(element['name'])
             fileout.write_line('class {0};'.format(name))
コード例 #24
0
ファイル: BaseClassFiles.py プロジェクト: hovo1990/deviser
 def print_includes(self, fileout):
     for element in self.elements:
         name = strFunctions.prefix_name(element['name'])
         fileout.copy_line_verbatim('#include <{0}/{1}.h>\n'
                                    ''.format(global_variables.language,
                                              name))