[gjs/wip/gobj-kitchen-sink: 12/23] util: Add a new format specifier to gjs_parse_args specifying a 64-bit integer



commit 9872b048a88bfb7cc08f37383495b423fd8720e5
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Jan 27 18:09:32 2012 -0500

    util: Add a new format specifier to gjs_parse_args specifying a 64-bit integer

 gjs/jsapi-util.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/gjs/jsapi-util.c b/gjs/jsapi-util.c
index 326325a..990c50d 100644
--- a/gjs/jsapi-util.c
+++ b/gjs/jsapi-util.c
@@ -1378,6 +1378,7 @@ gjs_value_to_int64  (JSContext  *context,
  * F: A string, converted into "filename encoding" (i.e. active locale)
  * i: A number, will be converted to a C "gint32"
  * u: A number, converted into a C "guint32"
+ * t: A 64-bit number, converted into a C "gint64" by way of gjs_value_to_int64()
  * o: A JavaScript object, as a "JSObject *"
  *
  * If the first character in the format string is a '!', then JS is allowed
@@ -1521,6 +1522,14 @@ gjs_parse_args (JSContext  *context,
             }
         }
             break;
+        case 't': {
+            if (!gjs_value_to_int64(context, js_value, (gint64*) arg_location)) {
+                /* Our error message is going to be more useful */
+                JS_ClearPendingException(context);
+                arg_error_message = "Couldn't convert to 64-bit integer";
+            }
+        }
+            break;
         case 'f': {
             double num;
             if (!JS_ValueToNumber(context, js_value, &num)) {



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