changeset 14:7a3d7ce08927

Added quasimode.log().
author Atul Varma <avarma@mozilla.com>
date Sun, 11 Apr 2010 21:54:07 -0700
parents bab79fdfa745
children 547b12bed241
files JavaScriptQuasimode.m
diffstat 1 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/JavaScriptQuasimode.m	Sun Apr 11 21:34:36 2010 -0700
+++ b/JavaScriptQuasimode.m	Sun Apr 11 21:54:07 2010 -0700
@@ -33,8 +33,29 @@
   return JSValueMakeUndefined(ctx);
 }
 
+static JSValueRef
+method_log(JSContextRef ctx,
+           JSObjectRef function,
+           JSObjectRef thisObject,
+           size_t argumentCount,
+           const JSValueRef arguments[],
+           JSValueRef* exception)
+{
+  if (argumentCount >= 1 &&
+      JSValueIsString(ctx, arguments[0])) {
+    Quasimode *quasimode = (Quasimode *) JSObjectGetPrivate(thisObject);
+    JSStringRef str = JSValueToStringCopy(ctx, arguments[0], NULL);
+    size_t len = JSStringGetMaximumUTF8CStringSize(str);
+    char buf[len];
+    JSStringGetUTF8CString(str, buf, len);
+    printf("%s\n", buf);
+  }
+  return JSValueMakeUndefined(ctx);
+}
+
 static JSQuasimodeMethod jsQuasimodeMethods[] = {
   {"setSize", method_setSize},
+  {"log", method_log},
   {NULL, NULL}
 };