seed r391 - in trunk: . libseed modules modules/canvas modules/sqlite
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r391 - in trunk: . libseed modules modules/canvas modules/sqlite
- Date: Fri, 5 Dec 2008 08:09:40 +0000 (UTC)
Author: racarr
Date: Fri Dec 5 08:09:39 2008
New Revision: 391
URL: http://svn.gnome.org/viewvc/seed?rev=391&view=rev
Log:
Beginnings of a toy canvas implementation.
Added:
trunk/modules/canvas/
trunk/modules/canvas/Makefile.am
trunk/modules/canvas/example.js (contents, props changed)
trunk/modules/canvas/seed-canvas.c
Modified:
trunk/configure.ac
trunk/libseed/seed-api.c
trunk/libseed/seed.h
trunk/modules/Makefile.am
trunk/modules/sqlite/seed-sqlite.c
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Dec 5 08:09:39 2008
@@ -112,6 +112,7 @@
modules/Makefile
modules/example/Makefile
modules/sqlite/Makefile
+modules/canvas/Makefile
])
echo "
Modified: trunk/libseed/seed-api.c
==============================================================================
--- trunk/libseed/seed-api.c (original)
+++ trunk/libseed/seed-api.c Fri Dec 5 08:09:39 2008
@@ -1,5 +1,15 @@
#include "seed-private.h"
+void seed_value_protect(JSContextRef ctx, JSValueRef value)
+{
+ JSValueProtect(ctx, value);
+}
+
+void seed_value_unprotect(JSContextRef ctx, JSValueRef value)
+{
+ JSValueUnprotect(ctx, value);
+}
+
JSGlobalContextRef seed_context_create(JSContextGroupRef group,
JSClassRef global_class)
{
Modified: trunk/libseed/seed.h
==============================================================================
--- trunk/libseed/seed.h (original)
+++ trunk/libseed/seed.h Fri Dec 5 08:09:39 2008
@@ -122,7 +122,8 @@
const SeedValue arguments[],
SeedException * exception);
-
+void seed_value_unprotect(SeedContext ctx, SeedValue value);
+void seed_value_protect(SeedContext ctx, SeedValue value);
/*
* seed-types.c
*/
@@ -228,6 +229,9 @@
GObject * val,
SeedException * exception);
+gpointer seed_pointer_get_pointer(SeedContext ctx,
+ SeedValue pointer);
+
typedef void (*SeedFunctionCallback) (SeedContext ctx,
SeedObject function,
SeedObject this_object,
Modified: trunk/modules/Makefile.am
==============================================================================
--- trunk/modules/Makefile.am (original)
+++ trunk/modules/Makefile.am Fri Dec 5 08:09:39 2008
@@ -1 +1 @@
-SUBDIRS = example sqlite
+SUBDIRS = example sqlite canvas
Added: trunk/modules/canvas/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/modules/canvas/Makefile.am Fri Dec 5 08:09:39 2008
@@ -0,0 +1,20 @@
+lib_LTLIBRARIES = \
+ libcanvas.la
+
+libcanvas_la_SOURCES = \
+ seed-canvas.c
+
+libsqlite_la_LDFLAGS = \
+ `pkg-config --libs seed cairo`
+
+EXTRA_DIST=example.js
+
+AM_CPPFLAGS = \
+ -I../../libseed/ \
+ `pkg-config --cflags seed` \
+ `pkg-config --cflags glib-2.0` -g \
+ `pkg-config --cflags gobject-introspection-1.0` \
+ `pkg-config --cflags cairo`
+
+libdir = ${exec_prefix}/lib/seed
+
Added: trunk/modules/canvas/example.js
==============================================================================
--- (empty file)
+++ trunk/modules/canvas/example.js Fri Dec 5 08:09:39 2008
@@ -0,0 +1,18 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gdk");
+Seed.import_namespace("Gtk");
+Seed.import_namespace("Canvas");
+
+
+Gtk.init(null, null);
+
+w = new Gtk.Window();
+w.show_all();
+
+cr = Gdk.cairo_create(w.window);
+c = new Canvas.CairoCanvas(cr);
+Seed.print(c);
+
+
+
+
Added: trunk/modules/canvas/seed-canvas.c
==============================================================================
--- (empty file)
+++ trunk/modules/canvas/seed-canvas.c Fri Dec 5 08:09:39 2008
@@ -0,0 +1,254 @@
+#include "../../libseed/seed.h"
+#include <cairo.h>
+
+SeedObject namespace_ref;
+SeedClass canvas_class;
+SeedEngine * eng;
+
+#define GET_CR cairo_t * cr = seed_object_get_private(this_object)
+
+SeedObject canvas_construct_canvas(SeedContext ctx,
+ SeedObject constructor,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ if (argument_count != 1)
+ {
+ seed_make_exception(ctx, exception, "ArgumentError",
+ "Canvas.Canvas constructor expected 1 argument");
+ return (SeedObject)seed_make_null(ctx);
+ }
+ return seed_make_object(ctx, canvas_class,
+ seed_pointer_get_pointer(ctx, arguments[0]));
+}
+
+SeedValue seed_canvas_save (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ cairo_save(cr);
+
+ return seed_make_null(ctx);
+}
+
+SeedValue seed_canvas_restore (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ cairo_restore(cr);
+
+ return seed_make_null(ctx);
+}
+
+SeedValue seed_canvas_scale (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ gdouble x = seed_value_to_double(ctx, arguments[0], exception);
+ gdouble y = seed_value_to_double(ctx, arguments[1], exception);
+
+ cairo_scale(cr, x, y);
+
+ return seed_make_null(ctx);
+}
+
+SeedValue seed_canvas_translate (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ gdouble x = seed_value_to_double(ctx, arguments[0], exception);
+ gdouble y = seed_value_to_double(ctx, arguments[1], exception);
+
+ cairo_translate(cr, x, y);
+
+ return seed_make_null(ctx);
+}
+
+SeedValue seed_canvas_rotate (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ gdouble x = seed_value_to_double(ctx, arguments[0], exception);
+
+ cairo_rotate(cr, x);
+
+ return seed_make_null(ctx);
+}
+
+SeedValue seed_canvas_transform (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ cairo_matrix_t matrix;
+ gdouble xx, yx, xy, yy, x0, y0;
+
+ xx = seed_value_to_double(ctx, arguments[0], exception);
+ yx = seed_value_to_double(ctx, arguments[1], exception);
+ xy = seed_value_to_double(ctx, arguments[2], exception);
+ yy = seed_value_to_double(ctx, arguments[3], exception);
+ x0 = seed_value_to_double(ctx, arguments[4], exception);
+ y0 = seed_value_to_double(ctx, arguments[5], exception);
+
+ cairo_matrix_init(&matrix, xx, yx, xy, yy, x0, y0);
+ cairo_transform(cr, &matrix);
+
+ return seed_make_null(ctx);
+}
+
+SeedValue seed_canvas_set_transform (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ cairo_matrix_t matrix;
+ gdouble xx, yx, xy, yy, x0, y0;
+
+ cairo_identity_matrix(cr);
+
+ xx = seed_value_to_double(ctx, arguments[0], exception);
+ yx = seed_value_to_double(ctx, arguments[1], exception);
+ xy = seed_value_to_double(ctx, arguments[2], exception);
+ yy = seed_value_to_double(ctx, arguments[3], exception);
+ x0 = seed_value_to_double(ctx, arguments[4], exception);
+ y0 = seed_value_to_double(ctx, arguments[5], exception);
+
+ cairo_matrix_init(&matrix, xx, yx, xy, yy, x0, y0);
+ cairo_transform(cr, &matrix);
+
+ return seed_make_null(ctx);
+}
+
+SeedValue seed_canvas_clear_rect (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ gdouble x, y, width, height;
+
+ x = seed_value_to_double(ctx, arguments[0], exception);
+ y = seed_value_to_double(ctx, arguments[0], exception);
+ width = seed_value_to_double(ctx, arguments[0], exception);
+ height = seed_value_to_double(ctx, arguments[0], exception);
+
+ cairo_save(cr);
+
+ cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
+ cairo_rectangle(cr, x, y, width, height);
+ cairo_clip(cr);
+
+ cairo_paint(cr);
+
+ cairo_restore(cr);
+
+ return seed_make_null(ctx);
+}
+SeedValue seed_canvas_stroke_rect (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ gdouble x, y, width, height;
+
+ x = seed_value_to_double(ctx, arguments[0], exception);
+ y = seed_value_to_double(ctx, arguments[0], exception);
+ width = seed_value_to_double(ctx, arguments[0], exception);
+ height = seed_value_to_double(ctx, arguments[0], exception);
+
+ cairo_rectangle(cr, x, y, width, height);
+ cairo_stroke(cr);
+
+ return seed_make_null(ctx);
+}
+SeedValue seed_canvas_fill_rect (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ size_t argument_count,
+ const SeedValue arguments[],
+ SeedException * exception)
+{
+ GET_CR;
+ gdouble x, y, width, height;
+
+ x = seed_value_to_double(ctx, arguments[0], exception);
+ y = seed_value_to_double(ctx, arguments[0], exception);
+ width = seed_value_to_double(ctx, arguments[0], exception);
+ height = seed_value_to_double(ctx, arguments[0], exception);
+
+ cairo_rectangle(cr, x, y, width, height);
+ cairo_fill(cr);
+
+ return seed_make_null(ctx);
+}
+
+seed_static_function canvas_funcs[] = {
+ {"save", seed_canvas_save, 0},
+ {"restore", seed_canvas_restore, 0},
+ {"scale", seed_canvas_scale, 0},
+ {"rotate", seed_canvas_rotate, 0},
+ {"translate", seed_canvas_translate, 0},
+ {"transform", seed_canvas_transform, 0},
+ {"setTransform", seed_canvas_set_transform, 0},
+ {"clearRect", seed_canvas_clear_rect, 0},
+ {"fillRect", seed_canvas_fill_rect, 0},
+ {"strokeRect", seed_canvas_stroke_rect, 0},
+ {0, 0, 0}
+};
+
+void seed_module_init(SeedEngine * local_eng)
+{
+ SeedObject canvas_constructor;
+ seed_class_definition canvas_class_def = seed_empty_class;
+
+ eng = local_eng;
+
+ namespace_ref = seed_make_object(eng->context, 0, 0);
+
+ seed_object_set_property(eng->context, eng->global, "Canvas",
+ namespace_ref);
+
+ canvas_class_def.class_name = "CairoCanvas";
+
+ canvas_class = seed_create_class(&canvas_class_def);
+
+ canvas_constructor = seed_make_constructor(eng->context,
+ canvas_class,
+ canvas_construct_canvas);
+
+ seed_object_set_property(eng->context, namespace_ref, "CairoCanvas",
+ canvas_constructor);
+
+}
Modified: trunk/modules/sqlite/seed-sqlite.c
==============================================================================
--- trunk/modules/sqlite/seed-sqlite.c (original)
+++ trunk/modules/sqlite/seed-sqlite.c Fri Dec 5 08:09:39 2008
@@ -96,8 +96,8 @@
for (i = 0; i < argc; i++)
{
seed_object_set_property(ctx, hash,
- azColName[i],
- seed_value_from_string(ctx, argv[i], 0));
+ azColName[i],
+ seed_value_from_string(ctx, argv[i], 0));
}
seed_object_call(ctx, function, 0, 1, &hash, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]