How to use the pygccxml.declarations.templates.args function in pygccxml

To help you get started, we’ve selected a few pygccxml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Gabrielcarvfer / NS3 / 3rd-party / pybindgen / pybindgen / gccxmlparser.py View on Github external
parameter_annotations.get('return', {}))
                argument_specs = []
                for arg in member.arguments:
                    argument_specs.append(self.type_registry.lookup_parameter(arg.type, arg.name,
                                                                              parameter_annotations.get(arg.name, {}),
                                                                              arg.default_value))



                if pure_virtual and not class_wrapper.allow_subclassing:
                    class_wrapper.set_cannot_be_constructed("pure virtual method and subclassing disabled")
                    #self.pygen_sink.writeln('cls.set_cannot_be_constructed("pure virtual method not wrapped")')

                custom_template_method_name = None
                if templates.is_instantiation(member.demangled_name):
                    template_parameters = templates.args(member.demangled_name)
                    template_instance_names = global_annotations.get('template_instance_names', '')
                    if template_instance_names:
                        for mapping in template_instance_names.split('|'):
                            type_names, name = mapping.split('=>')
                            instance_types = type_names.split(',')
                            if instance_types == template_parameters:
                                custom_template_method_name = name
                                break
                else:
                    template_parameters = ()

                if member.has_const:
                    kwargs['is_const'] = True
                if member.has_static:
                    kwargs['is_static'] = True
                if is_virtual:
github gjcarneiro / pybindgen / pybindgen / gccxmlparser.py View on Github external
parameter_annotations.get('return', {}))
                argument_specs = []
                for arg in member.arguments:
                    argument_specs.append(self.type_registry.lookup_parameter(arg.type, arg.name,
                                                                              parameter_annotations.get(arg.name, {}),
                                                                              arg.default_value))



                if pure_virtual and not class_wrapper.allow_subclassing:
                    class_wrapper.set_cannot_be_constructed("pure virtual method and subclassing disabled")
                    #self.pygen_sink.writeln('cls.set_cannot_be_constructed("pure virtual method not wrapped")')

                custom_template_method_name = None
                if templates.is_instantiation(member.demangled_name):
                    template_parameters = templates.args(member.demangled_name)
                    template_instance_names = global_annotations.get('template_instance_names', '')
                    if template_instance_names:
                        for mapping in template_instance_names.split('|'):
                            type_names, name = mapping.split('=>')
                            instance_types = type_names.split(',')
                            if instance_types == template_parameters:
                                custom_template_method_name = name
                                break
                else:
                    template_parameters = ()

                if member.has_const:
                    kwargs['is_const'] = True
                if member.has_static:
                    kwargs['is_static'] = True
                if is_virtual:
github Gabrielcarvfer / NS3 / 3rd-party / pybindgen / pybindgen / gccxmlparser.py View on Github external
pygen_sink = self._get_pygen_sink_for_definition(fun)
                if pygen_sink:
                    if 'pygen_comment' in global_annotations:
                        pygen_sink.writeln('## ' + global_annotations['pygen_comment'])
                    pygen_sink.writeln("root_module[%r].add_function_as_constructor(%s)" %
                                       (cpp_class.full_name,
                                        ", ".join([repr(fun.name), retval_repr, arglist_repr]),))

                if params_ok:
                    function_wrapper = cpp_class.add_function_as_constructor(fun.name, return_type, arguments)
                    function_wrapper.gccxml_definition = fun

                continue

            if templates.is_instantiation(fun.demangled_name):
                template_parameters = templates.args(fun.demangled_name)
                kwargs['template_parameters'] = template_parameters
                template_instance_names = global_annotations.get('template_instance_names', '')
                if template_instance_names:
                    for mapping in template_instance_names.split('|'):
                        type_names, name = mapping.split('=>')
                        instance_types = type_names.split(',')
                        if instance_types == template_parameters:
                            kwargs['custom_name'] = name
                            break

            if alt_name:
                kwargs['custom_name'] = alt_name

            if fun.attributes:
                if 'deprecated' in fun.attributes:
                    kwargs['deprecated'] = True
github Gabrielcarvfer / NS3 / bindings / python / ns3modulescan-modular.py View on Github external
## cause needless changes, since the generated python files are
        ## kept under version control.

        #global_annotations['pygen_comment'] = "%s:%i: %s" % \
        #    (ns3_header, pygccxml_definition.location.line, pygccxml_definition)
        global_annotations['pygen_comment'] = "%s (module %r): %s" % \
            (ns3_header, definition_module, pygccxml_definition)


        ## handle ns3::Object::GetObject (left to its own devices,
        ## pybindgen will generate a mangled name containing the template
        ## argument type name).
        if isinstance(pygccxml_definition, member_function_t) \
                and pygccxml_definition.parent.name == 'Object' \
                and pygccxml_definition.name == 'GetObject':
            template_args = templates.args(str(pygccxml_definition))
            if template_args == ['ns3::Object']:
                global_annotations['template_instance_names'] = 'ns3::Object=>GetObject'

        ## Don't wrap Simulator::Schedule* (manually wrapped)
        if isinstance(pygccxml_definition, member_function_t) \
                and pygccxml_definition.parent.name == 'Simulator' \
                and pygccxml_definition.name.startswith('Schedule'):
            global_annotations['ignore'] = None

        # manually wrapped
        if isinstance(pygccxml_definition, member_function_t) \
                and pygccxml_definition.parent.name == 'Simulator' \
                and pygccxml_definition.name == 'Run':
            global_annotations['ignore'] = True

        ## http://www.gccxml.org/Bug/view.php?id=9915
