Exemplo n.º 1
0
def generate_set_object_pointer(new_callback_class):
    set_object_pointer_method = TMethod()
    set_object_pointer_method.name = 'SetObjectPointer'
    set_object_pointer_method.arguments.append(TArgument())
    set_object_pointer_method.arguments[0].is_builtin = True
    set_object_pointer_method.arguments[0].type_name = 'void*'
    set_object_pointer_method.arguments[0].name = 'custom_object'
    set_object_pointer_method.noexcept = True
    set_object_pointer_method.noexcept_filled = True
    new_callback_class.methods.append(set_object_pointer_method)
Exemplo n.º 2
0
def generate_set_c_function_for_add_ref(class_generator, new_callback_class):
    set_add_ref_c_function = TMethod()
    set_add_ref_c_function.name = 'SetCFunctionForAddRef'
    set_add_ref_c_function.arguments.append(TArgument())
    set_add_ref_c_function.arguments[0].is_builtin = True
    set_add_ref_c_function.arguments[
        0].type_name = class_generator.add_ref_callback_type
    set_add_ref_c_function.arguments[0].name = 'c_function_pointer'
    set_add_ref_c_function.noexcept = True
    set_add_ref_c_function.noexcept_filled = True
    new_callback_class.methods.append(set_add_ref_c_function)
Exemplo n.º 3
0
def generate_callback_for_method(cur_method_generator, new_callback_class):
    set_c_function_method = TMethod()
    set_c_function_method.name = 'SetCFunctionFor{0}'.format(
        cur_method_generator.name)
    set_c_function_method.arguments.append(TArgument())
    set_c_function_method.arguments[0].is_builtin = True
    set_c_function_method.arguments[
        0].type_name = cur_method_generator.callback_type
    set_c_function_method.arguments[0].name = 'c_function_pointer'
    set_c_function_method.noexcept = True
    set_c_function_method.noexcept_filled = True
    new_callback_class.methods.append(set_c_function_method)
Exemplo n.º 4
0
def generate_get_object_pointer(new_callback_class):
    get_object_pointer_method = TMethod()
    get_object_pointer_method.name = 'GetObjectPointer'
    get_object_pointer_method.return_is_builtin = True
    get_object_pointer_method.return_type = 'void*'
    get_object_pointer_method.noexcept = True
    get_object_pointer_method.noexcept_filled = True
    get_object_pointer_method.const = True
    new_callback_class.methods.append(get_object_pointer_method)
Exemplo n.º 5
0
def instantiate_method(method: TMethod, instantiation: TInstantiation):
    instantiate_constructor(method, instantiation)
    method.return_type = instantiate_type(method.return_type, instantiation)
Exemplo n.º 6
0
    def process_class(self, cur_class: TClass):
        top = self.properties_stack.pop()

        for cur_property in cur_class.properties:
            cur_set_prefix = cur_property.set_prefix if cur_property.set_prefix_filled else top.set_prefix_value
            cur_get_prefix = cur_property.get_prefix if cur_property.get_prefix_filled else top.get_prefix_value
            cur_get_const = cur_property.get_const if cur_property.get_const_filled else top.get_const_value
            cur_argument_name = cur_property.set_argument_name if cur_property.set_argument_name \
                else get_c_name(cur_property.name)
            new_get_method = TMethod()
            new_get_method.name = cur_get_prefix + cur_property.name
            new_get_method.const = cur_get_const
            new_get_method.return_type = cur_property.return_type if cur_property.return_type_filled \
                else cur_property.type_name
            new_get_method.documentations = copy.deepcopy(
                cur_property.documentations)
            new_get_method.impl_2_c = cur_property.get_impl_2_c
            new_get_method.impl_2_c_filled = cur_property.get_impl_2_c_filled
            new_get_method.return_is_builtin = cur_property.is_builtin
            new_get_method.return_is_builtin_filled = cur_property.is_builtin_filled
            new_get_method.return_copy_or_add_ref = cur_property.return_copy_or_add_ref
            new_get_method.return_copy_or_add_ref_filled = True
            if cur_property.field_name_filled:
                new_get_method.getter_field_name = cur_property.field_name
                new_get_method.getter_field_name_filled = True
            PropertiesProcessor.__process_documentations(new_get_method, True)
            cur_class.methods.append(new_get_method)
            new_set_method = TMethod()
            new_set_method.name = cur_set_prefix + cur_property.name
            set_input_argument = TArgument()
            set_input_argument.name = cur_argument_name
            set_input_argument.type_name = cur_property.set_argument_type if cur_property.set_argument_type_filled \
                else cur_property.type_name
            set_input_argument.c_2_impl = cur_property.set_c_2_impl
            set_input_argument.c_2_impl_filled = cur_property.set_c_2_impl_filled
            set_input_argument.c_2_impl_mode = cur_property.set_c_2_impl_mode
            set_input_argument.c_2_impl_mode_filled = cur_property.set_c_2_impl_mode_filled
            set_input_argument.is_builtin = cur_property.is_builtin
            set_input_argument.is_builtin_filled = cur_property.is_builtin_filled
            new_set_method.arguments.append(set_input_argument)
            if cur_property.field_name_filled:
                new_set_method.setter_field_name = cur_property.field_name
                new_set_method.setter_field_name_filled = True
            new_set_method.documentations = copy.deepcopy(
                cur_property.documentations)
            PropertiesProcessor.__process_documentations(new_set_method, False)
            cur_class.methods.append(new_set_method)

            if self.unittest_generator:
                self.unittest_generator.add_property(cur_class, cur_property,
                                                     new_set_method,
                                                     new_get_method)
        self.properties_stack.append(top)