[gjs: 2/45] [cairo] Add context prototype
- From: Johan Dahlin <johan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 2/45] [cairo] Add context prototype
- Date: Tue, 2 Mar 2010 18:52:11 +0000 (UTC)
commit 6894309da80ac6f87e13fc4901be0cca0b9db855
Author: Johan Dahlin <johan gnome org>
Date: Wed Feb 17 19:17:25 2010 -0200
[cairo] Add context prototype
Makefile-modules.am | 3 +-
modules/cairo-context.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++
modules/cairo-private.h | 33 +++++++++++++++++++
modules/cairo.c | 10 +++++-
4 files changed, 124 insertions(+), 2 deletions(-)
---
diff --git a/Makefile-modules.am b/Makefile-modules.am
index f14088b..9b2984c 100644
--- a/Makefile-modules.am
+++ b/Makefile-modules.am
@@ -85,7 +85,8 @@ cairoNative_la_LDFLAGS = \
$(JS_NATIVE_MODULE_LDFLAGS)
cairoNative_la_SOURCES = \
- modules/cairo.h \
+ modules/cairo-private.h \
+ modules/cairo-context.c \
modules/cairo.c
diff --git a/modules/cairo-context.c b/modules/cairo-context.c
new file mode 100644
index 0000000..1411d84
--- /dev/null
+++ b/modules/cairo-context.c
@@ -0,0 +1,80 @@
+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+/* Copyright 2010 litl, LLC. All Rights Reserved.
+ *
+ * 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 <gjs/gjs.h>
+#include <cairo.h>
+#include "cairo-private.h"
+
+typedef struct {
+ void *dummy;
+ JSContext *context;
+ JSObject *object;
+} GjsCairoContext;
+
+GJS_DEFINE_PROTO("CairoContext", gjs_cairo_context)
+
+GJS_DEFINE_PRIV_FROM_JS(GjsCairoContext, gjs_cairo_context_class);
+
+static JSBool
+gjs_cairo_context_constructor(JSContext *context,
+ JSObject *obj,
+ uintN argc,
+ jsval *argv,
+ jsval *retval)
+{
+ GjsCairoContext *priv;
+
+ priv = g_slice_new0(GjsCairoContext);
+
+ g_assert(priv_from_js(context, obj) == NULL);
+ JS_SetPrivate(context, obj, priv);
+
+ priv->context = context;
+ priv->object = obj;
+
+ return JS_TRUE;
+}
+
+static void
+gjs_cairo_context_finalize(JSContext *context,
+ JSObject *obj)
+{
+ GjsCairoContext *priv;
+ priv = priv_from_js(context, obj);
+ if (priv == NULL)
+ return;
+
+ g_slice_free(GjsCairoContext, priv);
+}
+
+/* Properties */
+static JSPropertySpec gjs_cairo_context_proto_props[] = {
+ { NULL }
+};
+
+/* Methods */
+static JSFunctionSpec gjs_cairo_context_proto_funcs[] = {
+ { NULL }
+};
+
diff --git a/modules/cairo-private.h b/modules/cairo-private.h
new file mode 100644
index 0000000..bc66490
--- /dev/null
+++ b/modules/cairo-private.h
@@ -0,0 +1,33 @@
+/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
+/* Copyright 2010 litl, LLC. All Rights Reserved.
+ *
+ * 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.
+ */
+
+#ifndef __CAIRO_PRIVATE_H__
+#define __CAIRO_PRIVATE_H__
+
+JSBool gjs_js_define_cairo_stuff(JSContext *context,
+ JSObject *module_obj);
+
+jsval gjs_cairo_context_create_proto(JSContext *context, JSObject *module,
+ const char *proto_name, JSObject *parent);
+
+#endif /* __CAIRO_PRIVATE_H__ */
+
diff --git a/modules/cairo.c b/modules/cairo.c
index 9f27940..ef05b84 100644
--- a/modules/cairo.c
+++ b/modules/cairo.c
@@ -23,12 +23,20 @@
#include <config.h>
#include <gjs/gjs.h>
-#include <cairo.h>
+
+#include "cairo-private.h"
JSBool
gjs_js_define_cairo_stuff(JSContext *context,
JSObject *module_obj)
{
+ jsval obj;
+
+ obj = gjs_cairo_context_create_proto(context, module_obj,
+ "Context", NULL);
+ if (obj == JSVAL_NULL)
+ return JS_FALSE;
+
return JS_TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]