seed r517 - in trunk: . examples examples/turtle libseed modules/readline src tests



Author: hortont
Date: Sat Dec 20 08:21:16 2008
New Revision: 517
URL: http://svn.gnome.org/viewvc/seed?rev=517&view=rev

Log:
Remove readline builtin, fix everything everywhere that uses it...


Modified:
   trunk/Makefile.am
   trunk/config.h.in
   trunk/configure.ac
   trunk/examples/repl.js
   trunk/examples/turtle/Makefile.am
   trunk/libseed/seed-builtins.c
   trunk/modules/readline/Makefile.am
   trunk/src/main.c
   trunk/tests/builtin-argument-length.js
   trunk/tests/readline.js

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Sat Dec 20 08:21:16 2008
@@ -1,26 +1,23 @@
 ## Process this file with automake to produce Makefile.in
-## Created by Anjuta
 
 SUBDIRS = po \
-	libseed\
-	src\
-	extensions\
-	doc\
-	examples\
+	libseed \
+	src \
+	extensions \
+	doc \
+	examples \
 	modules \
 	tests
-	
 
 seeddocdir = ${prefix}/share/doc/seed
 seeddoc_DATA = \
-	README\
-	COPYING\
-	AUTHORS\
-	ChangeLog\
-	INSTALL\
+	README \
+	COPYING \
+	AUTHORS \
+	ChangeLog \
+	INSTALL \
 	NEWS
 
-
 pkgconfig_DATA = seed.pc 
 
 pkgconfigdir = $(libdir)/pkgconfig
@@ -30,7 +27,6 @@
 
 DISTCHEKC_CONFIGURE_FLAGS=--enable-gtk-doc
 
-
 # Copy all the spec files. Of cource, only one is actually used.
 dist-hook:
 	for specfile in *.spec; do \

Modified: trunk/config.h.in
==============================================================================
--- trunk/config.h.in	(original)
+++ trunk/config.h.in	Sat Dec 20 08:21:16 2008
@@ -24,9 +24,6 @@
 /* Define if your <locale.h> file defines LC_MESSAGES. */
 #undef HAVE_LC_MESSAGES
 
-/* have readline */
-#undef HAVE_LIBREADLINE
-
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sat Dec 20 08:21:16 2008
@@ -56,10 +56,12 @@
   AC_SUBST(FFI_CFLAGS)
 fi
 
