def split_classes( self ):
        class_creators = [x for x in self.extmodule.body.creators if isinstance(x, ( code_creators.class_t, code_creators.class_declaration_t ) )]

        class_creators = [cc for cc in class_creators if not cc.declaration.already_exposed]

        buckets = split_sequence(class_creators, len(class_creators)/self.number_of_buckets )
        if len(buckets) > self.number_of_buckets:
            buckets[len(buckets)-2] += buckets[len(buckets)-1]
            buckets = buckets[:len(buckets)-1]

        for index, bucket in enumerate( buckets ):
            self.split_creators( bucket
                                 , '_classes_%d' % (index+1)
                                 , 'register_classes_%d' % (index+1)
                                 , -1 )
示例#2
0
 def split_internal_calldefs(self, class_creator, calldef_types, pattern):
     creators = filter(lambda x: isinstance(x, calldef_types), class_creator.creators)
     grouped_creators = pypp_utils.split_sequence(creators, self.num_of_functions_per_file)
     if len(grouped_creators) == 1:
         for creator in creators:
             creator.works_on_instance = False
         self.split_internal_creators(class_creator, creators, pattern)
         return pattern
     else:
         patterns = []
         for index, group in enumerate(grouped_creators):
             pattern_tmp = pattern + str(index)
             patterns.append(pattern_tmp)
             for creator in group:
                 creator.works_on_instance = False
             self.split_internal_creators(class_creator, group, pattern_tmp)
         return patterns
示例#3
0
 def split_internal_calldefs( self, class_creator, calldef_types, pattern ):
     creators = filter( lambda x: isinstance(x, calldef_types ), class_creator.creators )
     grouped_creators = pypp_utils.split_sequence( creators, self.num_of_functions_per_file )
     if len( grouped_creators ) == 1:
         for creator in creators:
             creator.works_on_instance = False
         self.split_internal_creators( class_creator, creators, pattern )
         return pattern
     else:
         patterns = []
         for index, group in enumerate( grouped_creators ):
             pattern_tmp = pattern + str( index )
             patterns.append( pattern_tmp )
             for creator in group:
                 creator.works_on_instance = False
             self.split_internal_creators( class_creator, group, pattern_tmp )
         return patterns
示例#4
0
    def split_classes( self ):
        class_creators = filter( lambda x: isinstance(x, ( code_creators.class_t, code_creators.class_declaration_t ) )
                                 , self.extmodule.body.creators )

        class_creators = filter( lambda cc: not cc.declaration.already_exposed
                                 , class_creators )

        buckets = split_sequence(class_creators, len(class_creators)/self.number_of_buckets )
        if len(buckets) > self.number_of_buckets:
            buckets[len(buckets)-2] += buckets[len(buckets)-1]
            buckets = buckets[:len(buckets)-1]

        for index, bucket in enumerate( buckets ):
            self.split_creators( bucket
                                 , '_classes_%d' % (index+1)
                                 , 'register_classes_%d' % (index+1)
                                 , -1 )
示例#5
0
    def split_classes(self):
        class_creators = filter(
            lambda x: isinstance(x, (code_creators.class_t, code_creators.
                                     class_declaration_t)),
            self.extmodule.body.creators)

        class_creators = filter(lambda cc: not cc.declaration.already_exposed,
                                class_creators)

        buckets = split_sequence(class_creators,
                                 len(class_creators) / self.number_of_buckets)
        if len(buckets) > self.number_of_buckets:
            buckets[len(buckets) - 2] += buckets[len(buckets) - 1]
            buckets = buckets[:len(buckets) - 1]

        for index, bucket in enumerate(buckets):
            self.split_creators(bucket, '_classes_%d' % (index + 1),
                                'register_classes_%d' % (index + 1), -1)
示例#6
0
    def split_classes(self):
        class_creators = [
            x for x in self.extmodule.body.creators
            if isinstance(x, (code_creators.class_t,
                              code_creators.class_declaration_t))
        ]

        class_creators = [
            cc for cc in class_creators if not cc.declaration.already_exposed
        ]

        buckets = split_sequence(class_creators,
                                 len(class_creators) / self.number_of_buckets)
        if len(buckets) > self.number_of_buckets:
            buckets[len(buckets) - 2] += buckets[len(buckets) - 1]
            buckets = buckets[:len(buckets) - 1]

        for index, bucket in enumerate(buckets):
            self.split_creators(bucket, '_classes_%d' % (index + 1),
                                'register_classes_%d' % (index + 1), -1)
示例#7
0
    def split_classes(self):
        class_creators = filter(
            lambda x: isinstance(x, (code_creators.class_t, code_creators.class_declaration_t)),
            self.extmodule.body.creators,
        )

        class_creators = filter(lambda cc: not cc.declaration.already_exposed, class_creators)

        if len(class_creators) > self.number_of_buckets:
            numBuckets = len(class_creators) / self.number_of_buckets
        else:
            numBuckets = 1
        buckets = split_sequence(class_creators, numBuckets)
        for outBuckets in range(self.number_of_buckets, len(buckets)):
            buckets[self.number_of_buckets - 1] += buckets[outBuckets]
        buckets = buckets[: self.number_of_buckets]

        for index, bucket in enumerate(buckets):
            self.split_creators(
                bucket,
                "_classes_%d" % (index + 1)
                # ,'_register_classes_%d' % (index+1)
                ,
                self.extmodule.body.name + "_register_classes_%d" % (index + 1),
                -1,
            )

        # If I have specified more classes than what actually exists, I have to
        # create dummy files
        if self.number_of_buckets > len(buckets):
            for i in range(len(buckets), self.number_of_buckets + 1):
                emptyFileHandle = open(
                    os.path.join(self.directory_path, self.extmodule.body.name + "_classes_" + str(i) + ".pypp.cpp"),
                    "w",
                )
                emptyFileHandle.close()