[gjs] Merge gi.so into gjs.so



commit d3e5105ae51223614f7297bce35fc7fc52cd5ebf
Author: Colin Walters <walters verbum org>
Date:   Tue Jun 21 17:39:16 2011 -0400

    Merge gi.so into gjs.so
    
    No consumer of gjs is interested in gjs without gi, let's stop
    pretending it's an addon module.  All of the other modules link
    to it anyways, and in reality to integrate things well, we
    need to be able to cross call between gjs core -> gi and the
    reverse.

 Makefile-gi.am        |   61 -------------------------------------------------
 Makefile-modules.am   |   32 +++++++------------------
 Makefile.am           |   46 +++++++++++++++++++++++++++++++++++-
 configure.ac          |    4 +--
 gi/value.c            |   18 ++------------
 gjs/context.c         |    5 ++++
 {modules => gjs}/gi.c |    0
 {modules => gjs}/gi.h |    0
 8 files changed, 62 insertions(+), 104 deletions(-)
---
diff --git a/Makefile-modules.am b/Makefile-modules.am
index 45c7d9d..9607d1c 100644
--- a/Makefile-modules.am
+++ b/Makefile-modules.am
@@ -16,7 +16,7 @@ dist_gjsjs_DATA +=		\
 	modules/dbus.js		\
 	modules/promise.js
 
-gjsnative_LTLIBRARIES += console.la debugger.la gi.la langNative.la mainloop.la gettextNative.la dbusNative.la cairoNative.la
+gjsnative_LTLIBRARIES += console.la debugger.la langNative.la mainloop.la gettextNative.la dbusNative.la cairoNative.la
 
 JS_NATIVE_MODULE_CFLAGS =	\
         $(AM_CFLAGS)		\
@@ -28,24 +28,10 @@ JS_NATIVE_MODULE_LIBADD =	\
 JS_NATIVE_MODULE_LDFLAGS =	\
         -module -avoid-version -no-undefined -rdynamic
 
-gi_la_CFLAGS = 					\
-	$(JS_NATIVE_MODULE_CFLAGS) 		\
-	$(GJS_GI_CFLAGS)
-gi_la_LIBADD = \
-	libgjs-gi.la				\
-	$(JS_NATIVE_MODULE_LIBADD) 		\
-	$(GJS_GI_LIBS)
-gi_la_LDFLAGS = 				\
-	$(JS_NATIVE_MODULE_LDFLAGS)
-
-gi_la_SOURCES =		\
-	modules/gi.h	\
-	modules/gi.c
-
 langNative_la_CFLAGS = 				\
 	$(JS_NATIVE_MODULE_CFLAGS)
 langNative_la_LIBADD = \
-	libgjs-gi.la				\
+	libgjs.la				\
 	$(JS_NATIVE_MODULE_LIBADD)
 langNative_la_LDFLAGS = 			\
 	$(JS_NATIVE_MODULE_LDFLAGS)
@@ -57,7 +43,7 @@ langNative_la_SOURCES =				\
 mainloop_la_CFLAGS = 				\
 	$(JS_NATIVE_MODULE_CFLAGS)
 mainloop_la_LIBADD = \
-	libgjs-gi.la				\
+	libgjs.la				\
 	$(JS_NATIVE_MODULE_LIBADD)
 mainloop_la_LDFLAGS = 				\
 	$(JS_NATIVE_MODULE_LDFLAGS)
@@ -69,7 +55,7 @@ mainloop_la_SOURCES =		\
 gettextNative_la_CFLAGS = 				\
 	$(JS_NATIVE_MODULE_CFLAGS)
 gettextNative_la_LIBADD = \
-	libgjs-gi.la				\
+	libgjs.la				\
 	$(JS_NATIVE_MODULE_LIBADD)
 gettextNative_la_LDFLAGS = 				\
 	$(JS_NATIVE_MODULE_LDFLAGS)
@@ -81,12 +67,12 @@ gettextNative_la_SOURCES =		\
 cairoNative_la_CFLAGS =                         \
         $(JS_NATIVE_MODULE_CFLAGS)              \
         $(GJS_CAIRO_CFLAGS)                     \
-        $(GJS_GI_CFLAGS)
+        $(GJS_CFLAGS)
 cairoNative_la_LIBADD =                         \