-dnl ==========================libreadline======================================
-AC_CHECK_LIB(readline, readline,
-    AC_DEFINE(HAVE_LIBREADLINE, 1, [have readline]),
-    AC_MSG_ERROR([readline not found]))
+dnl ========================readline module====================================
+AC_TRY_CPP([#include <readline/readline.h>],
+					 have_readline_h=yes,
+					 have_readline_h=no)
+AM_CONDITIONAL(BUILD_READLINE_MODULE, test "x$have_readline_h" = "xyes")
+AC_SUBST(BUILD_READLINE_MODULE)
 
 dnl =========================canvas module=====================================
 AC_TRY_CPP([#include <cairo/cairo.h>], have_cairo_h=yes, have_cairo_h=no)
@@ -142,4 +144,5 @@
 Modules:
    SQLite.....................$have_sqlite3_h
    Canvas.....................$have_cairo_h
+   readline...................$have_readline_h
 "

Modified: trunk/examples/repl.js
==============================================================================
--- trunk/examples/repl.js	(original)
+++ trunk/examples/repl.js	Sat Dec 20 08:21:16 2008
@@ -1,16 +1,16 @@
 #!/usr/bin/env seed
-with (Seed)
+
+Seed.import_namespace("readline");
+
+while(1)
 {
-	while(1)
+	try
 	{
-		try
-		{
-			item = readline("> ");
-			print(eval(item));
-		}
-		catch(e)
-		{
-			print(e.name + " " + e.message);
-		}
+		item = readline.readline("> ");
+		Seed.print(eval(item));
+	}
+	catch(e)
+	{
+	   	Seed.print(e.name + " " + e.message);
 	}
 }

Modified: trunk/examples/turtle/Makefile.am
==============================================================================
--- trunk/examples/turtle/Makefile.am	(original)
+++ trunk/examples/turtle/Makefile.am	Sat Dec 20 08:21:16 2008
@@ -10,7 +10,7 @@
 	turtle.c
 
 seed_turtle_LDFLAGS = \
-	-L../../libseed/.libs -lseed -lreadline
+	-L../../libseed/.libs -lseed
 
 seed_turtle_LDADD = \
 	$(SEED_LIBS) \

Modified: trunk/libseed/seed-builtins.c
==============================================================================
--- trunk/libseed/seed-builtins.c	(original)
+++ trunk/libseed/seed-builtins.c	Sat Dec 20 08:21:16 2008
@@ -20,8 +20,6 @@
  */
 #include <stdio.h>
 #include "seed-private.h"
-#include <readline/readline.h>
-#include <readline/history.h>
 #include <string.h>
 #include <sys/mman.h>
 
@@ -104,114 +102,6 @@
 	return JSValueMakeNull(ctx);
 }
 
-static void
-seed_handle_rl_closure(ffi_cif * cif,
-					   void * result,
-					   void ** args,
-					   void * userdata)
-{
-	JSContextRef ctx = JSGlobalContextCreateInGroup(context_group,
-													0);
-	JSValueRef exception = 0;
-	JSObjectRef function = (JSObjectRef) userdata;
-
-	JSObjectCallAsFunction(ctx, function, 0, 0, 0, &exception);
-	if (exception)
-	{
-		gchar *mes = seed_exception_to_string(ctx, 
-											  exception);
-		g_warning("Exception in readline bind key closure. %s \n", mes, 0);
-	}
-	JSGlobalContextRelease((JSGlobalContextRef)ctx);
-}
-
-// "Leaky" in that it exists for lifetime of program,
-// kind of unavoidable though.
-static ffi_closure * seed_make_rl_closure(JSObjectRef function)
-{
-	ffi_cif * cif;
-	ffi_closure *closure;
-	ffi_arg result;
-	ffi_status status;
-	
-	cif = g_new0(ffi_cif, 1);
-	closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
-				   PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
-	ffi_prep_cif(cif, FFI_DEFAULT_ABI, 0, &ffi_type_sint, 0);
-	ffi_prep_closure(closure, cif, seed_handle_rl_closure, function);
-	
-	return closure;
-}
-
-static JSValueRef
-seed_readline_bind(JSContextRef ctx,
-			  JSObjectRef function,
-			  JSObjectRef this_object,
-			  size_t argumentCount,
-			  const JSValueRef arguments[], JSValueRef * exception)
-{
-	gchar * key;
-	ffi_closure * c;
-
-	if (argumentCount != 2)
-	{
-		gchar *mes =
-			g_strdup_printf("Seed.readline_bind expected 2 arguments, "
-							"got %d", argumentCount);
-		seed_make_exception(ctx, exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeNull(ctx);
-	}
-
-	key = seed_value_to_string(ctx, arguments[0], exception);
-	c = seed_make_rl_closure((JSObjectRef)arguments[1]);
-	
-	rl_bind_key(*key, (Function*)c);
-	
-	g_free(key);
-	
-	return JSValueMakeNull(ctx);
-}
-
-static JSValueRef
-seed_readline(JSContextRef ctx,
-			  JSObjectRef function,
-			  JSObjectRef this_object,
-			  size_t argumentCount,
-			  const JSValueRef arguments[], JSValueRef * exception)
-{
-	JSValueRef valstr = 0;
-	gchar *str = 0;
-	gchar *buf;
-
-	if (argumentCount != 1)
-	{
-		gchar *mes =
-			g_strdup_printf("Seed.readline expected 1 argument, "
-							"got %d", argumentCount);
-		seed_make_exception(ctx, exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeNull(ctx);
-	}
-
-	buf = seed_value_to_string(ctx, arguments[0], exception);
-
-	str = readline(buf);
-	if (str && *str)
-	{
-		add_history(str);
-		valstr = seed_value_from_string(ctx, str, exception);
-		g_free(str);
-	}
-
-	g_free(buf);
-
-	if (valstr == 0)
-		valstr = JSValueMakeNull(ctx);
-
-	return valstr;
-}
-
 const gchar *seed_g_type_name_to_string(GITypeInfo * type)
 {
 	GITypeTag type_tag = g_type_info_get_tag(type);
@@ -415,8 +305,6 @@
 	seed_create_function(local_eng->context, 
 						 "print", &seed_print, obj);
 	seed_create_function(local_eng->context, 
-						 "readline", &seed_readline, obj);
-	seed_create_function(local_eng->context, 
 						 "check_syntax", &seed_check_syntax, obj);
 	seed_create_function(local_eng->context, 
 						 "introspect", &seed_introspect, obj);
@@ -426,8 +314,6 @@
 						 "spawn", &seed_spawn, obj);
 	seed_create_function(local_eng->context, 
 						 "quit", &seed_quit, obj);
-	seed_create_function(local_eng->context, 
-						 "readline_bind", &seed_readline_bind, obj);
 
 	arrayObj = JSObjectMake(local_eng->context, NULL, NULL);
 

Modified: trunk/modules/readline/Makefile.am
==============================================================================
--- trunk/modules/readline/Makefile.am	(original)
+++ trunk/modules/readline/Makefile.am	Sat Dec 20 08:21:16 2008
@@ -1,4 +1,4 @@
-#if BUILD_SQLITE3_MODULE
+if BUILD_READLINE_MODULE
 
 lib_LTLIBRARIES = \
 	libreadline.la
@@ -15,6 +15,6 @@
 	`pkg-config --cflags glib-2.0` -g \
 	`pkg-config --cflags gobject-introspection-1.0`
 
-#endif
+endif
 
 libdir = ${exec_prefix}/lib/seed

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Sat Dec 20 08:21:16 2008
@@ -23,7 +23,6 @@
 #include <stdio.h>
 #include "../libseed/seed.h"
 #include "../libseed/seed-debug.h"
-#include <readline/readline.h>
 #include <stdlib.h>
 #include <girepository.h>
 
@@ -33,8 +32,9 @@
 {
 	SeedScript  * script;
 
-	script = seed_make_script(eng->context, "while(1) { try { Seed.print(eval("
-							  "Seed.readline(\"> \"))); } catch(e) {"
+	script = seed_make_script(eng->context, "Seed.import_namespace('readline');"
+							  "while(1) { try { Seed.print(eval("
+							  "readline.readline(\"> \"))); } catch(e) {"
 							  "Seed.print(e.name + \" \" + e.message);}}",
 							  NULL, 0);
 	seed_evaluate(eng->context, script, 0);

Modified: trunk/tests/builtin-argument-length.js
==============================================================================
--- trunk/tests/builtin-argument-length.js	(original)
+++ trunk/tests/builtin-argument-length.js	Sat Dec 20 08:21:16 2008
@@ -1,7 +1,7 @@
 #!/usr/bin/env seed
 // Returns: 0
 // STDIN:
-// STDOUT:Seed\.include expected 1 argument, got 0\nFile not found: 1\.000000\.\n\nFile not found: \.\n\nSeed\.include expected 1 argument, got 2\nSeed\.include expected 1 argument, got 2\nSeed\.print expected 1 argument, got 0\nSeed\.print expected 1 argument, got 2\nSeed\.print expected 1 argument, got 2\nSeed\.print expected 1 argument, got 3\nSeed\.readline expected 1 argument, got 0\nSeed\.readline expected 1 argument, got 2\nSeed\.introspect expected 1 argument, got 0\nSeed\.introspect expected 1 argument, got 2\nSeed\.check_syntax expected 1 argument, got 0\nSeed\.check_syntax expected 1 argument, got 2
+// STDOUT:Seed\.include expected 1 argument, got 0\nFile not found: 1\.000000\.\n\nFile not found: \.\n\nSeed\.include expected 1 argument, got 2\nSeed\.include expected 1 argument, got 2\nSeed\.print expected 1 argument, got 0\nSeed\.print expected 1 argument, got 2\nSeed\.print expected 1 argument, got 2\nSeed\.print expected 1 argument, got 3\nSeed\.introspect expected 1 argument, got 0\nSeed\.introspect expected 1 argument, got 2\nSeed\.check_syntax expected 1 argument, got 0\nSeed\.check_syntax expected 1 argument, got 2
 // STDERR:
 
 try{
@@ -34,13 +34,6 @@
 }catch(e){Seed.print(e.message)}
 
 try{
-Seed.readline();
-}catch(e){Seed.print(e.message)}
-try{
-Seed.readline("asdf>", "something");
-}catch(e){Seed.print(e.message)}
-
-try{
 Seed.introspect();
 }catch(e){Seed.print(e.message)}
 try{

Modified: trunk/tests/readline.js
==============================================================================
--- trunk/tests/readline.js	(original)
+++ trunk/tests/readline.js	Sat Dec 20 08:21:16 2008
@@ -4,4 +4,5 @@
 // STDOUT:4.000000
 // STDERR:
 
-Seed.print(eval(Seed.readline("")));
+Seed.import_namespace("readline");
+Seed.print(eval(readline.readline("")));



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