from .glibast import (GLibBoxed, GLibEnum, GLibEnumMember, GLibFlags,
GLibInterface, GLibObject, GLibSignal, GLibBoxedStruct,
GLibBoxedUnion, GLibBoxedOther, type_names)
-from .utils import extract_libtool, to_underscores
+from .utils import extract_libtool, to_underscores, to_underscores_noprefix
SYMBOL_BLACKLIST = [
def _register_internal_type(self, type_name, node):
self._names.type_names[type_name] = (None, node)
- self._uscore_type_names[to_underscores(type_name).lower()] = node
+ uscored = to_underscores(type_name).lower()
+ self._uscore_type_names[uscored] = node
# 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
prefix = type_name[:-len(suffix)]
no_uscore_prefixed = (prefix + '_' + to_underscores(suffix)).lower()
self._uscore_type_names[no_uscore_prefixed] = node
+ print "ADDING USCORED: %r %r" % (uscored, no_uscore_prefixed)
# Helper functions
# method name
argtype = target_arg.type.ctype.replace('*', '')
name = self._transformer.strip_namespace_object(argtype)
- name_uscore = to_underscores(name).lower()
+ name_uscore = to_underscores_noprefix(name).lower()
name_offset = func.symbol.find(name_uscore)
if name_offset < 0:
return None
return name
+def to_underscores_noprefix(name):
+ """Like to_underscores, but designed for "unprefixed" names.
+ to_underscores("DBusFoo") => dbus_foo, not d_bus_foo."""
+ name = _upperstr_pat1.sub(r'\1_\2', name)
+ name = _upperstr_pat2.sub(r'\1_\2', name)
+ return name
+
_libtool_pat = re.compile("dlname='([A-z0-9\.\-\+]+)'\n")
<type name="Boxed" c:type="FooBoxed*"/>
</return-value>
</function>
+ <record name="DBusData"
+ c:type="FooDBusData"
+ glib:type-name="FooDBusData"
+ glib:get-type="foo_dbus_data_get_type">
+ <method name="method" c:identifier="foo_dbus_data_method">
+ <return-value>
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="dbusdata">
+ <type name="DBusData" c:type="FooDBusData*"/>
+ </parameter>
+ </parameters>
+ </method>
+ </record>
<callback name="Callback" c:type="FooCallback">
<return-value>
<type name="boolean" c:type="gboolean"/>
{
}
+
+struct _FooDBusData
+{
+ double private;
+};
+
+FooDBusData *
+foo_dbus_data_copy (const FooDBusData *boxed)
+{
+ return (FooDBusData *)g_memdup (boxed, sizeof (FooDBusData));
+}
+
+void
+foo_dbus_data_free (FooBoxed *boxed)
+{
+ g_slice_free (FooDBusData, boxed);
+}
+
+
+GType
+foo_dbus_data_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("FooDBusData",
+ (GBoxedCopyFunc) foo_dbus_data_copy,
+ (GBoxedFreeFunc) foo_dbus_data_free);
+ return our_type;
+}
FooBoxed* foo_boxed_new (void);
void foo_boxed_method (FooBoxed* boxed);
+/* This one tests capitalization handling with respect to DBus */
+typedef struct _FooDBusData FooDBusData;
+GType foo_dbus_data_get_type (void) G_GNUC_CONST;
+void foo_dbus_data_method (FooDBusData* dbusdata);
+
/* FIXME: Scanner does not support this yet
const char *FOO_CONSTANT_STR = "foo-constant-str";
const int FOO_CONSTANT_INT = 10;