-        libgjs-gi.la                            \
+        libgjs.la                            \
         $(JS_NATIVE_MODULE_LIBADD)              \
         $(GJS_CAIRO_LIBS)                       \
-        $(GJS_GI_LIBS)
+        $(GJS_LIBS)
 cairoNative_la_LDFLAGS =                        \
         $(JS_NATIVE_MODULE_LDFLAGS)
 
@@ -123,7 +109,7 @@ console_la_SOURCES =		\
 debugger_la_CFLAGS = 				\
 	$(JS_NATIVE_MODULE_CFLAGS)
 debugger_la_LIBADD = \
-	libgjs-gi.la				\
+	libgjs.la				\
 	$(JS_NATIVE_MODULE_LIBADD)
 debugger_la_LDFLAGS = 				\
 	$(JS_NATIVE_MODULE_LDFLAGS)
@@ -143,7 +129,7 @@ dbusNative_la_CFLAGS = 					\
 	$(JS_NATIVE_MODULE_CFLAGS) 		\
 	$(GJS_DBUS_CFLAGS)
 dbusNative_la_LIBADD = \
-	libgjs-gi.la				\
+	libgjs.la				\
 	libgjs-dbus.la				\
 	$(JS_NATIVE_MODULE_LIBADD) 		\
 	$(GJS_DBUS_LIBS)
diff --git a/Makefile.am b/Makefile.am
index 886554e..e3f1ad8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -65,8 +65,9 @@ lib_LTLIBRARIES += libgjs.la
 
 libgjs_la_CPPFLAGS =		\
 	$(AM_CPPFLAGS)		\
-	$(GJS_CFLAGS)		\
+	$(GJS_CFLAGS)	\
 	$(gjs_directory_defines)\
+	-I$(top_srcdir)/gi	\
 	-DGJS_COMPILATION
 libgjs_la_CFLAGS = 		\
 	$(AM_CFLAGS)
@@ -84,6 +85,8 @@ libgjs_la_SOURCES =		\
 	gjs/byteArray.c		\
 	gjs/context.c		\
 	gjs/importer.c		\
+	gjs/gi.h		\
+	gjs/gi.c		\
 	gjs/jsapi-private.cpp	\
 	gjs/jsapi-util.c	\
 	gjs/jsapi-util-array.c	\
@@ -100,6 +103,46 @@ libgjs_la_SOURCES =		\
 	util/log.c		\
 	util/misc.c
 
+# For historical reasons, some files live in gi/
+libgjs_la_SOURCES += \
+	gi/arg.h	\
+	gi/boxed.h	\
+	gi/closure.h	\
+	gi/enumeration.h	\
+	gi/function.h	\
+	gi/keep-alive.h	\
+	gi/gjs_gi_trace.h \
+	gi/ns.h	        \
+	gi/object.h	\
+	gi/foreign.h	\
+	gi/param.h	\
+	gi/repo.h	\
+	gi/union.h	\
+	gi/value.h	\
+	gi/arg.c	\
+	gi/boxed.c	\
+	gi/closure.c	\
+	gi/enumeration.c	\
+	gi/function.c	\
+	gi/keep-alive.c	\
+	gi/ns.c	\
+	gi/object.c	\
+	gi/foreign.c	\
+	gi/param.c	\
+        gi/repo.c	\
+	gi/union.c	\
+        gi/value.c
+
+if ENABLE_DTRACE
+gjs_gi_probes.h: gi/gjs_gi_probes.d
+	$(DTRACE) -C -h -s $< -o $@
+gjs_gi_probes.o: gi/gjs_gi_probes.d
+	$(DTRACE) -G -s $< -o $@
+BUILT_SOURCES += gjs_gi_probes.h gjs_gi_probes.o
+libgjs_la_LIBADD += gjs_gi_probes.o
+endif
+EXTRA_DIST += gi/gjs_gi_probes.d
+
 gjstest_files_with_tests += 	\
 	gjs/context.c		\
 	gjs/jsapi-util-array.c	\
@@ -118,7 +161,6 @@ tapset_DATA = $(tapset_in_files:.stp.in=.stp)
 endif
 
 include Makefile-gjs-dbus.am
-include Makefile-gi.am
 include Makefile-modules.am
 include Makefile-examples.am
 ########################################################################
