[seed] Implementing a dymmy _gi module



commit b5ba834f64838ad586447c114fe409ba2fcb1ef0
Author: Danilo Cesar Lemes de Paula <danilo cesar collabora co uk>
Date:   Thu Mar 17 14:27:13 2016 -0300

    Implementing a dymmy _gi module
    
    Adding a module missing to deal with seed/gjs compatibility

 configure.ac                |    1 +
 modules/gjs/Makefile.am     |    2 +-
 modules/gjs/_gi/Makefile.am |   22 +++++
 modules/gjs/_gi/seed-gi.c   |  181 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 205 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e0004a4..fb3620d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -511,6 +511,7 @@ modules/ffi/Makefile
 modules/DynamicObject/Makefile
 
 modules/gjs/system/Makefile
+modules/gjs/_gi/Makefile
 extensions/gjs/Makefile
 modules/gjs/Makefile
 
diff --git a/modules/gjs/Makefile.am b/modules/gjs/Makefile.am
index 3ab87eb..d9a106c 100644
--- a/modules/gjs/Makefile.am
+++ b/modules/gjs/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = system
+SUBDIRS = system _gi
 
 EXTRA_DIST= cairo.js coverage.js format.js gettext.js jsUnit.js lang.js mainloop.js package.js signals.js
 
