[seed] Add seed_make_array to the API



commit 752afdfc4d6791ed8ad54e6a27babe1ea3ca948a
Author: Robert Carr <racarr mireia (none)>
Date:   Mon Apr 13 20:43:14 2009 -0400

    Add seed_make_array to the API
---
 libseed/seed-api.c |    8 ++++++
 libseed/seed.h     |    3 ++
 modules/os/os.c    |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 76 insertions(+), 1 deletions(-)

diff --git a/libseed/seed-api.c b/libseed/seed-api.c
index 228cd87..0017b88 100644
--- a/libseed/seed-api.c
+++ b/libseed/seed-api.c
@@ -578,3 +578,11 @@ seed_context_get_global_object (JSGlobalContextRef ctx)
 }
 
 
+JSObjectRef
+seed_make_array (JSContextRef ctx, 
+		 const JSValueRef elements[],
+		 gsize num_elements, 
+		 JSValueRef *exception)
+{
+  return JSObjectMakeArray (ctx, num_elements, elements, exception);
+}
diff --git a/libseed/seed.h b/libseed/seed.h
index cdff2a9..a594360 100644
--- a/libseed/seed.h
+++ b/libseed/seed.h
@@ -236,6 +236,9 @@ typedef void (*SeedFunctionCallback) (SeedContext ctx,
 void seed_create_function (SeedContext ctx,
 			   gchar * name, SeedFunctionCallback callback,
 			   SeedObject object);
+/* Inconsistent naming? */
+SeedObject seed_make_array (SeedContext ctx, const SeedValue elements,
+			    gsize num_elements, SeedException *exception);
 
 typedef SeedObject (*SeedModuleInitCallback) (SeedEngine * eng);
 
diff --git a/modules/os/os.c b/modules/os/os.c
index 5cc3afa..7cf4ce1 100644
--- a/modules/os/os.c
+++ b/modules/os/os.c
@@ -137,13 +137,77 @@ seed_os_geteuid (SeedContext ctx,
   return seed_value_from_long (ctx, (glong) ret, exception);
 }
 
+SeedValue
+seed_os_getgid (SeedContext ctx,
+		 SeedObject function,
+		 SeedObject this_object,
+		 size_t argument_count,
+		 const SeedValue arguments[], 
+		 SeedException * exception)
+{
+  SeedValue seed_ret;
+  gid_t ret;
+  
+  if (argument_count != 0)
+    {
+      EXPECTED_EXCEPTION("os.getegid", "no arguments");
+    }
+  ret = getgid ();
+
+  return seed_value_from_long (ctx, (glong) ret, exception);
+}
+
+SeedValue
+seed_os_getuid (SeedContext ctx,
+		 SeedObject function,
+		 SeedObject this_object,
+		 size_t argument_count,
+		 const SeedValue arguments[], 
+		 SeedException * exception)
+{
+  SeedValue seed_ret;
+  uid_t ret;
+  
+  if (argument_count != 0)
+    {
+      EXPECTED_EXCEPTION("os.geteuid", "no arguments");
+    }
+  ret = getuid ();
+
+  return seed_value_from_long (ctx, (glong) ret, exception);
+}
+
+SeedValue
+seed_os_getgroups (SeedContext ctx,
+		   SeedObject function,
+		   SeedObject this_object,
+		   size_t argument_count,
+		   const SeedValue arguments[], 
+		   SeedException * exception)
+{
+  SeedValue seed_ret;
+  gid_t *group_list;
+  guint num_groups;
+  
+  if (argument_count != 0)
+    {
+      EXPECTED_EXCEPTION("os.geteuid", "no arguments");
+    }
+  ret = getuid ();
+
+  return seed_value_from_long (ctx, (glong) ret, exception);
+}
+
 seed_static_function os_funcs[] = {
   {"chdir", seed_os_chdir, 0},
   {"fchdir", seed_os_fchdir, 0},
   {"getcwd", seed_os_getcwd, 0},
   {"ctermid", seed_os_ctermid, 0},
   {"getegid", seed_os_getegid, 0},
-  {"geteuid", seed_os_geteuid, 0}
+  {"geteuid", seed_os_geteuid, 0},
+  {"getgid", seed_os_getgid, 0},
+  {"getuid", seed_os_getuid, 0},
+  {"getgroups", seed_os_getgroups, 0}
 };
 
 SeedObject



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