[seed: 1/6] Add os.lseek



commit c779c7ddd2c77e23837d371ff7d841fe6ea673b4
Author: Robert Carr <racarr mireia (none)>
Date:   Wed Apr 15 12:23:16 2009 -0400

    Add os.lseek
---
 examples/glib/timeout.js |    8 +++++---
 modules/os/os.c          |   25 ++++++++++++++++++++++++-
 2 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/examples/glib/timeout.js b/examples/glib/timeout.js
index 2ed3442..a18935e 100755
--- a/examples/glib/timeout.js
+++ b/examples/glib/timeout.js
@@ -4,15 +4,17 @@ GLib = imports.gi.GLib;
 
 count = 0;
 
-GLib.timeout_add(500,
-function()
+function test()
 {
 	count++;
 	Seed.print("Hello from timeout number " + count);
 	if (count == 5)
 		Seed.quit();
 	return true;
-},0);
+}
+
+GLib.timeout_add(500,
+test,null);
 
 // No offset/size data for GLib.MainLoop, not our fault. Have to use context right now, because mainloop has a bad typelib info.
 context = GLib.main_context_default();
diff --git a/modules/os/os.c b/modules/os/os.c
index 4bf3bd7..4acccbd 100644
--- a/modules/os/os.c
+++ b/modules/os/os.c
@@ -744,6 +744,28 @@ seed_os_isatty (SeedContext ctx,
   
   return seed_value_from_boolean (ctx, isatty (fd), exception);
 }
+
+SeedValue
+seed_os_lseek (SeedContext ctx,
+	       SeedObject function,
+	       SeedObject this_object,
+	       size_t argument_count,
+	       const SeedValue arguments[], 
+	       SeedException * exception)
+{
+  gint fd, whence;
+  off_t offset;
+
+  if (argument_count != 3)
+    {
+      EXPECTED_EXCEPTION ("os.lseek", "3 arguments");
+    }
+  fd = seed_value_to_int (ctx, arguments[0], exception);
+  offset = seed_value_to_long (ctx, arguments[1], exception);
+  whence = seed_value_to_int (ctx, arguments[2], exception);
+  
+  return seed_value_from_long (ctx, lseek (fd, offset, whence), exception);
+}
   
 seed_static_function os_funcs[] = {
   {"chdir", seed_os_chdir, 0},
@@ -779,7 +801,8 @@ seed_static_function os_funcs[] = {
   {"fpathconf", seed_os_fpathconf, 0},
   {"fsync", seed_os_fsync, 0},
   {"ftruncate", seed_os_ftruncate, 0},
-  {"isatty", seed_os_isatty, 0}
+  {"isatty", seed_os_isatty, 0},
+  {"lseek", seed_os_lseek, 0}
 };
 
 #define OS_DEFINE_ENUM(name, value) \



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