gobject-introspection r746 - in trunk: giscanner tests/scanner tools
- From: walters svn gnome org
- To: svn-commits-list gnome org
- Subject: gobject-introspection r746 - in trunk: giscanner tests/scanner tools
- Date: Sat, 18 Oct 2008 00:44:14 +0000 (UTC)
Author: walters
Date: Sat Oct 18 00:44:14 2008
New Revision: 746
URL: http://svn.gnome.org/viewvc/gobject-introspection?rev=746&view=rev
Log:
Bug 556783 - namespace/prefix rework
Modified:
trunk/giscanner/glibtransformer.py
trunk/giscanner/transformer.py
trunk/tests/scanner/annotation-1.0-expected.gir
trunk/tests/scanner/drawable-1.0-expected.gir
trunk/tests/scanner/drawable-injected-1.0-expected.gir
trunk/tests/scanner/foo-1.0-expected.gir
trunk/tests/scanner/utility-1.0-expected.gir
trunk/tools/g-ir-scanner
Modified: trunk/giscanner/glibtransformer.py
==============================================================================
--- trunk/giscanner/glibtransformer.py (original)
+++ trunk/giscanner/glibtransformer.py Sat Oct 18 00:44:14 2008
@@ -171,7 +171,7 @@
# Besides the straight underscore conversion, we also try
# removing the underscores from the namespace as a possible C
# mapping; e.g. it's webkit_web_view, not web_kit_web_view
- suffix = self._transformer.strip_namespace_object(type_name)
+ suffix = self._transformer.remove_prefix(type_name)
prefix = type_name[:-len(suffix)]
no_uscore_prefixed = (prefix + '_' + to_underscores(suffix)).lower()
self._uscore_type_names[no_uscore_prefixed] = node
@@ -332,7 +332,7 @@
# pointers: GtkButton -> gtk_button_, so we can figure out the
# method name
argtype = target_arg.type.ctype.replace('*', '')
- name = self._transformer.strip_namespace_object(argtype)
+ name = self._transformer.remove_prefix(argtype)
name_uscore = to_underscores_noprefix(name).lower()
name_offset = func.symbol.find(name_uscore)
if name_offset < 0:
@@ -378,7 +378,7 @@
# The _uscore_type_names member holds the plain GLibBoxed
# object; we want to actually use the struct/record associated
if isinstance(klass, GLibBoxed):
- name = self._transformer.strip_namespace_object(klass.type_name)
+ name = self._transformer.remove_prefix(klass.type_name)
klass = self._get_attribute(name)
if not is_method:
@@ -468,14 +468,14 @@
field.writable = False
name = self._resolve_type_name(name)
- resolved = self._transformer.strip_namespace_object(name)
+ resolved = self._transformer.remove_prefix(name)
pair_class = self._get_attribute(resolved)
if pair_class and isinstance(pair_class,
(GLibObject, GLibInterface)):
for field in maybe_class.fields[1:]:
pair_class.fields.append(field)
return
- name = self._transformer.strip_namespace_object(maybe_class.name)
+ name = self._transformer.remove_prefix(maybe_class.name)
pair_class = self._get_attribute(name)
if pair_class and isinstance(pair_class,
(GLibObject, GLibInterface)):
@@ -520,7 +520,7 @@
klass = (GLibFlags if ftype_id == cgobject.TYPE_FLAGS else GLibEnum)
type_name = cgobject.type_name(type_id)
- enum_name = self._transformer.strip_namespace_object(type_name)
+ enum_name = self._transformer.remove_prefix(type_name)
node = klass(enum_name, type_name, members, symbol)
self._add_attribute(node, replace=True)
self._register_internal_type(type_name, node)
@@ -535,7 +535,7 @@
parent_type_name = cgobject.type_name(cgobject.type_parent(type_id))
parent_gitype = self._resolve_gtypename(parent_type_name)
node = GLibObject(
- self._transformer.strip_namespace_object(type_name),
+ self._transformer.remove_prefix(type_name),
parent_gitype,
type_name, symbol)
self._introspect_properties(node, type_id)
@@ -563,7 +563,7 @@
else:
parent_gitype = self._resolve_gtypename(parent_type_name)
node = GLibInterface(
- self._transformer.strip_namespace_object(type_name),
+ self._transformer.remove_prefix(type_name),
parent_gitype,
type_name, symbol)
self._introspect_properties(node, type_id)
@@ -709,7 +709,7 @@
self._resolve_function(newfunc)
def _pair_boxed_type(self, boxed):
- name = self._transformer.strip_namespace_object(boxed.type_name)
+ name = self._transformer.remove_prefix(boxed.type_name)
pair_node = self._get_attribute(name)
if not pair_node:
boxed_item = GLibBoxedOther(name, boxed.type_name,
Modified: trunk/giscanner/transformer.py
==============================================================================
--- trunk/giscanner/transformer.py (original)
+++ trunk/giscanner/transformer.py Sat Oct 18 00:44:14 2008
@@ -131,12 +131,6 @@
elif hasattr(node, 'symbol'):
self._names.ctypes[node.symbol] = (nsname, node)
- def strip_namespace_object(self, name):
- prefix = self._namespace.name.lower()
- if len(name) > len(prefix) and name.lower().startswith(prefix):
- return name[len(prefix):]
- return self._remove_prefix(name)
-
# Private
def _add_node(self, node):
@@ -155,16 +149,16 @@
prefix = to_underscores(self._namespace.name).lower() + '_'
if name.lower().startswith(prefix):
name = name[len(prefix):]
- return self._remove_prefix(name, isfunction=True)
+ return self.remove_prefix(name, isfunction=True)
- def _remove_prefix(self, name, isfunction=False):
+ def remove_prefix(self, name, isfunction=False):
# when --strip-prefix=g:
# GHashTable -> HashTable
# g_hash_table_new -> hash_table_new
prefix = self._strip_prefix.lower()
if isfunction:
prefix += '_'
- if name.lower().startswith(prefix):
+ if len(name) > len(prefix) and name.lower().startswith(prefix):
name = name[len(prefix):]
while name.startswith('_'):
@@ -207,9 +201,7 @@
child.const_int,
child.ident))
- enum_name = self.strip_namespace_object(symbol.ident)
- enum_name = symbol.ident[-len(enum_name):]
- enum_name = self._remove_prefix(enum_name)
+ enum_name = self.remove_prefix(symbol.ident)
enum = Enum(enum_name, symbol.ident, members)
self._names.type_names[symbol.ident] = (None, enum)
return enum
@@ -331,9 +323,9 @@
CTYPE_POINTER,
CTYPE_BASIC_TYPE,
CTYPE_VOID):
- name = self.strip_namespace_object(symbol.ident)
+ name = self.remove_prefix(symbol.ident)
if symbol.base_type.name:
- target = self.strip_namespace_object(symbol.base_type.name)
+ target = self.remove_prefix(symbol.base_type.name)
else:
target = 'none'
if name in type_names:
@@ -463,8 +455,7 @@
return return_
def _create_const(self, symbol):
- name = self._remove_prefix(symbol.ident)
- name = self._strip_namespace_func(name)
+ name = self.remove_prefix(symbol.ident)
if symbol.const_string is None:
type_name = 'int'
value = symbol.const_int
@@ -475,15 +466,14 @@
return const
def _create_typedef_struct(self, symbol):
- name = self.strip_namespace_object(symbol.ident)
+ name = self.remove_prefix(symbol.ident)
struct = Struct(name, symbol.ident)
self._typedefs_ns[symbol.ident] = struct
self._create_struct(symbol)
return struct
def _create_typedef_union(self, symbol):
- name = self._remove_prefix(symbol.ident)
- name = self.strip_namespace_object(name)
+ name = self.remove_prefix(symbol.ident)
union = Union(name, symbol.ident)
self._typedefs_ns[symbol.ident] = union
self._create_union(symbol)
@@ -499,7 +489,7 @@
name = symbol.ident[1:]
else:
name = symbol.ident
- name = self.strip_namespace_object(name)
+ name = self.remove_prefix(name)
struct = Struct(name, symbol.ident)
for child in symbol.base_type.child_list:
@@ -519,7 +509,7 @@
name = symbol.ident[1:]
else:
name = symbol.ident
- name = self.strip_namespace_object(name)
+ name = self.remove_prefix(name)
union = Union(name, symbol.ident)
for child in symbol.base_type.child_list:
@@ -533,9 +523,9 @@
parameters = self._create_parameters(symbol.base_type.base_type)
retval = self._create_return(symbol.base_type.base_type.base_type)
if symbol.ident.find('_') > 0:
- name = self._strip_namespace_func(symbol.ident)
+ name = self.remove_prefix(symbol.ident, True)
else:
- name = self.strip_namespace_object(symbol.ident)
+ name = self.remove_prefix(symbol.ident)
return Callback(name, retval, list(parameters), symbol.ident)
def _typepair_to_str(self, item):
@@ -555,7 +545,7 @@
return type_names[type_name]
except KeyError, e:
pass
- type_name = self.strip_namespace_object(type_name)
+ type_name = self.remove_prefix(type_name)
resolved = names.aliases.get(type_name)
if resolved:
return self._typepair_to_str(resolved)
Modified: trunk/tests/scanner/annotation-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/annotation-1.0-expected.gir (original)
+++ trunk/tests/scanner/annotation-1.0-expected.gir Sat Oct 18 00:44:14 2008
@@ -179,7 +179,7 @@
</class>
<record name="ObjectClass" c:type="AnnotationObjectClass">
<field name="parent_class">
- <type name="GObject.Class" c:type="GObjectClass"/>
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
</field>
</record>
</namespace>
Modified: trunk/tests/scanner/drawable-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/drawable-1.0-expected.gir (original)
+++ trunk/tests/scanner/drawable-1.0-expected.gir Sat Oct 18 00:44:14 2008
@@ -54,7 +54,7 @@
</class>
<record name="TestDrawableClass" c:type="TestDrawableClass">
<field name="parent_class">
- <type name="GObject.Class" c:type="GObjectClass"/>
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
</field>
</record>
<record name="TestPixmapObjectClass" c:type="_TestPixmapObjectClass">
Modified: trunk/tests/scanner/drawable-injected-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/drawable-injected-1.0-expected.gir (original)
+++ trunk/tests/scanner/drawable-injected-1.0-expected.gir Sat Oct 18 00:44:14 2008
@@ -59,7 +59,7 @@
</class>
<record name="TestDrawableClass" c:type="TestDrawableClass">
<field name="parent_class">
- <type name="GObject.Class" c:type="GObjectClass"/>
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
</field>
</record>
<record name="TestPixmapObjectClass" c:type="_TestPixmapObjectClass">
Modified: trunk/tests/scanner/foo-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/foo-1.0-expected.gir (original)
+++ trunk/tests/scanner/foo-1.0-expected.gir Sat Oct 18 00:44:14 2008
@@ -168,7 +168,7 @@
</class>
<record name="ObjectClass" c:type="FooObjectClass">
<field name="parent_class">
- <type name="GObject.Class" c:type="GObjectClass"/>
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
</field>
<callback name="virtual_method" c:type="virtual_method">
<return-value>
Modified: trunk/tests/scanner/utility-1.0-expected.gir
==============================================================================
--- trunk/tests/scanner/utility-1.0-expected.gir (original)
+++ trunk/tests/scanner/utility-1.0-expected.gir Sat Oct 18 00:44:14 2008
@@ -18,7 +18,7 @@
</class>
<record name="ObjectClass" c:type="UtilityObjectClass">
<field name="parent_class">
- <type name="GObject.Class" c:type="GObjectClass"/>
+ <type name="GObject.ObjectClass" c:type="GObjectClass"/>
</field>
</record>
<enumeration name="EnumType" c:type="UtilityEnumType">
Modified: trunk/tools/g-ir-scanner
==============================================================================
--- trunk/tools/g-ir-scanner (original)
+++ trunk/tools/g-ir-scanner Sat Oct 18 00:44:14 2008
@@ -62,13 +62,13 @@
help="directories to search for libraries")
parser.add_option("-n", "--namespace",
action="store", dest="namespace_name",
- help="name of namespace for this unit")
+ help="name of namespace for this unit, also used as --strip-prefix default")
parser.add_option("", "--nsversion",
action="store", dest="namespace_version",
help="version of namespace for this unit")
parser.add_option("", "--strip-prefix",
- action="store", dest="strip_prefix", default="",
- help="prefix to strip from functions, like g_")
+ action="store", dest="strip_prefix", default=None,
+ help="remove this prefix from objects and functions")
parser.add_option("-o", "--output",
action="store", dest="output",
help="output to writeout, defaults to stdout")
@@ -252,7 +252,10 @@
# Transform the C symbols into AST nodes
transformer = Transformer(ss, options.namespace_name, options.namespace_version)
- transformer.set_strip_prefix(options.strip_prefix)
+ if options.strip_prefix:
+ transformer.set_strip_prefix(options.strip_prefix)
+ else:
+ transformer.set_strip_prefix(options.namespace_name)
transformer.set_include_paths(options.include_paths)
shown_include_warning = False
for include in options.includes:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]