diff --git a/modules/gjs/_gi/Makefile.am b/modules/gjs/_gi/Makefile.am
new file mode 100644
index 0000000..925a99a
--- /dev/null
+++ b/modules/gjs/_gi/Makefile.am
@@ -0,0 +1,22 @@
+seedlibdir = ${libdir}/seed SEED_GTK_VERSION@/gjs
+
+seedlib_LTLIBRARIES = \
+       libseed__gi.la
+
+libseed__gi_la_SOURCES = \
+       seed-gi.c
+
+AM_CPPFLAGS = \
+       -I top_srcdir@/libseed/ \
+       $(GOBJECT_INTROSPECTION_CFLAGS) \
+       $(SEED_DEBUG_CFLAGS) \
+       $(SEED_PROFILE_CFLAGS)
+
+libseed__gi_la_LDFLAGS = \
+       -module -avoid-version \
+       $(GOBJECT_INTROSPECTION_LDFLAGS)
+
+libseed__gi_la_LIBADD = \
+       $(top_builddir)/libseed/libseed SEED_GTK_VERSION@.la \
+       $(SEED_PROFILE_LIBS)
+
diff --git a/modules/gjs/_gi/seed-gi.c b/modules/gjs/_gi/seed-gi.c
new file mode 100644
index 0000000..a090638
--- /dev/null
+++ b/modules/gjs/_gi/seed-gi.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2015 Collabora Ltd.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include <glib.h>
+#include <seed-module.h>
+#include <config.h>
+
+#define GJS_COMPAT_VERSION (1 * 100 + 40) * 100 + 0
+
+#define NUMARG_EXPECTED_EXCEPTION(name, argc)                                  \
+    seed_make_exception(ctx, exception, "ArgumentError",                       \
+                        name " expected " argc " but got %zd", argumentCount); \
+    return seed_make_undefined(ctx);
+
+static SeedValue
+gjs_override_property(SeedContext ctx,
+                      SeedObject function,
+                      SeedObject this_object,
+                      size_t argumentCount,
+                      const SeedValue arguments[],
+                      SeedException* exception)
+{
+    // TODO: to be implemented.
+    seed_make_exception(ctx, exception, "ImplementationError",
+                        "Not implemented yet");
+    return seed_make_undefined(ctx);
+}
+
+static SeedValue
+gjs_register_interface(SeedContext ctx,
+                       SeedObject function,
+                       SeedObject this_object,
+                       size_t argumentCount,
+                       const SeedValue arguments[],
+                       SeedException* exception)
+{
+    // TODO: to be implemented.
+    seed_make_exception(ctx, exception, "ImplementationError",
+                        "Not implemented yet");
+    return seed_make_undefined(ctx);
+}
+static SeedValue
+gjs_register_type(SeedContext ctx,
+                  SeedObject function,
+                  SeedObject this_object,
+                  size_t argumentCount,
+                  const SeedValue arguments[],
+                  SeedException* exception)
+{
+    // TODO: to be implemented.
+    seed_make_exception(ctx, exception, "ImplementationError",
+                        "Not implemented yet");
+    return seed_make_undefined(ctx);
+}
+
+static SeedValue
+gjs_add_interface(SeedContext ctx,
+                  SeedObject function,
+                  SeedObject this_object,
+                  size_t argumentCount,
+                  const SeedValue arguments[],
+                  SeedException* exception)
+{
+    // TODO: to be implemented.
+    seed_make_exception(ctx, exception, "ImplementationError",
+                        "Not implemented yet");
+    return seed_make_undefined(ctx);
+}
+
+static SeedValue
+gjs_hook_up_vfunc(SeedContext ctx,
+                  SeedObject function,
+                  SeedObject this_object,
+                  size_t argumentCount,
+                  const SeedValue arguments[],
+                  SeedException* exception)
+{
+    // TODO: to be implemented.
+    seed_make_exception(ctx, exception, "ImplementationError",
+                        "Not implemented yet");
+    return seed_make_undefined(ctx);
+}
+
+static SeedValue
+gjs_signal_new(SeedContext ctx,
+               SeedObject function,
+               SeedObject this_object,
+               size_t argumentCount,
+               const SeedValue arguments[],
+               SeedException* exception)
+{
+    // TODO: to be implemented.
+    seed_make_exception(ctx, exception, "ImplementationError",
+                        "Not implemented yet");
+    return seed_make_undefined(ctx);
+}
+
+static seed_static_function module_funcs[]
+  = { { "override_property", gjs_override_property, 0 },
+      { "register_interface", gjs_register_interface, 0 },
+      { "register_type", gjs_register_type, 0 },
+      { "add_interface", gjs_add_interface, 0 },
+      { "hook_up_vfunc", gjs_hook_up_vfunc, 0 },
+      { "signal_new", gjs_signal_new, 0 },
+      { 0, 0, 0 } };
+
+static seed_class_definition system_def = {
+    0,                                        /* Version, always 0 */
+    SEED_CLASS_ATTRIBUTE_NO_SHARED_PROTOTYPE, /* JSClassAttributes */
+    "_gi",                                    /* Class Name */
+    NULL,                                     /* Parent Class */
+    NULL,                                     /* Static Values */
+    module_funcs,                             /* Static Functions */
+    NULL,
+    NULL, /* Finalize */
+    NULL, /* Has Property */
+    NULL, /* Get Property */
+    NULL, /* Set Property */
+    NULL, /* Delete Property */
+    NULL, /* Get Property Names */
+    NULL, /* Call As Function */
+    NULL, /* Call As Constructor */
+    NULL, /* Has Instance */
+    NULL  /* Convert To Type */
+};
+
+SeedObject
+gjs_compat_define_gi_stuff(SeedEngine* eng)
+{
+    SeedContext context = eng->context;
+    SeedObject module;
+    gboolean ret;
+
+    module = seed_make_object(context, seed_create_class(&system_def), NULL);
+    g_print("Module: %p\n", module);
+
+    SeedValue seed = seed_object_get_property(context, eng->global, "Seed");
+    SeedValue argv = seed_object_get_property(context, seed, "argv");
+
+    g_print("Seed: %p\n", seed);
+    g_print("Argv: %p\n", argv);
+
+    ret = seed_object_set_property(
+      context, module, "version",
+      (SeedValue) seed_value_from_int(context, GJS_COMPAT_VERSION, NULL));
+    g_print("Module: %d\n", ret);
+
+    return module;
+}
+
+SeedObject
+seed_module_init(SeedEngine* eng)
+{
+    return gjs_compat_define_gi_stuff(eng);
+}


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