[seed] libseed: Move Seed.fork into os module
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] libseed: Move Seed.fork into os module
- Date: Wed, 27 May 2009 04:41:44 -0400 (EDT)
commit 975b83c9a8e245c359eddd62967ec236ceaac014
Author: Robert Carr <racarr svn gnome org>
Date: Wed May 27 04:41:38 2009 -0400
libseed: Move Seed.fork into os module
---
doc/runtime.html.in | 21 ---------------------
examples/gtkplug.js | 3 ++-
libseed/seed-builtins.c | 14 --------------
modules/os/os.c | 14 ++++++++++++++
tests/javascript/fork.js | 4 ++--
5 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/doc/runtime.html.in b/doc/runtime.html.in
index 907dcd8..0a14ccb 100644
--- a/doc/runtime.html.in
+++ b/doc/runtime.html.in
@@ -139,27 +139,6 @@ catch(e){
print("Something horrible happened on line " + e.line);
}
</pre>
-<div class="section"><b>Seed.fork</b>()</div>
-<p><i>Returns: pid of child (to parent); 0 (to child)</i></p>
-<p>
-Creates a new process which is an exact copy of the current one, starting from the next instruction in both processes. It works just as <a href="http://www.opengroup.org/onlinepubs/000095399/functions/fork.html">POSIX fork</a> should.
-</p>
-<pre class="sh_javascript">
-var pid = Seed.fork();
-
-if(pid){
- // Parent
-
- while(1)
- print("From Parent");
-}
-else{
- // Child
-
- while(1)
- print("From Child");
-}
-</pre>
<div class="section"><b>Seed.stringify</b>(object)</div>
<p>
Returns a string representing the entire contents of <i>object</i> in a pretty-printed fashion, like that of JSON.
diff --git a/examples/gtkplug.js b/examples/gtkplug.js
index 6a18da3..d9bab18 100755
--- a/examples/gtkplug.js
+++ b/examples/gtkplug.js
@@ -1,10 +1,11 @@
#!/usr/bin/env seed
Gtk = imports.gi.Gtk;
Multiprocessing = imports.multiprocessing;
+os = imports.os;
var pipes = new Multiprocessing.Pipe();
-var child_pid = Seed.fork();
+var child_pid = os.fork();
if (child_pid === 0){
Gtk.init(Seed.argv);
diff --git a/libseed/seed-builtins.c b/libseed/seed-builtins.c
index 95916ce..1abf4e2 100644
--- a/libseed/seed-builtins.c
+++ b/libseed/seed-builtins.c
@@ -336,19 +336,6 @@ seed_check_syntax (JSContextRef ctx,
}
static JSValueRef
-seed_fork (JSContextRef ctx,
- JSObjectRef function,
- JSObjectRef this_object,
- size_t argumentCount,
- const JSValueRef arguments[], JSValueRef * exception)
-{
- pid_t child;
-
- child = fork ();
- return seed_value_from_int (ctx, child, exception);
-}
-
-static JSValueRef
seed_spawn (JSContextRef ctx,
JSObjectRef function,
JSObjectRef this_object,
@@ -495,7 +482,6 @@ seed_init_builtins (SeedEngine * local_eng, gint * argc, gchar *** argv)
"check_syntax", &seed_check_syntax, obj);
seed_create_function (local_eng->context,
"introspect", &seed_introspect, obj);
- seed_create_function (local_eng->context, "fork", &seed_fork, obj);
seed_create_function (local_eng->context, "spawn", &seed_spawn, obj);
seed_create_function (local_eng->context, "quit", &seed_quit, obj);
seed_create_function (local_eng->context, "breakpoint",
diff --git a/modules/os/os.c b/modules/os/os.c
index 753c452..268f53b 100644
--- a/modules/os/os.c
+++ b/modules/os/os.c
@@ -971,7 +971,21 @@ seed_os_access (SeedContext ctx,
return seed_value_from_boolean (ctx, FALSE, exception);
}
+static SeedValue
+seed_os_fork (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ pid_t t = fork();
+
+ return seed_value_from_long (ctx, t, exception);
+}
+
seed_static_function os_funcs[] = {
+ {"fork", seed_os_fork, 0},
{"chdir", seed_os_chdir, 0},
{"fchdir", seed_os_fchdir, 0},
{"getcwd", seed_os_getcwd, 0},
diff --git a/tests/javascript/fork.js b/tests/javascript/fork.js
index ba07996..bfefa24 100755
--- a/tests/javascript/fork.js
+++ b/tests/javascript/fork.js
@@ -3,8 +3,8 @@
// STDIN:
// STDOUT:[AB]\n[AB]
// STDERR:
-
-var a = Seed.fork();
+os = imports.os;
+var a = os.fork();
if(a)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]