diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-01 19:18:36 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-01 19:18:36 (GMT) |
commit | fd0778237785840ec754f98e847a524590cbf61c (patch) | |
tree | ebf4609be11843f9657810515d47faa3873c2db8 /src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp | |
parent | 99d2c52f1068b2dd4bd16b8c1c8231beeb94a649 (diff) | |
download | uscxml-fd0778237785840ec754f98e847a524590cbf61c.zip uscxml-fd0778237785840ec754f98e847a524590cbf61c.tar.gz uscxml-fd0778237785840ec754f98e847a524590cbf61c.tar.bz2 |
More work on TypedArrays
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp index ba0b992..84ff887 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCText.cpp @@ -15,33 +15,34 @@ JSStaticFunction JSCText::staticFunctions[] = { { "splitText", splitTextCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; + JSValueRef JSCText::splitTextCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 1) { - std::string errorMsg = "Wrong number of arguments in splitText"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCTextPrivate* privData = (struct JSCTextPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - Arabica::DOM::Text<std::string>* retVal = new Arabica::DOM::Text<std::string>(privData->nativeObj->splitText(localOffset)); - JSClassRef retClass = JSCText::getTmpl(); + Arabica::DOM::Text<std::string>* retVal = new Arabica::DOM::Text<std::string>(privData->nativeObj->splitText(localOffset)); + JSClassRef retClass = JSCText::getTmpl(); - struct JSCText::JSCTextPrivate* retPrivData = new JSCText::JSCTextPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCText::JSCTextPrivate* retPrivData = new JSCText::JSCTextPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); - return retObj; + return retObj; -} + } + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling splitText"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } |