Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __create_alias_symbol(self, node, gi_name, parent_name):
name = get_symbol_names(node)[0]
type_desc = type_description_from_node(node)
aliased_type = QualifiedSymbol(type_tokens=type_desc.type_tokens)
self.add_attrs(aliased_type, type_desc=type_desc)
filename = self.__get_symbol_filename(name, node)
alias_link = [l for l in type_desc.type_tokens if isinstance(l, Link)]
for lang in self.languages:
fund_type = lang.get_fundamental(type_desc.c_name)
if fund_type:
# The alias name is now considered as a FUNDAMENTAL type.
lang.add_fundamental (name, fund_type)
else:
if alias_link:
lang.add_alias_link (name, alias_link[0])
return self.create_symbol(AliasSymbol, node,
aliased_type=aliased_type,
display_name=name,
filename=filename,
parent_name=parent_name)
Link('https://docs.python.org/2.7/library/functions.html#bool',
'bool', None)
true_link = \
Link('https://docs.python.org/2/library/constants.html#True',
'True', None)
false_link = \
Link('https://docs.python.org/2/library/constants.html#False',
'False', None)
pointer_link = \
Link('https://docs.python.org/2.7/library/functions.html#object',
'object', None)
integer_link = \
Link('https://docs.python.org/2/library/functions.html#int',
'int', None)
float_link = \
Link('https://docs.python.org/2/library/functions.html#float',
'float', None)
none_link = \
Link('https://docs.python.org/2/library/constants.html#None',
'None', None)
unicode_link = \
Link('https://docs.python.org/2/library/functions.html#unicode',
'unicode', None)
gtype_link = \
Link('https://developer.gnome.org/gobject/stable/'
'gobject-Type-Information.html#GType',
'GObject.Type', None)
gvariant_link = \
Link('https://developer.gnome.org/glib/stable/glib-GVariant.html',
'GLib.Variant', None)
Link('https://docs.python.org/3/library/constants.html#False',
'False', None)
pointer_link = \
Link('https://docs.python.org/3/library/functions.html#object',
'object', None)
integer_link = \
Link('https://docs.python.org/3/library/functions.html#int',
'int', None)
float_link = \
Link('https://docs.python.org/3/library/functions.html#float',
'float', None)
none_link = \
Link('https://docs.python.org/3/library/constants.html#None',
'None', None)
list_link = \
Link('https://docs.python.org/3/library/functions.html#func-list',
'list', None)
gtype_link = \
Link('https://developer.gnome.org/gobject/stable/'
'gobject-Type-Information.html#GType',
'GObject.Type', None)
gvariant_link = \
Link('https://developer.gnome.org/glib/stable/glib-GVariant.html',
'GLib.Variant', None)
FUNDAMENTALS[cls.language_name] = {
"none": none_link,
"gpointer": pointer_link,
"gconstpointer": pointer_link,
"gboolean": boolean_link,
"gint8": integer_link,
def make_c_style_type_name (self, type_):
tokens = []
while (type_.kind == cindex.TypeKind.POINTER):
self.__apply_qualifiers(type_, tokens)
tokens.append ('*')
type_ = type_.get_pointee()
if type_.kind == cindex.TypeKind.TYPEDEF:
d = type_.get_declaration ()
link = Link (None, d.displayname, d.displayname)
tokens.append (link)
self.__apply_qualifiers(type_, tokens)
elif type_.kind in (cindex.TypeKind.UNEXPOSED, cindex.TypeKind.ELABORATED):
d = type_.get_declaration()
if d.spelling:
tokens.append(Link(None, d.displayname, d.displayname))
else:
tokens.append('__UNKNOWN__')
if d.kind == cindex.CursorKind.STRUCT_DECL:
tokens.append ('struct ')
elif d.kind == cindex.CursorKind.ENUM_DECL:
tokens.append ('enum ')
else:
tokens.append (type_.spelling + ' ')
tokens = []
while (type_.kind == cindex.TypeKind.POINTER):
self.__apply_qualifiers(type_, tokens)
tokens.append ('*')
type_ = type_.get_pointee()
if type_.kind == cindex.TypeKind.TYPEDEF:
d = type_.get_declaration ()
link = Link (None, d.displayname, d.displayname)
tokens.append (link)
self.__apply_qualifiers(type_, tokens)
elif type_.kind in (cindex.TypeKind.UNEXPOSED, cindex.TypeKind.ELABORATED):
d = type_.get_declaration()
if d.spelling:
tokens.append(Link(None, d.displayname, d.displayname))
else:
tokens.append('__UNKNOWN__')
if d.kind == cindex.CursorKind.STRUCT_DECL:
tokens.append ('struct ')
elif d.kind == cindex.CursorKind.ENUM_DECL:
tokens.append ('enum ')
else:
tokens.append (type_.spelling + ' ')
tokens.reverse()
return tokens
for idx in destroy_indices:
param = parameters[idx]
self.add_attrs(param, is_destroy=True)
for idx in closure_indices:
param = parameters[idx]
self.add_attrs(param, is_closure=True)
# We add our instance parameter last in order not to mess with
# the destroy indices
if instance_param is not None:
param, direction = self.__create_parameter_symbol(instance_param)
parameters.insert(0, param)
if node.attrib.get('throws') == '1':
type_desc = SymbolTypeDesc([Link(None, 'GError', 'GError'), '*', '*'], 'GLib.Error', 'GError**', 0)
param = ParameterSymbol(argname='error', type_tokens=type_desc.type_tokens)
parameters.append(param)
self.add_attrs(param, type_desc=type_desc, direction='out')
retval = node.find(
'{http://www.gtk.org/introspection/core/1.0}return-value')
retval = self.__create_return_value_symbol(retval, out_parameters)
return (parameters, retval)
def type_tokens_from_type_name(type_name, python_lang):
res = [Link(None, type_name, type_name, mandatory=True)]
if python_lang and not python_lang.get_fundamental(type_name):
res.append('<span class="pointer-token">*</span>')
return res
Link('https://docs.python.org/2/library/functions.html#float',
'float', None)
none_link = \
Link('https://docs.python.org/2/library/constants.html#None',
'None', None)
unicode_link = \
Link('https://docs.python.org/2/library/functions.html#unicode',
'unicode', None)
gtype_link = \
Link('https://developer.gnome.org/gobject/stable/'
'gobject-Type-Information.html#GType',
'GObject.Type', None)
gvariant_link = \
Link('https://developer.gnome.org/glib/stable/glib-GVariant.html',
'GLib.Variant', None)
fundamentals = {
"none": none_link,
"gpointer": pointer_link,
"gconstpointer": pointer_link,
"gboolean": boolean_link,
"gint8": integer_link,
"guint8": integer_link,
"gint16": integer_link,
"guint16": integer_link,
"gint32": integer_link,
"guint32": integer_link,
"gchar": integer_link,
"guchar": integer_link,
"gshort": integer_link,
Link('https://developer.mozilla.org/en-US/docs/Web/'
'JavaScript/Reference/Global_Objects/Object', 'Object',
None)
true_link = \
Link('https://developer.mozilla.org/en-US/docs/Web/'
'JavaScript/Reference/Global_Objects/Boolean',
'true', None)
false_link = \
Link('https://developer.mozilla.org/en-US/docs/Web/'
'JavaScript/Reference/Global_Objects/Boolean',
'false', None)
number_link = \
Link('https://developer.mozilla.org/en-US/docs/Glossary/Number',
'Number', None)
null_link = \
Link('https://developer.mozilla.org/en-US/docs/Web/'
'JavaScript/Reference/Global_Objects/null',
'null', None)
gtype_link = \
Link('https://developer.gnome.org/gobject/stable/'
'gobject-Type-Information.html#GType',
'GObject.Type', None)
FUNDAMENTALS[cls.language_name] = {
'gchararray': string_link,
'gunichar': string_link,
'utf8': string_link,
'gchar': string_link,
'guchar': number_link,
'gint8': number_link,
'guint8': number_link,
'gint16': number_link,
def _inject_fundamentals():
# Working around https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/744
CLanguage.add_fundamental("JackClient", Link("https://jackaudio.org/api/jack_8h.html",
'jack_client_t', None))
CLanguage.add_fundamental(
"GrapheneMatrix",
Link("https://developer.gnome.org/graphene/stable/graphene-Matrix.html#graphene-matrix-t",
'graphen_matrix_t', 'GrapheneMatrix'))
CLanguage.add_fundamental(
"CairoContext",
Link("https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-t",
'cairo_t', 'CairoContext'))