github tkn-tub / ns3-gym / bindings / python / ns3modulescan.py View on Github external
## cause needless changes, since the generated python files are
    ## kept under version control.

    #global_annotations['pygen_comment'] = "%s:%i: %s" % \
    #    (ns3_header, pygccxml_definition.location.line, pygccxml_definition)
    global_annotations['pygen_comment'] = "%s: %s" % \
        (ns3_header, pygccxml_definition)


    ## handle ns3::Object::GetObject (left to its own devices,
    ## pybindgen will generate a mangled name containing the template
    ## argument type name).
    if isinstance(pygccxml_definition, member_function_t) \
            and pygccxml_definition.parent.name == 'Object' \
            and pygccxml_definition.name == 'GetObject':
        template_args = templates.args(pygccxml_definition.demangled_name)
        if template_args == ['ns3::Object']:
            global_annotations['template_instance_names'] = 'ns3::Object=>GetObject'

    ## Don't wrap Simulator::Schedule* (manually wrapped)
    if isinstance(pygccxml_definition, member_function_t) \
            and pygccxml_definition.parent.name == 'Simulator' \
            and pygccxml_definition.name.startswith('Schedule'):
        global_annotations['ignore'] = None

    # manually wrapped
    if isinstance(pygccxml_definition, member_function_t) \
            and pygccxml_definition.parent.name == 'Simulator' \
            and pygccxml_definition.name == 'Run':
        global_annotations['ignore'] = True

    ## http://www.gccxml.org/Bug/view.php?id=9915
github gjcarneiro / pybindgen / pybindgen / castxmlparser.py View on Github external
kwargs['outer_class'] = outer_class
            outer_class_key = outer_class.partial_decl_string
        else:
            outer_class_key = None

        container_register_key = (outer_class_key, name)
        if container_register_key in self._containers_registered:
            return
        self._containers_registered[container_register_key] = None
        element_type = None
        #print >> sys.stderr, "************* register_container", name
        #print ("*********************", templates.args(traits.class_declaration(definition).name))
        try:
          element_type = traits.element_type(definition)
        except RuntimeError:
          value_type_str = templates.args(traits.class_declaration(definition).name)[traits.element_type_index]
          try:
            has_space_pointer = value_type_str.endswith(' *')
            if has_space_pointer:
              value_type_str = value_type_str[:-2]
              element_type = find_declaration_from_name (traits.class_declaration(definition).top_parent, value_type_str)
              if isinstance(element_type, class_declaration.class_types):
                element_type = cpptypes.declarated_t(element_type)
              element_type = cpptypes.pointer_t(element_type)
            if None is element_type:
              raise RuntimeError(
                        "Unable to find out %s '%s' key\\value type." %
                        (traits.name(), traits.class_declaration(definition).decl_string))
          except RuntimeError:
            if value_type_str == "unsigned short":
              element_type = find_declaration_from_name (traits.class_declaration(definition).top_parent, "short unsigned int")
            else:
github Gabrielcarvfer / NS3 / bindings / python / ns3modulescan.py View on Github external
## cause needless changes, since the generated python files are
    ## kept under version control.

    #global_annotations['pygen_comment'] = "%s:%i: %s" % \
    #    (ns3_header, pygccxml_definition.location.line, pygccxml_definition)
    global_annotations['pygen_comment'] = "%s: %s" % \
        (ns3_header, pygccxml_definition)


    ## handle ns3::Object::GetObject (left to its own devices,
    ## pybindgen will generate a mangled name containing the template
    ## argument type name).
    if isinstance(pygccxml_definition, member_function_t) \
            and pygccxml_definition.parent.name == 'Object' \
            and pygccxml_definition.name == 'GetObject':
        template_args = templates.args(pygccxml_definition.demangled_name)
        if template_args == ['ns3::Object']:
            global_annotations['template_instance_names'] = 'ns3::Object=>GetObject'

    ## Don't wrap Simulator::Schedule* (manually wrapped)
    if isinstance(pygccxml_definition, member_function_t) \
            and pygccxml_definition.parent.name == 'Simulator' \
            and pygccxml_definition.name.startswith('Schedule'):
        global_annotations['ignore'] = None

    # manually wrapped
    if isinstance(pygccxml_definition, member_function_t) \
            and pygccxml_definition.parent.name == 'Simulator' \
            and pygccxml_definition.name == 'Run':
        global_annotations['ignore'] = True

    ## http://www.gccxml.org/Bug/view.php?id=9915
github InsightSoftwareConsortium / ITK / Wrapping / Generators / SwigInterface / igenerator.py View on Github external
def removeStdAllocator(s):
        if pygccxml.declarations.templates.is_instantiation(s):
            args = []
            for arg in pygccxml.declarations.templates.args(s):
                if not arg.startswith("std::allocator"):
                    t, d = SwigInputGenerator.typeAndDecorators(arg)
                    args.append(SwigInputGenerator.removeStdAllocator(t) + d)
            return pygccxml.declarations.templates.join(
                pygccxml.declarations.templates.name(s),
                args) + SwigInputGenerator.typeAndDecorators(s)[1]
        return s