seed r217 - in trunk: . libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r217 - in trunk: . libseed
- Date: Sun, 9 Nov 2008 06:55:07 +0000 (UTC)
Author: racarr
Date: Sun Nov 9 06:55:07 2008
New Revision: 217
URL: http://svn.gnome.org/viewvc/seed?rev=217&view=rev
Log:
Some exception rework. Clean up API a bit.
Added:
trunk/libseed/seed-exceptions.c
trunk/libseed/seed-exceptions.h
Modified:
trunk/configure.ac
trunk/libseed/Makefile.am
trunk/libseed/seed-engine.c
trunk/libseed/seed-engine.h
trunk/libseed/seed.h
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Sun Nov 9 06:55:07 2008
@@ -1,7 +1,7 @@
dnl Process this file with autoconf to produce a configure script.
dnl Created by Anjuta application wizard.
-AC_INIT(seed, 0.1)
+AC_INIT(seed, 0.1.2)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_CONFIG_HEADERS([config.h])
Modified: trunk/libseed/Makefile.am
==============================================================================
--- trunk/libseed/Makefile.am (original)
+++ trunk/libseed/Makefile.am Sun Nov 9 06:55:07 2008
@@ -7,6 +7,8 @@
seed-closure.h \
seed-builtins.c\
seed-builtins.h \
+ seed-exceptions.c \
+ seed-exceptions.h \
seed-engine.c \
seed-engine.h \
seed-private.h \
Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c (original)
+++ trunk/libseed/seed-engine.c Sun Nov 9 06:55:07 2008
@@ -32,39 +32,6 @@
gchar *glib_message = 0;
-void
-seed_make_exception(JSValueRef * exception,
- const gchar * name, const gchar * message)
-{
- JSStringRef js_name = 0;
- JSStringRef js_message = 0;
- JSValueRef js_name_ref = 0, js_message_ref = 0;
- JSObjectRef exception_obj;
-
- if (!exception)
- return;
-
- if (name)
- {
- js_name = JSStringCreateWithUTF8CString(name);
- js_name_ref = JSValueMakeString(eng->context, js_name);
- }
- if (message)
- {
- js_message = JSStringCreateWithUTF8CString(message);
- js_message_ref = JSValueMakeString(eng->context, js_message);
- }
-
- exception_obj = JSObjectMake(eng->context, 0, NULL);
- seed_value_set_property(exception_obj, "message", js_message_ref);
- seed_value_set_property(exception_obj, "name", js_name_ref);
-
- *exception = exception_obj;
-
- JSStringRelease(js_name);
- JSStringRelease(js_message);
-}
-
static JSObjectRef
seed_gobject_constructor_invoked(JSContextRef ctx,
JSObjectRef constructor,
@@ -1080,45 +1047,3 @@
{
return s->exception;
}
-
-gchar *seed_exception_get_name(JSValueRef e)
-{
- SeedValue name;
- g_assert((e));
- if (!JSValueIsObject(eng->context, e))
- return 0;
-
- name = seed_value_get_property(e, "name");
- return seed_value_to_string(name, 0);
-}
-
-gchar *seed_exception_get_message(JSValueRef e)
-{
- SeedValue name;
- g_assert((e));
- if (!JSValueIsObject(eng->context, e))
- return 0;
-
- name = seed_value_get_property(e, "message");
- return seed_value_to_string(name, 0);
-}
-
-guint seed_exception_get_line(JSValueRef e)
-{
- SeedValue line;
- g_assert((e));
- if (!JSValueIsObject(eng->context, e))
- return 0;
- line = seed_value_get_property(e, "line");
- return seed_value_to_uint(line, 0);
-}
-
-gchar *seed_exception_get_file(JSValueRef e)
-{
- SeedValue file;
- g_assert((e));
- if (!JSValueIsObject(eng->context, e))
- return 0;
- file = seed_value_get_property(e, "sourceURL");
- return seed_value_to_string(file, 0);
-}
Modified: trunk/libseed/seed-engine.h
==============================================================================
--- trunk/libseed/seed-engine.h (original)
+++ trunk/libseed/seed-engine.h Sun Nov 9 06:55:07 2008
@@ -46,6 +46,6 @@
JSObjectRef object,
gboolean instance);
void seed_create_function(gchar * name, gpointer func, JSObjectRef obj);
-void seed_make_exception(JSValueRef * exception,
- const gchar * name, const gchar * message);
+
+
#endif
Added: trunk/libseed/seed-exceptions.c
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-exceptions.c Sun Nov 9 06:55:07 2008
@@ -0,0 +1,118 @@
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
+ */
+/*
+ * seed-exceptions.c
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "seed-private.h"
+
+void
+seed_make_exception(JSValueRef * exception,
+ const gchar * name,
+ const gchar * message)
+{
+ JSStringRef js_name = 0;
+ JSStringRef js_message = 0;
+ JSValueRef js_name_ref = 0, js_message_ref = 0;
+ JSObjectRef exception_obj;
+
+ if (!exception)
+ return;
+
+ if (name)
+ {
+ js_name = JSStringCreateWithUTF8CString(name);
+ js_name_ref = JSValueMakeString(eng->context, js_name);
+ }
+ if (message)
+ {
+ js_message = JSStringCreateWithUTF8CString(message);
+ js_message_ref = JSValueMakeString(eng->context, js_message);
+ }
+
+ exception_obj = JSObjectMake(eng->context, 0, NULL);
+ seed_value_set_property(exception_obj, "message", js_message_ref);
+ seed_value_set_property(exception_obj, "name", js_name_ref);
+
+ *exception = exception_obj;
+
+ JSStringRelease(js_name);
+ JSStringRelease(js_message);
+}
+
+gchar *seed_exception_get_name(JSValueRef e)
+{
+ SeedValue name;
+ g_assert((e));
+ if (!JSValueIsObject(eng->context, e))
+ return 0;
+
+ name = seed_value_get_property(e, "name");
+ return seed_value_to_string(name, 0);
+}
+
+gchar *seed_exception_get_message(JSValueRef e)
+{
+ SeedValue name;
+ g_assert((e));
+ if (!JSValueIsObject(eng->context, e))
+ return 0;
+
+ name = seed_value_get_property(e, "message");
+ return seed_value_to_string(name, 0);
+}
+
+guint seed_exception_get_line(JSValueRef e)
+{
+ SeedValue line;
+ g_assert((e));
+ if (!JSValueIsObject(eng->context, e))
+ return 0;
+ line = seed_value_get_property(e, "line");
+ return seed_value_to_uint(line, 0);
+}
+
+gchar * seed_exception_get_file(JSValueRef e)
+{
+ SeedValue line;
+ g_assert((e));
+ if (!JSValueIsObject(eng->context, e))
+ return 0;
+ line = seed_value_get_property(e, "sourceURL");
+ return seed_value_to_string(line, 0);
+}
+
+gchar * seed_exception_to_string(JSValueRef e)
+{
+ guint line;
+ gchar *mes, *name, *file, *ret;
+
+ line = seed_exception_get_line(e);
+ mes = seed_exception_get_message(e);
+ file = seed_exception_get_file(e);
+ name = seed_exception_get_name(e);
+
+ ret = g_strdup_printf("Line %d in %s: %s %s",
+ line, file, name, mes);
+
+ g_free(mes);
+ g_free(file);
+ g_free(name);
+}
+
+
Added: trunk/libseed/seed-exceptions.h
==============================================================================
--- (empty file)
+++ trunk/libseed/seed-exceptions.h Sun Nov 9 06:55:07 2008
@@ -0,0 +1,37 @@
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*-
+ */
+/*
+ * seed-engine.h
+ * Copyright (C) Robert Carr 2008 <carrr rpi edu>
+ *
+ * libseed is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * libseed is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef _SEED_EXCEPTIONS_H
+#define _SEED_EXCEPTIONS_H
+
+#include "seed-private.h"
+
+void seed_make_exception(JSValueRef * exception,
+ const gchar * name, const gchar * message);
+
+gchar *seed_exception_get_name(JSValueRef e);
+gchar *seed_exception_get_message(JSValueRef e);
+guint seed_exception_get_line(JSValueRef e);
+gchar *seed_exception_get_file(JSValueRef e);
+
+gchar * seed_exception_to_string(JSValueRef e);
+
+
+#endif _SEED_ENGINE_H
Modified: trunk/libseed/seed.h
==============================================================================
--- trunk/libseed/seed.h (original)
+++ trunk/libseed/seed.h Sun Nov 9 06:55:07 2008
@@ -44,6 +44,7 @@
gchar *seed_exception_get_message(SeedException e);
guint seed_exception_get_line(SeedException e);
gchar *seed_exception_get_file(SeedException e);
+gchar * seed_exception_to_string(SeedException e);
SeedValue seed_evaluate(SeedScript * s, SeedObject this);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]