diff --git a/configure.ac b/configure.ac
index 27badf9..ec5e164 100644
--- a/configure.ac
+++ b/configure.ac
@@ -218,8 +218,7 @@ fi
 CFLAGS="$save_CFLAGS"
 
 common_packages="gobject-2.0 >= gobject_required_version $JS_PACKAGE"
-gjs_packages="gmodule-2.0 gthread-2.0 $common_packages"
-gjs_gi_packages="gobject-introspection-1.0 >= 0.10.1 $common_packages"
+gjs_packages="gmodule-2.0 gthread-2.0 gobject-introspection-1.0 >= 0.10.1 $common_packages"
 gjs_cairo_gobject_packages="cairo-gobject $common_packages"
 gjs_cairo_packages="cairo $common_packages"
 gjs_dbus_packages="dbus-glib-1 $common_packages"
@@ -228,7 +227,6 @@ gjstests_packages="$gjstests_packages $gjs_packages"
 
 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= gobject_required_version])
 PKG_CHECK_MODULES([GJS], [$gjs_packages])
-PKG_CHECK_MODULES([GJS_GI], [$gjs_gi_packages])
 # Prefer cairo-gobject if we have it
 PKG_CHECK_MODULES([GJS_CAIRO], [$gjs_cairo_gobject_packages], have_cairo_gobject=yes, have_cairo_gobject=no)
 if test x${have_cairo_gobject} != xyes; then
diff --git a/gi/value.c b/gi/value.c
index 2de1401..a8f1424 100644
--- a/gi/value.c
+++ b/gi/value.c
@@ -37,10 +37,6 @@
 
 #include <girepository.h>
 
-static GType _array_type = G_TYPE_INVALID;
-static GType _byte_array_type = G_TYPE_INVALID;
-static GType _ptr_array_type = G_TYPE_INVALID;
-
 static JSBool gjs_value_from_g_value_internal(JSContext    *context,
                                               jsval        *value_p,
                                               const GValue *gvalue,
@@ -638,9 +634,9 @@ gjs_value_from_g_value_internal(JSContext    *context,
             return JS_FALSE;
         }
     } else if (g_type_is_a(gtype, G_TYPE_HASH_TABLE) ||
-               g_type_is_a(gtype, _array_type) ||
-               g_type_is_a(gtype, _byte_array_type) ||
-               g_type_is_a(gtype, _ptr_array_type)) {
+               g_type_is_a(gtype, G_TYPE_ARRAY) ||
+               g_type_is_a(gtype, G_TYPE_BYTE_ARRAY) ||
+               g_type_is_a(gtype, G_TYPE_PTR_ARRAY)) {
         gjs_throw(context,
                   "Unable to introspect element-type of container in GValue");
         return JS_FALSE;
@@ -772,11 +768,3 @@ gjs_value_from_g_value(JSContext    *context,
 {
     return gjs_value_from_g_value_internal(context, value_p, gvalue, FALSE, NULL, 0);
 }
-
-__attribute__((constructor)) static void
-_gjs_value_init_types(void)
-{
-    _array_type = g_type_from_name("GArray");
-    _byte_array_type = g_type_from_name("GByteArray");
-    _ptr_array_type = g_type_from_name("GPtrArray");
-}
diff --git a/gjs/context.c b/gjs/context.c
index d810d50..377ea61 100644
--- a/gjs/context.c
+++ b/gjs/context.c
@@ -31,6 +31,8 @@
 #include "byteArray.h"
 #include "compat.h"
 
+#include "gi.h"
+
 #include <util/log.h>
 #include <util/glib.h>
 #include <util/error.h>
@@ -666,6 +668,9 @@ gjs_context_constructor (GType                  type,
         js_context->profiler = gjs_profiler_new(js_context->runtime);
     }
 
+    if (!gjs_is_registered_native_module(js_context->context, NULL, "gi"))
+        gjs_register_native_module("gi", gjs_define_gi_stuff, 0);
+
     JS_EndRequest(js_context->context);
 
     g_static_mutex_lock (&contexts_lock);
diff --git a/modules/gi.c b/gjs/gi.c
similarity index 100%
rename from modules/gi.c
rename to gjs/gi.c
diff --git a/modules/gi.h b/gjs/gi.h
similarity index 100%
rename from modules/gi.h
rename to gjs/gi.h



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]