Mercurial > osx-quasimode
changeset 8:353aee1ddf91
renamed boop() to setSize(), setSize() now passes both x and y args
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Sun, 11 Apr 2010 19:20:52 -0700 |
parents | cd9bef04e813 |
children | d8d966549380 |
files | Quasimode.m |
diffstat | 1 files changed, 21 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/Quasimode.m Sun Apr 11 19:17:08 2010 -0700 +++ b/Quasimode.m Sun Apr 11 19:20:52 2010 -0700 @@ -10,14 +10,14 @@ #import <WebKit/DOMEvents.h> #import <JavaScriptCore/JavaScriptCore.h> -void QModeClassInitialize(JSContextRef ctx, JSObjectRef object); +void QModeClassInitialize(JSContextRef ctx, JSObjectRef object); -JSValueRef boop(JSContextRef ctx, - JSObjectRef function, - JSObjectRef thisObject, - size_t argumentCount, - const JSValueRef arguments[], - JSValueRef* exception); +JSValueRef setSize(JSContextRef ctx, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception); @interface QMode : NSObject { NSWindow *window; @@ -92,27 +92,29 @@ void QModeClassInitialize(JSContextRef ctx, JSObjectRef object) { - JSStringRef boopStr = JSStringCreateWithUTF8CString("boop"); - JSObjectRef func = JSObjectMakeFunctionWithCallback(ctx, boopStr, boop); + JSStringRef setSizeStr = JSStringCreateWithUTF8CString("setSize"); + JSObjectRef func = JSObjectMakeFunctionWithCallback(ctx, setSizeStr, + setSize); - JSObjectSetProperty(ctx, object, boopStr, func, + JSObjectSetProperty(ctx, object, setSizeStr, func, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL); } -JSValueRef boop(JSContextRef ctx, - JSObjectRef function, - JSObjectRef thisObject, - size_t argumentCount, - const JSValueRef arguments[], - JSValueRef* exception) +JSValueRef setSize(JSContextRef ctx, + JSObjectRef function, + JSObjectRef thisObject, + size_t argumentCount, + const JSValueRef arguments[], + JSValueRef* exception) { - if (argumentCount >= 1 && - JSValueIsNumber(ctx, arguments[0])) { + if (argumentCount >= 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { QMode *app = (QMode *) JSObjectGetPrivate(thisObject); [app setSizeWithX: (int) JSValueToNumber(ctx, arguments[0], NULL) - Y: 0]; + Y: (int) JSValueToNumber(ctx, arguments[1], NULL)]; } return JSValueMakeUndefined(ctx); }