perl-Glib r1038 - trunk
- From: tsch svn gnome org
- To: svn-commits-list gnome org
- Subject: perl-Glib r1038 - trunk
- Date: Sun, 2 Nov 2008 11:35:17 +0000 (UTC)
Author: tsch
Date: Sun Nov 2 11:35:17 2008
New Revision: 1038
URL: http://svn.gnome.org/viewvc/perl-Glib?rev=1038&view=rev
Log:
Provide gperl_register_boxed_alias, gperl_register_fundamental_alias, and
gperl_register_object_alias to register aliases for other registered types. An
alias is a package name that will resolve to the specified type, while the type
will still resolve to its originally registered package when going the other
way.
Modified:
trunk/ChangeLog
trunk/GBoxed.xs
trunk/GObject.xs
trunk/GType.xs
trunk/Glib.exports
trunk/gperl.h
Modified: trunk/GBoxed.xs
==============================================================================
--- trunk/GBoxed.xs (original)
+++ trunk/GBoxed.xs Sun Nov 2 11:35:17 2008
@@ -209,6 +209,44 @@
G_UNLOCK (info_by_package);
}
+=item void gperl_register_boxed_alias (GType gtype, const char * package)
+
+Makes I<package> an alias for I<type>. This means that the package name
+specified by I<package> will be mapped to I<type> by
+I<gperl_boxed_type_from_package>, but I<gperl_boxed_package_from_type> won't
+map I<type> to I<package>. This is useful if you want to change the canonical
+package name of a type while preserving backwards compatibility with code which
+uses I<package> to specify I<type>.
+
+In order for this to make sense, another package name should be registered for
+I<type> with I<gperl_register_boxed>.
+
+=cut
+
+void
+gperl_register_boxed_alias (GType gtype,
+ const char * package)
+{
+ BoxedInfo * boxed_info;
+
+ G_LOCK (info_by_gtype);
+ boxed_info = (BoxedInfo *)
+ g_hash_table_lookup (info_by_gtype, (gpointer) gtype);
+ G_UNLOCK (info_by_gtype);
+
+ if (!boxed_info) {
+ croak ("cannot register alias %s for the unregistered type %s",
+ package, g_type_name (gtype));
+ }
+
+ G_LOCK (info_by_package);
+ /* associate package with the same boxed_info. boxed_info is still
+ owned by info_by_gtype. info_by_package doesn't have a
+ free-function installed, so that's ok. */
+ g_hash_table_insert (info_by_package, (char *) package, boxed_info);
+ G_UNLOCK (info_by_package);
+}
+
=item GType gperl_boxed_type_from_package (const char * package)
Look up the GType associated with package I<package>. Returns 0 if I<type> is
Modified: trunk/GObject.xs
==============================================================================
--- trunk/GObject.xs (original)
+++ trunk/GObject.xs Sun Nov 2 11:35:17 2008
@@ -359,6 +359,44 @@
class_info_finish_loading (class_info);
}
+=item void gperl_register_object_alias (GType gtype, const char * package)
+
+Makes I<package> an alias for I<type>. This means that the package name
+specified by I<package> will be mapped to I<type> by
+I<gperl_object_type_from_package>, but I<gperl_object_package_from_type> won't
+map I<type> to I<package>. This is useful if you want to change the canonical
+package name of a type while preserving backwards compatibility with code which
+uses I<package> to specify I<type>.
+
+In order for this to make sense, another package name should be registered for
+I<type> with I<gperl_register_object>.
+
+=cut
+
+void
+gperl_register_object_alias (GType gtype,
+ const char * package)
+{
+ ClassInfo *class_info;
+
+ G_LOCK (types_by_type);
+ class_info = (ClassInfo *)
+ g_hash_table_lookup (types_by_type, (gpointer) gtype);
+ G_UNLOCK (types_by_type);
+
+ if (!class_info) {
+ croak ("cannot register alias %s for the unregistered type %s",
+ package, g_type_name (gtype));
+ }
+
+ G_LOCK (types_by_package);
+ /* associate package with the same class_info. class_info is still
+ owned by types_by_type. types_by_package doesn't have a
+ free-function installed, so that's ok. */
+ g_hash_table_insert (types_by_package, (char *) package, class_info);
+ G_UNLOCK (types_by_package);
+}
+
=item void gperl_register_sink_func (GType gtype, GPerlObjectSinkFunc func)
Modified: trunk/GType.xs
==============================================================================
--- trunk/GType.xs (original)
+++ trunk/GType.xs Sun Nov 2 11:35:17 2008
@@ -104,6 +104,45 @@
gperl_set_isa (package, "Glib::Flags");
}
+=item void gperl_register_fundamental_alias (GType gtype, const char * package)
+
+Makes I<package> an alias for I<type>. This means that the package name
+specified by I<package> will be mapped to I<type> by
+I<gperl_fundamental_type_from_package>, but
+I<gperl_fundamental_package_from_type> won't map I<type> to I<package>. This
+is useful if you want to change the canonical package name of a type while
+preserving backwards compatibility with code which uses I<package> to specify
+I<type>.
+
+In order for this to make sense, another package name should be registered for
+I<type> with I<gperl_register_fundamental> or
+I<gperl_register_fundamental_full>.
+
+=cut
+
+void
+gperl_register_fundamental_alias (GType gtype,
+ const char * package)
+{
+ const char * res;
+
+ G_LOCK (packages_by_type);
+ res = (const char *)
+ g_hash_table_lookup (packages_by_type, (gpointer) gtype);
+ G_UNLOCK (packages_by_type);
+
+ if (!res) {
+ croak ("cannot register alias %s for the unregistered type %s",
+ package, g_type_name (gtype));
+ }
+
+ G_LOCK (types_by_package);
+ g_hash_table_insert (types_by_package,
+ (char *) package,
+ (gpointer) gtype);
+ G_UNLOCK (types_by_package);
+}
+
=item GPerlValueWrapperClass
Specifies the vtable that is to be used to convert fundamental types to and
Modified: trunk/Glib.exports
==============================================================================
--- trunk/Glib.exports (original)
+++ trunk/Glib.exports Sun Nov 2 11:35:17 2008
@@ -66,9 +66,12 @@
gperl_param_spec_package_from_type
gperl_prepend_isa
gperl_register_boxed
+gperl_register_boxed_alias
gperl_register_error_domain
gperl_register_fundamental
+gperl_register_fundamental_alias
gperl_register_object
+gperl_register_object_alias
gperl_register_sink_func
gperl_remove_exception_handler
gperl_run_exception_handlers
Modified: trunk/gperl.h
==============================================================================
--- trunk/gperl.h (original)
+++ trunk/gperl.h Sun Nov 2 11:35:17 2008
@@ -114,6 +114,7 @@
};
void gperl_register_fundamental (GType gtype, const char * package);
+void gperl_register_fundamental_alias (GType gtype, const char * package);
void gperl_register_fundamental_full (GType gtype, const char * package, GPerlValueWrapperClass * wrapper_class);
GType gperl_fundamental_type_from_package (const char * package);
@@ -208,6 +209,7 @@
void gperl_register_boxed (GType gtype,
const char * package,
GPerlBoxedWrapperClass * wrapper_class);
+void gperl_register_boxed_alias (GType gtype, const char * package);
SV * gperl_new_boxed (gpointer boxed, GType gtype, gboolean own);
SV * gperl_new_boxed_copy (gpointer boxed, GType gtype);
@@ -222,6 +224,7 @@
* GObject
*/
void gperl_register_object (GType gtype, const char * package);
+void gperl_register_object_alias (GType gtype, const char * package);
typedef void (*GPerlObjectSinkFunc) (GObject *);
void gperl_register_sink_func (GType gtype,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]