diff options
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore')
41 files changed, 3964 insertions, 1999 deletions
diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h index e88851e..5953c0e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h @@ -31,6 +31,7 @@ public: virtual ~JSCDOM(); uscxml::Storage* storage; Arabica::XPath::XPath<std::string>* xpath; + }; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp index c714735..173a0ed 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDataModel.cpp @@ -8,6 +8,18 @@ #include "dom/JSCCDATASection.h" #include "dom/JSCSCXMLEvent.h" +#include "dom/JSCArrayBuffer.h" +#include "dom/JSCInt8Array.h" +#include "dom/JSCUint8Array.h" +#include "dom/JSCUint8ClampedArray.h" +#include "dom/JSCInt16Array.h" +#include "dom/JSCUint16Array.h" +#include "dom/JSCInt32Array.h" +#include "dom/JSCUint32Array.h" +#include "dom/JSCFloat32Array.h" +#include "dom/JSCFloat64Array.h" +#include "dom/JSCDataView.h" + #include "uscxml/Message.h" #include <glog/logging.h> @@ -22,6 +34,12 @@ privData->nativeObj = new type<std::string>(node); \ JSObjectRef retObj = JSObjectMake(_ctx, JSC##type::getTmpl(), privData);\ return retObj; +#define JSC_ADD_GLOBAL_OBJECT(name, constructor)\ +JSStringRef name##Name = JSStringCreateWithUTF8CString(#name);\ +JSObjectRef name = JSObjectMake(dm->_ctx, constructor, NULL);\ +JSObjectSetProperty(dm->_ctx, JSContextGetGlobalObject(dm->_ctx), name##Name, name, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete, NULL);\ +JSStringRelease(name##Name); + namespace uscxml { using namespace Arabica::XPath; @@ -127,6 +145,18 @@ boost::shared_ptr<DataModelImpl> JSCDataModel::create(InterpreterImpl* interpret JSStringRelease(sessionIdName); JSStringRelease(sessionId); + JSC_ADD_GLOBAL_OBJECT(ArrayBuffer, JSCArrayBuffer::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Int8Array, JSCInt8Array::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Uint8Array, JSCUint8Array::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Uint8ClampedArray, JSCUint8ClampedArray::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Int16Array, JSCInt16Array::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Uint16Array, JSCUint16Array::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Int32Array, JSCInt32Array::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Uint32Array, JSCUint32Array::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Float32Array, JSCFloat32Array::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(Float64Array, JSCFloat64Array::getTmpl()); + JSC_ADD_GLOBAL_OBJECT(DataView, JSCDataView::getTmpl()); + JSCDocument::JSCDocumentPrivate* privData = new JSCDocument::JSCDocumentPrivate(); if (interpreter) { privData->nativeObj = new Document<std::string>(interpreter->getDocument()); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp index 39c8dab..a7c27e1 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.cpp @@ -17,60 +17,105 @@ JSStaticFunction JSCArrayBuffer::staticFunctions[] = { { 0, 0, 0 } }; +JSObjectRef JSCArrayBuffer::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::ArrayBuffer* localInstance = NULL; + + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::ArrayBuffer(localLength); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for ArrayBuffer"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCArrayBuffer::getTmpl(); + + struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCArrayBuffer::byteLengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(object); return JSValueMakeNumber(ctx, privData->nativeObj->getByteLength()); } + JSValueRef JSCArrayBuffer::sliceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in slice"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(thisObj); - long localBegin = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localBegin = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin, localEnd)); - JSClassRef retClass = JSCArrayBuffer::getTmpl(); + uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin, localEnd)); + JSClassRef retClass = JSCArrayBuffer::getTmpl(); - struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); - return retObj; + return retObj; + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + long localBegin = (long)JSValueToNumber(ctx, arguments[0], exception); + + uscxml::ArrayBuffer* retVal = new uscxml::ArrayBuffer(privData->nativeObj->slice(localBegin)); + JSClassRef retClass = JSCArrayBuffer::getTmpl(); + + struct JSCArrayBuffer::JSCArrayBufferPrivate* retPrivData = new JSCArrayBuffer::JSCArrayBufferPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; + + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling slice"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCArrayBuffer::isViewCallback(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 isView"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCArrayBufferPrivate* privData = (struct JSCArrayBufferPrivate*)JSObjectGetPrivate(thisObj); - void* localValue = JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)); + if (false) { + } else if (argumentCount == 1 && + true) { + void* localValue = JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)); - bool retVal = privData->nativeObj->isView(localValue); + bool retVal = privData->nativeObj->isView(localValue); - JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); - return jscRetVal; -} + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; + } + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling isView"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h index e3e7a14..b3fa8ea 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBuffer.h @@ -42,7 +42,11 @@ public: static JSValueRef sliceCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef isViewCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef byteLengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -55,6 +59,10 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.cpp index f599aff..031bed5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCArrayBufferView.cpp @@ -30,7 +30,7 @@ JSValueRef JSCArrayBufferView::bufferAttrGetter(JSContextRef ctx, JSObjectRef ob retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp index 3f967dd..e870216 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCAttr.cpp @@ -74,7 +74,7 @@ JSValueRef JSCAttr::ownerElementAttrGetter(JSContextRef ctx, JSObjectRef object, retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp index f64b4c9..1b87bcc 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCCharacterData.cpp @@ -53,134 +53,144 @@ JSValueRef JSCCharacterData::lengthAttrGetter(JSContextRef ctx, JSObjectRef obje return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); } + JSValueRef JSCCharacterData::substringDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in substringData"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCCharacterDataPrivate* privData = (struct JSCCharacterDataPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned long localCount = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned long localCount = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); - std::string retVal = privData->nativeObj->substringData(localOffset, localCount); + std::string retVal = privData->nativeObj->substringData(localOffset, localCount); - JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); - JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); - JSStringRelease(jscString); - return jscRetVal; + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling substringData"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCCharacterData::appendDataCallback(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 appendData"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCCharacterDataPrivate* privData = (struct JSCCharacterDataPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg); - char* localArgBuffer = new char[localArgMaxSize]; - JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize); - std::string localArg(localArgBuffer); - JSStringRelease(stringReflocalArg); - free(localArgBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg); + char* localArgBuffer = new char[localArgMaxSize]; + JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize); + std::string localArg(localArgBuffer); + JSStringRelease(stringReflocalArg); + free(localArgBuffer); - privData->nativeObj->appendData(localArg); + privData->nativeObj->appendData(localArg); - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling appendData"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCCharacterData::insertDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in insertData"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCCharacterDataPrivate* privData = (struct JSCCharacterDataPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg); - char* localArgBuffer = new char[localArgMaxSize]; - JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize); - std::string localArg(localArgBuffer); - JSStringRelease(stringReflocalArg); - free(localArgBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg); + char* localArgBuffer = new char[localArgMaxSize]; + JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize); + std::string localArg(localArgBuffer); + JSStringRelease(stringReflocalArg); + free(localArgBuffer); + + privData->nativeObj->insertData(localOffset, localArg); - privData->nativeObj->insertData(localOffset, localArg); + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling insertData"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCCharacterData::deleteDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in deleteData"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCCharacterDataPrivate* privData = (struct JSCCharacterDataPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned long localCount = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned long localCount = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); - privData->nativeObj->deleteData(localOffset, localCount); + privData->nativeObj->deleteData(localOffset, localCount); - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling deleteData"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCCharacterData::replaceDataCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in replaceData"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCCharacterDataPrivate* privData = (struct JSCCharacterDataPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned long localCount = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); - JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[2], exception); - size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg); - char* localArgBuffer = new char[localArgMaxSize]; - JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize); - std::string localArg(localArgBuffer); - JSStringRelease(stringReflocalArg); - free(localArgBuffer); - - - privData->nativeObj->replaceData(localOffset, localCount, localArg); + if (false) { + } else if (argumentCount == 3 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsString(ctx, arguments[2])) { + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned long localCount = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + JSStringRef stringReflocalArg = JSValueToStringCopy(ctx, arguments[2], exception); + size_t localArgMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalArg); + char* localArgBuffer = new char[localArgMaxSize]; + JSStringGetUTF8CString(stringReflocalArg, localArgBuffer, localArgMaxSize); + std::string localArg(localArgBuffer); + JSStringRelease(stringReflocalArg); + free(localArgBuffer); + + + privData->nativeObj->replaceData(localOffset, localCount, localArg); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling replaceData"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } - } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp index 72d4beb..81b3e46 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp @@ -18,134 +18,142 @@ JSStaticFunction JSCDOMImplementation::staticFunctions[] = { { "createDocument", createDocumentCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; + JSValueRef JSCDOMImplementation::hasFeatureCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in hasFeature"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDOMImplementationPrivate* privData = (struct JSCDOMImplementationPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalFeature = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localFeatureMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalFeature); - char* localFeatureBuffer = new char[localFeatureMaxSize]; - JSStringGetUTF8CString(stringReflocalFeature, localFeatureBuffer, localFeatureMaxSize); - std::string localFeature(localFeatureBuffer); - JSStringRelease(stringReflocalFeature); - free(localFeatureBuffer); - - JSStringRef stringReflocalVersion = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localVersionMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalVersion); - char* localVersionBuffer = new char[localVersionMaxSize]; - JSStringGetUTF8CString(stringReflocalVersion, localVersionBuffer, localVersionMaxSize); - std::string localVersion(localVersionBuffer); - JSStringRelease(stringReflocalVersion); - free(localVersionBuffer); - - - bool retVal = privData->nativeObj->hasFeature(localFeature, localVersion); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalFeature = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localFeatureMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalFeature); + char* localFeatureBuffer = new char[localFeatureMaxSize]; + JSStringGetUTF8CString(stringReflocalFeature, localFeatureBuffer, localFeatureMaxSize); + std::string localFeature(localFeatureBuffer); + JSStringRelease(stringReflocalFeature); + free(localFeatureBuffer); + + JSStringRef stringReflocalVersion = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localVersionMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalVersion); + char* localVersionBuffer = new char[localVersionMaxSize]; + JSStringGetUTF8CString(stringReflocalVersion, localVersionBuffer, localVersionMaxSize); + std::string localVersion(localVersionBuffer); + JSStringRelease(stringReflocalVersion); + free(localVersionBuffer); + + + bool retVal = privData->nativeObj->hasFeature(localFeature, localVersion); + + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling hasFeature"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDOMImplementation::createDocumentTypeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in createDocumentType"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDOMImplementationPrivate* privData = (struct JSCDOMImplementationPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); - char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; - JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); - std::string localQualifiedName(localQualifiedNameBuffer); - JSStringRelease(stringReflocalQualifiedName); - free(localQualifiedNameBuffer); - - JSStringRef stringReflocalPublicId = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localPublicIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalPublicId); - char* localPublicIdBuffer = new char[localPublicIdMaxSize]; - JSStringGetUTF8CString(stringReflocalPublicId, localPublicIdBuffer, localPublicIdMaxSize); - std::string localPublicId(localPublicIdBuffer); - JSStringRelease(stringReflocalPublicId); - free(localPublicIdBuffer); - - JSStringRef stringReflocalSystemId = JSValueToStringCopy(ctx, arguments[2], exception); - size_t localSystemIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalSystemId); - char* localSystemIdBuffer = new char[localSystemIdMaxSize]; - JSStringGetUTF8CString(stringReflocalSystemId, localSystemIdBuffer, localSystemIdMaxSize); - std::string localSystemId(localSystemIdBuffer); - JSStringRelease(stringReflocalSystemId); - free(localSystemIdBuffer); + if (false) { + } else if (argumentCount == 3 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1]) && + JSValueIsString(ctx, arguments[2])) { + JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); + char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; + JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); + std::string localQualifiedName(localQualifiedNameBuffer); + JSStringRelease(stringReflocalQualifiedName); + free(localQualifiedNameBuffer); + + JSStringRef stringReflocalPublicId = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localPublicIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalPublicId); + char* localPublicIdBuffer = new char[localPublicIdMaxSize]; + JSStringGetUTF8CString(stringReflocalPublicId, localPublicIdBuffer, localPublicIdMaxSize); + std::string localPublicId(localPublicIdBuffer); + JSStringRelease(stringReflocalPublicId); + free(localPublicIdBuffer); + + JSStringRef stringReflocalSystemId = JSValueToStringCopy(ctx, arguments[2], exception); + size_t localSystemIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalSystemId); + char* localSystemIdBuffer = new char[localSystemIdMaxSize]; + JSStringGetUTF8CString(stringReflocalSystemId, localSystemIdBuffer, localSystemIdMaxSize); + std::string localSystemId(localSystemIdBuffer); + JSStringRelease(stringReflocalSystemId); + free(localSystemIdBuffer); + + + Arabica::DOM::DocumentType<std::string>* retVal = new Arabica::DOM::DocumentType<std::string>(privData->nativeObj->createDocumentType(localQualifiedName, localPublicId, localSystemId)); + JSClassRef retClass = JSCDocumentType::getTmpl(); + + struct JSCDocumentType::JSCDocumentTypePrivate* retPrivData = new JSCDocumentType::JSCDocumentTypePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + + return retObj; + } - Arabica::DOM::DocumentType<std::string>* retVal = new Arabica::DOM::DocumentType<std::string>(privData->nativeObj->createDocumentType(localQualifiedName, localPublicId, localSystemId)); - JSClassRef retClass = JSCDocumentType::getTmpl(); - - struct JSCDocumentType::JSCDocumentTypePrivate* retPrivData = new JSCDocumentType::JSCDocumentTypePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; - - JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); - - return retObj; - + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling createDocumentType"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDOMImplementation::createDocumentCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in createDocument"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDOMImplementationPrivate* privData = (struct JSCDOMImplementationPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); + if (false) { + } else if (argumentCount == 3 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1]) && + JSValueIsObject(ctx, arguments[2]) && JSValueIsObjectOfClass(ctx, arguments[2], JSCDocumentType::getTmpl())) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); - JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); - char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; - JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); - std::string localQualifiedName(localQualifiedNameBuffer); - JSStringRelease(stringReflocalQualifiedName); - free(localQualifiedNameBuffer); + JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); + char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; + JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); + std::string localQualifiedName(localQualifiedNameBuffer); + JSStringRelease(stringReflocalQualifiedName); + free(localQualifiedNameBuffer); - Arabica::DOM::DocumentType<std::string>* localDoctype = ((struct JSCDocumentType::JSCDocumentTypePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[2], exception)))->nativeObj; + Arabica::DOM::DocumentType<std::string>* localDoctype = ((struct JSCDocumentType::JSCDocumentTypePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[2], exception)))->nativeObj; - Arabica::DOM::Document<std::string>* retVal = new Arabica::DOM::Document<std::string>(privData->nativeObj->createDocument(localNamespaceURI, localQualifiedName, *localDoctype)); - JSClassRef retClass = JSCDocument::getTmpl(); + Arabica::DOM::Document<std::string>* retVal = new Arabica::DOM::Document<std::string>(privData->nativeObj->createDocument(localNamespaceURI, localQualifiedName, *localDoctype)); + JSClassRef retClass = JSCDocument::getTmpl(); - struct JSCDocument::JSCDocumentPrivate* retPrivData = new JSCDocument::JSCDocumentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCDocument::JSCDocumentPrivate* retPrivData = new JSCDocument::JSCDocumentPrivate(); + 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 createDocument"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.cpp index 5e6ee80..530e157 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCDataView.h" namespace Arabica { @@ -29,346 +31,535 @@ JSStaticFunction JSCDataView::staticFunctions[] = { { "setFloat64", setFloat64Callback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; -JSValueRef JSCDataView::getInt8Callback(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 getInt8"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; + +JSObjectRef JSCDataView::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::DataView* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localByteLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::DataView(localBuffer, localByteOffset, localByteLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::DataView(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::DataView(localBuffer); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for DataView"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); } + JSClassRef retClass = JSCDataView::getTmpl(); + + struct JSCDataView::JSCDataViewPrivate* retPrivData = new JSCDataView::JSCDataViewPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + +JSValueRef JSCDataView::getInt8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { + struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + + char retVal = privData->nativeObj->getInt8(localByteOffset); - char retVal = privData->nativeObj->getInt8(localByteOffset); + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getInt8"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::getUint8Callback(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 getUint8"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - char retVal = privData->nativeObj->getUint8(localByteOffset); + unsigned char retVal = privData->nativeObj->getUint8(localByteOffset); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getUint8"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::getInt16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getInt16"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsBoolean(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + short retVal = privData->nativeObj->getInt16(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - short retVal = privData->nativeObj->getInt16(localByteOffset, localLittleEndian); + short retVal = privData->nativeObj->getInt16(localByteOffset); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getInt16"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::getUint16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getUint16"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsBoolean(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + unsigned short retVal = privData->nativeObj->getUint16(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned short retVal = privData->nativeObj->getUint16(localByteOffset, localLittleEndian); + unsigned short retVal = privData->nativeObj->getUint16(localByteOffset); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getUint16"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::getInt32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getInt32"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsBoolean(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + long retVal = privData->nativeObj->getInt32(localByteOffset, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - long retVal = privData->nativeObj->getInt32(localByteOffset, localLittleEndian); + long retVal = privData->nativeObj->getInt32(localByteOffset); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getInt32"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::getUint32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getUint32"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsBoolean(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + unsigned long retVal = privData->nativeObj->getUint32(localByteOffset, localLittleEndian); - unsigned long retVal = privData->nativeObj->getUint32(localByteOffset, localLittleEndian); + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + unsigned long retVal = privData->nativeObj->getUint32(localByteOffset); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getUint32"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::getFloat32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getFloat32"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsBoolean(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + float retVal = privData->nativeObj->getFloat32(localByteOffset, localLittleEndian); - float retVal = privData->nativeObj->getFloat32(localByteOffset, localLittleEndian); + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + float retVal = privData->nativeObj->getFloat32(localByteOffset); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getFloat32"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::getFloat64Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getFloat64"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsBoolean(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[1]); + + double retVal = privData->nativeObj->getFloat64(localByteOffset, localLittleEndian); - double retVal = privData->nativeObj->getFloat64(localByteOffset, localLittleEndian); + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + double retVal = privData->nativeObj->getFloat64(localByteOffset); + + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getFloat64"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::setInt8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in setInt8"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); - privData->nativeObj->setInt8(localByteOffset, localValue); + privData->nativeObj->setInt8(localByteOffset, localValue); - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setInt8"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::setUint8Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in setUint8"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned char localValue = (unsigned char)JSValueToNumber(ctx, arguments[1], exception); - privData->nativeObj->setUint8(localByteOffset, localValue); + privData->nativeObj->setUint8(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setUint8"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::setInt16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in setInt16"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - short localValue = (short)JSValueToNumber(ctx, arguments[1], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); - - privData->nativeObj->setInt16(localByteOffset, localValue, localLittleEndian); + if (false) { + } else if (argumentCount == 3 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsBoolean(ctx, arguments[2])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + short localValue = (short)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setInt16(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + short localValue = (short)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->setInt16(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setInt16"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::setUint16Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in setUint16"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned short localValue = (unsigned short)JSValueToNumber(ctx, arguments[1], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); - - privData->nativeObj->setUint16(localByteOffset, localValue, localLittleEndian); + if (false) { + } else if (argumentCount == 3 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsBoolean(ctx, arguments[2])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned short localValue = (unsigned short)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setUint16(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned short localValue = (unsigned short)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->setUint16(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setUint16"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::setInt32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in setInt32"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - long localValue = (long)JSValueToNumber(ctx, arguments[1], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); - - privData->nativeObj->setInt32(localByteOffset, localValue, localLittleEndian); + if (false) { + } else if (argumentCount == 3 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsBoolean(ctx, arguments[2])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + long localValue = (long)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setInt32(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + long localValue = (long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->setInt32(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setInt32"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::setUint32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in setUint32"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned long localValue = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); - - privData->nativeObj->setUint32(localByteOffset, localValue, localLittleEndian); + if (false) { + } else if (argumentCount == 3 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsBoolean(ctx, arguments[2])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned long localValue = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setUint32(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned long localValue = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->setUint32(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setUint32"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::setFloat32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in setFloat32"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - float localValue = (float)JSValueToNumber(ctx, arguments[1], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); - - privData->nativeObj->setFloat32(localByteOffset, localValue, localLittleEndian); + if (false) { + } else if (argumentCount == 3 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsBoolean(ctx, arguments[2])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + float localValue = (float)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setFloat32(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + float localValue = (float)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->setFloat32(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setFloat32"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDataView::setFloat64Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in setFloat64"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDataViewPrivate* privData = (struct JSCDataViewPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - double localValue = (double)JSValueToNumber(ctx, arguments[1], exception); - bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); - - privData->nativeObj->setFloat64(localByteOffset, localValue, localLittleEndian); + if (false) { + } else if (argumentCount == 3 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsBoolean(ctx, arguments[2])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + double localValue = (double)JSValueToNumber(ctx, arguments[1], exception); + bool localLittleEndian = JSValueToBoolean(ctx, arguments[2]); + + privData->nativeObj->setFloat64(localByteOffset, localValue, localLittleEndian); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + double localValue = (double)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->setFloat64(localByteOffset, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setFloat64"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } - } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.h index 4d37120..e63805a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDataView.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -56,6 +57,7 @@ public: static JSValueRef setFloat32Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef setFloat64Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSStaticValue staticValues[]; @@ -68,6 +70,8 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp index a7f170f..a80bad8 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocument.cpp @@ -57,7 +57,7 @@ JSValueRef JSCDocument::doctypeAttrGetter(JSContextRef ctx, JSObjectRef object, retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -74,7 +74,7 @@ JSValueRef JSCDocument::implementationAttrGetter(JSContextRef ctx, JSObjectRef o retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -91,496 +91,522 @@ JSValueRef JSCDocument::documentElementAttrGetter(JSContextRef ctx, JSObjectRef retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } + JSValueRef JSCDocument::createElementCallback(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 createElement"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalTagName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localTagNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTagName); - char* localTagNameBuffer = new char[localTagNameMaxSize]; - JSStringGetUTF8CString(stringReflocalTagName, localTagNameBuffer, localTagNameMaxSize); - std::string localTagName(localTagNameBuffer); - JSStringRelease(stringReflocalTagName); - free(localTagNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalTagName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localTagNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTagName); + char* localTagNameBuffer = new char[localTagNameMaxSize]; + JSStringGetUTF8CString(stringReflocalTagName, localTagNameBuffer, localTagNameMaxSize); + std::string localTagName(localTagNameBuffer); + JSStringRelease(stringReflocalTagName); + free(localTagNameBuffer); - Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->createElement(localTagName)); - JSClassRef retClass = JSCElement::getTmpl(); + Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->createElement(localTagName)); + JSClassRef retClass = JSCElement::getTmpl(); - struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate(); + 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 createElement"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createDocumentFragmentCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { - Arabica::DOM::DocumentFragment<std::string>* retVal = new Arabica::DOM::DocumentFragment<std::string>(privData->nativeObj->createDocumentFragment()); - JSClassRef retClass = JSCDocumentFragment::getTmpl(); + Arabica::DOM::DocumentFragment<std::string>* retVal = new Arabica::DOM::DocumentFragment<std::string>(privData->nativeObj->createDocumentFragment()); + JSClassRef retClass = JSCDocumentFragment::getTmpl(); - struct JSCDocumentFragment::JSCDocumentFragmentPrivate* retPrivData = new JSCDocumentFragment::JSCDocumentFragmentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCDocumentFragment::JSCDocumentFragmentPrivate* retPrivData = new JSCDocumentFragment::JSCDocumentFragmentPrivate(); + 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 createDocumentFragment"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createTextNodeCallback(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 createTextNode"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData); - char* localDataBuffer = new char[localDataMaxSize]; - JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize); - std::string localData(localDataBuffer); - JSStringRelease(stringReflocalData); - free(localDataBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData); + char* localDataBuffer = new char[localDataMaxSize]; + JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize); + std::string localData(localDataBuffer); + JSStringRelease(stringReflocalData); + free(localDataBuffer); - Arabica::DOM::Text<std::string>* retVal = new Arabica::DOM::Text<std::string>(privData->nativeObj->createTextNode(localData)); - JSClassRef retClass = JSCText::getTmpl(); + Arabica::DOM::Text<std::string>* retVal = new Arabica::DOM::Text<std::string>(privData->nativeObj->createTextNode(localData)); + 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 createTextNode"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createCommentCallback(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 createComment"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData); - char* localDataBuffer = new char[localDataMaxSize]; - JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize); - std::string localData(localDataBuffer); - JSStringRelease(stringReflocalData); - free(localDataBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData); + char* localDataBuffer = new char[localDataMaxSize]; + JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize); + std::string localData(localDataBuffer); + JSStringRelease(stringReflocalData); + free(localDataBuffer); - Arabica::DOM::Comment<std::string>* retVal = new Arabica::DOM::Comment<std::string>(privData->nativeObj->createComment(localData)); - JSClassRef retClass = JSCComment::getTmpl(); + Arabica::DOM::Comment<std::string>* retVal = new Arabica::DOM::Comment<std::string>(privData->nativeObj->createComment(localData)); + JSClassRef retClass = JSCComment::getTmpl(); - struct JSCComment::JSCCommentPrivate* retPrivData = new JSCComment::JSCCommentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCComment::JSCCommentPrivate* retPrivData = new JSCComment::JSCCommentPrivate(); + 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 createComment"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createCDATASectionCallback(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 createCDATASection"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData); - char* localDataBuffer = new char[localDataMaxSize]; - JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize); - std::string localData(localDataBuffer); - JSStringRelease(stringReflocalData); - free(localDataBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData); + char* localDataBuffer = new char[localDataMaxSize]; + JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize); + std::string localData(localDataBuffer); + JSStringRelease(stringReflocalData); + free(localDataBuffer); - Arabica::DOM::CDATASection<std::string>* retVal = new Arabica::DOM::CDATASection<std::string>(privData->nativeObj->createCDATASection(localData)); - JSClassRef retClass = JSCCDATASection::getTmpl(); + Arabica::DOM::CDATASection<std::string>* retVal = new Arabica::DOM::CDATASection<std::string>(privData->nativeObj->createCDATASection(localData)); + JSClassRef retClass = JSCCDATASection::getTmpl(); - struct JSCCDATASection::JSCCDATASectionPrivate* retPrivData = new JSCCDATASection::JSCCDATASectionPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCCDATASection::JSCCDATASectionPrivate* retPrivData = new JSCCDATASection::JSCCDATASectionPrivate(); + 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 createCDATASection"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createProcessingInstructionCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in createProcessingInstruction"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalTarget = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localTargetMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTarget); - char* localTargetBuffer = new char[localTargetMaxSize]; - JSStringGetUTF8CString(stringReflocalTarget, localTargetBuffer, localTargetMaxSize); - std::string localTarget(localTargetBuffer); - JSStringRelease(stringReflocalTarget); - free(localTargetBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalTarget = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localTargetMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTarget); + char* localTargetBuffer = new char[localTargetMaxSize]; + JSStringGetUTF8CString(stringReflocalTarget, localTargetBuffer, localTargetMaxSize); + std::string localTarget(localTargetBuffer); + JSStringRelease(stringReflocalTarget); + free(localTargetBuffer); - JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData); - char* localDataBuffer = new char[localDataMaxSize]; - JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize); - std::string localData(localDataBuffer); - JSStringRelease(stringReflocalData); - free(localDataBuffer); + JSStringRef stringReflocalData = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localDataMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalData); + char* localDataBuffer = new char[localDataMaxSize]; + JSStringGetUTF8CString(stringReflocalData, localDataBuffer, localDataMaxSize); + std::string localData(localDataBuffer); + JSStringRelease(stringReflocalData); + free(localDataBuffer); - Arabica::DOM::ProcessingInstruction<std::string>* retVal = new Arabica::DOM::ProcessingInstruction<std::string>(privData->nativeObj->createProcessingInstruction(localTarget, localData)); - JSClassRef retClass = JSCProcessingInstruction::getTmpl(); + Arabica::DOM::ProcessingInstruction<std::string>* retVal = new Arabica::DOM::ProcessingInstruction<std::string>(privData->nativeObj->createProcessingInstruction(localTarget, localData)); + JSClassRef retClass = JSCProcessingInstruction::getTmpl(); - struct JSCProcessingInstruction::JSCProcessingInstructionPrivate* retPrivData = new JSCProcessingInstruction::JSCProcessingInstructionPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCProcessingInstruction::JSCProcessingInstructionPrivate* retPrivData = new JSCProcessingInstruction::JSCProcessingInstructionPrivate(); + 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 createProcessingInstruction"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createAttributeCallback(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 createAttribute"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->createAttribute(localName)); - JSClassRef retClass = JSCAttr::getTmpl(); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->createAttribute(localName)); + JSClassRef retClass = JSCAttr::getTmpl(); - struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); + 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 createAttribute"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createEntityReferenceCallback(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 createEntityReference"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); - Arabica::DOM::EntityReference<std::string>* retVal = new Arabica::DOM::EntityReference<std::string>(privData->nativeObj->createEntityReference(localName)); - JSClassRef retClass = JSCEntityReference::getTmpl(); + Arabica::DOM::EntityReference<std::string>* retVal = new Arabica::DOM::EntityReference<std::string>(privData->nativeObj->createEntityReference(localName)); + JSClassRef retClass = JSCEntityReference::getTmpl(); - struct JSCEntityReference::JSCEntityReferencePrivate* retPrivData = new JSCEntityReference::JSCEntityReferencePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCEntityReference::JSCEntityReferencePrivate* retPrivData = new JSCEntityReference::JSCEntityReferencePrivate(); + 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 createEntityReference"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::getElementsByTagNameCallback(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 getElementsByTagName"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalTagname = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localTagnameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTagname); - char* localTagnameBuffer = new char[localTagnameMaxSize]; - JSStringGetUTF8CString(stringReflocalTagname, localTagnameBuffer, localTagnameMaxSize); - std::string localTagname(localTagnameBuffer); - JSStringRelease(stringReflocalTagname); - free(localTagnameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalTagname = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localTagnameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalTagname); + char* localTagnameBuffer = new char[localTagnameMaxSize]; + JSStringGetUTF8CString(stringReflocalTagname, localTagnameBuffer, localTagnameMaxSize); + std::string localTagname(localTagnameBuffer); + JSStringRelease(stringReflocalTagname); + free(localTagnameBuffer); - Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagName(localTagname)); - JSClassRef retClass = JSCNodeList::getTmpl(); + Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagName(localTagname)); + JSClassRef retClass = JSCNodeList::getTmpl(); - struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); + 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 getElementsByTagName"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::importNodeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in importNode"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Node<std::string>* localImportedNode = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; - bool localDeep = JSValueToBoolean(ctx, arguments[1]); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCNode::getTmpl()) && + JSValueIsBoolean(ctx, arguments[1])) { + Arabica::DOM::Node<std::string>* localImportedNode = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + bool localDeep = JSValueToBoolean(ctx, arguments[1]); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->importNode(*localImportedNode, localDeep)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->importNode(*localImportedNode, localDeep)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 importNode"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createElementNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in createElementNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); - JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); - char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; - JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); - std::string localQualifiedName(localQualifiedNameBuffer); - JSStringRelease(stringReflocalQualifiedName); - free(localQualifiedNameBuffer); + JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); + char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; + JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); + std::string localQualifiedName(localQualifiedNameBuffer); + JSStringRelease(stringReflocalQualifiedName); + free(localQualifiedNameBuffer); - Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->createElementNS(localNamespaceURI, localQualifiedName)); - JSClassRef retClass = JSCElement::getTmpl(); + Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->createElementNS(localNamespaceURI, localQualifiedName)); + JSClassRef retClass = JSCElement::getTmpl(); - struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate(); + 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 createElementNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::createAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in createAttributeNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); - JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); - char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; - JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); - std::string localQualifiedName(localQualifiedNameBuffer); - JSStringRelease(stringReflocalQualifiedName); - free(localQualifiedNameBuffer); + JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); + char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; + JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); + std::string localQualifiedName(localQualifiedNameBuffer); + JSStringRelease(stringReflocalQualifiedName); + free(localQualifiedNameBuffer); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->createAttributeNS(localNamespaceURI, localQualifiedName)); - JSClassRef retClass = JSCAttr::getTmpl(); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->createAttributeNS(localNamespaceURI, localQualifiedName)); + JSClassRef retClass = JSCAttr::getTmpl(); - struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); + 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 createAttributeNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::getElementsByTagNameNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getElementsByTagNameNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); - JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); - char* localLocalNameBuffer = new char[localLocalNameMaxSize]; - JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); - std::string localLocalName(localLocalNameBuffer); - JSStringRelease(stringReflocalLocalName); - free(localLocalNameBuffer); + JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); + char* localLocalNameBuffer = new char[localLocalNameMaxSize]; + JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); + std::string localLocalName(localLocalNameBuffer); + JSStringRelease(stringReflocalLocalName); + free(localLocalNameBuffer); - Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagNameNS(localNamespaceURI, localLocalName)); - JSClassRef retClass = JSCNodeList::getTmpl(); + Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagNameNS(localNamespaceURI, localLocalName)); + JSClassRef retClass = JSCNodeList::getTmpl(); - struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); + 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 getElementsByTagNameNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCDocument::getElementByIdCallback(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 getElementById"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCDocumentPrivate* privData = (struct JSCDocumentPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalElementId = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localElementIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalElementId); - char* localElementIdBuffer = new char[localElementIdMaxSize]; - JSStringGetUTF8CString(stringReflocalElementId, localElementIdBuffer, localElementIdMaxSize); - std::string localElementId(localElementIdBuffer); - JSStringRelease(stringReflocalElementId); - free(localElementIdBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalElementId = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localElementIdMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalElementId); + char* localElementIdBuffer = new char[localElementIdMaxSize]; + JSStringGetUTF8CString(stringReflocalElementId, localElementIdBuffer, localElementIdMaxSize); + std::string localElementId(localElementIdBuffer); + JSStringRelease(stringReflocalElementId); + free(localElementIdBuffer); - Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->getElementById(localElementId)); - JSClassRef retClass = JSCElement::getTmpl(); + Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->getElementById(localElementId)); + JSClassRef retClass = JSCElement::getTmpl(); - struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCElement::JSCElementPrivate* retPrivData = new JSCElement::JSCElementPrivate(); + 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 getElementById"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp index 954f748..b57424f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDocumentType.cpp @@ -44,7 +44,7 @@ JSValueRef JSCDocumentType::entitiesAttrGetter(JSContextRef ctx, JSObjectRef obj retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -61,7 +61,7 @@ JSValueRef JSCDocumentType::notationsAttrGetter(JSContextRef ctx, JSObjectRef ob retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp index e0b403f..5bf50cf 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCElement.cpp @@ -42,507 +42,530 @@ JSValueRef JSCElement::tagNameAttrGetter(JSContextRef ctx, JSObjectRef object, J return retVal; } + JSValueRef JSCElement::getAttributeCallback(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 getAttribute"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); - std::string retVal = privData->nativeObj->getAttribute(localName); + std::string retVal = privData->nativeObj->getAttribute(localName); + + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); + return jscRetVal; + } - JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); - JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); - JSStringRelease(jscString); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getAttribute"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::setAttributeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in setAttribute"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); - - JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue); - char* localValueBuffer = new char[localValueMaxSize]; - JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize); - std::string localValue(localValueBuffer); - JSStringRelease(stringReflocalValue); - free(localValueBuffer); - - - privData->nativeObj->setAttribute(localName, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); + + JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue); + char* localValueBuffer = new char[localValueMaxSize]; + JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize); + std::string localValue(localValueBuffer); + JSStringRelease(stringReflocalValue); + free(localValueBuffer); + + + privData->nativeObj->setAttribute(localName, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setAttribute"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::removeAttributeCallback(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 removeAttribute"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); - privData->nativeObj->removeAttribute(localName); + privData->nativeObj->removeAttribute(localName); - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling removeAttribute"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::getAttributeNodeCallback(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 getAttributeNode"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->getAttributeNode(localName)); - JSClassRef retClass = JSCAttr::getTmpl(); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->getAttributeNode(localName)); + JSClassRef retClass = JSCAttr::getTmpl(); - struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); + 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 getAttributeNode"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::setAttributeNodeCallback(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 setAttributeNode"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Attr<std::string>* localNewAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCAttr::getTmpl())) { + Arabica::DOM::Attr<std::string>* localNewAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNode(*localNewAttr)); - JSClassRef retClass = JSCAttr::getTmpl(); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNode(*localNewAttr)); + JSClassRef retClass = JSCAttr::getTmpl(); - struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); + 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 setAttributeNode"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::removeAttributeNodeCallback(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 removeAttributeNode"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Attr<std::string>* localOldAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCAttr::getTmpl())) { + Arabica::DOM::Attr<std::string>* localOldAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->removeAttributeNode(*localOldAttr)); + JSClassRef retClass = JSCAttr::getTmpl(); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->removeAttributeNode(*localOldAttr)); - JSClassRef retClass = JSCAttr::getTmpl(); + struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); - 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 removeAttributeNode"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::getElementsByTagNameCallback(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 getElementsByTagName"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); + + Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagName(localName)); + JSClassRef retClass = JSCNodeList::getTmpl(); - Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagName(localName)); - JSClassRef retClass = JSCNodeList::getTmpl(); + struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); - 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 getElementsByTagName"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::getAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getAttributeNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); - - JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); - char* localLocalNameBuffer = new char[localLocalNameMaxSize]; - JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); - std::string localLocalName(localLocalNameBuffer); - JSStringRelease(stringReflocalLocalName); - free(localLocalNameBuffer); - - - std::string retVal = privData->nativeObj->getAttributeNS(localNamespaceURI, localLocalName); - - JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); - JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); - JSStringRelease(jscString); - return jscRetVal; + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); + + JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); + char* localLocalNameBuffer = new char[localLocalNameMaxSize]; + JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); + std::string localLocalName(localLocalNameBuffer); + JSStringRelease(stringReflocalLocalName); + free(localLocalNameBuffer); + + + std::string retVal = privData->nativeObj->getAttributeNS(localNamespaceURI, localLocalName); + + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getAttributeNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::setAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 3) { - std::string errorMsg = "Wrong number of arguments in setAttributeNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); - - JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); - char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; - JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); - std::string localQualifiedName(localQualifiedNameBuffer); - JSStringRelease(stringReflocalQualifiedName); - free(localQualifiedNameBuffer); - - JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[2], exception); - size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue); - char* localValueBuffer = new char[localValueMaxSize]; - JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize); - std::string localValue(localValueBuffer); - JSStringRelease(stringReflocalValue); - free(localValueBuffer); - - - privData->nativeObj->setAttributeNS(localNamespaceURI, localQualifiedName, localValue); - - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + if (false) { + } else if (argumentCount == 3 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1]) && + JSValueIsString(ctx, arguments[2])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); + + JSStringRef stringReflocalQualifiedName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localQualifiedNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalQualifiedName); + char* localQualifiedNameBuffer = new char[localQualifiedNameMaxSize]; + JSStringGetUTF8CString(stringReflocalQualifiedName, localQualifiedNameBuffer, localQualifiedNameMaxSize); + std::string localQualifiedName(localQualifiedNameBuffer); + JSStringRelease(stringReflocalQualifiedName); + free(localQualifiedNameBuffer); + + JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[2], exception); + size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue); + char* localValueBuffer = new char[localValueMaxSize]; + JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize); + std::string localValue(localValueBuffer); + JSStringRelease(stringReflocalValue); + free(localValueBuffer); + + + privData->nativeObj->setAttributeNS(localNamespaceURI, localQualifiedName, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setAttributeNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::removeAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in removeAttributeNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); - - JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); - char* localLocalNameBuffer = new char[localLocalNameMaxSize]; - JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); - std::string localLocalName(localLocalNameBuffer); - JSStringRelease(stringReflocalLocalName); - free(localLocalNameBuffer); - - - privData->nativeObj->removeAttributeNS(localNamespaceURI, localLocalName); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); + + JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); + char* localLocalNameBuffer = new char[localLocalNameMaxSize]; + JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); + std::string localLocalName(localLocalNameBuffer); + JSStringRelease(stringReflocalLocalName); + free(localLocalNameBuffer); + + + privData->nativeObj->removeAttributeNS(localNamespaceURI, localLocalName); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling removeAttributeNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::getAttributeNodeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getAttributeNodeNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); + + JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); + char* localLocalNameBuffer = new char[localLocalNameMaxSize]; + JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); + std::string localLocalName(localLocalNameBuffer); + JSStringRelease(stringReflocalLocalName); + free(localLocalNameBuffer); - JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); - char* localLocalNameBuffer = new char[localLocalNameMaxSize]; - JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); - std::string localLocalName(localLocalNameBuffer); - JSStringRelease(stringReflocalLocalName); - free(localLocalNameBuffer); + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->getAttributeNodeNS(localNamespaceURI, localLocalName)); + JSClassRef retClass = JSCAttr::getTmpl(); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->getAttributeNodeNS(localNamespaceURI, localLocalName)); - JSClassRef retClass = JSCAttr::getTmpl(); + struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); - 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 getAttributeNodeNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::setAttributeNodeNSCallback(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 setAttributeNodeNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Attr<std::string>* localNewAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCAttr::getTmpl())) { + Arabica::DOM::Attr<std::string>* localNewAttr = ((struct JSCAttr::JSCAttrPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNodeNS(*localNewAttr)); + JSClassRef retClass = JSCAttr::getTmpl(); - Arabica::DOM::Attr<std::string>* retVal = new Arabica::DOM::Attr<std::string>(privData->nativeObj->setAttributeNodeNS(*localNewAttr)); - JSClassRef retClass = JSCAttr::getTmpl(); + struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCAttr::JSCAttrPrivate* retPrivData = new JSCAttr::JSCAttrPrivate(); - 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 setAttributeNodeNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::getElementsByTagNameNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getElementsByTagNameNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); - JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); - char* localLocalNameBuffer = new char[localLocalNameMaxSize]; - JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); - std::string localLocalName(localLocalNameBuffer); - JSStringRelease(stringReflocalLocalName); - free(localLocalNameBuffer); + JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); + char* localLocalNameBuffer = new char[localLocalNameMaxSize]; + JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); + std::string localLocalName(localLocalNameBuffer); + JSStringRelease(stringReflocalLocalName); + free(localLocalNameBuffer); - Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagNameNS(localNamespaceURI, localLocalName)); - JSClassRef retClass = JSCNodeList::getTmpl(); + Arabica::DOM::NodeList<std::string>* retVal = new Arabica::DOM::NodeList<std::string>(privData->nativeObj->getElementsByTagNameNS(localNamespaceURI, localLocalName)); + JSClassRef retClass = JSCNodeList::getTmpl(); - struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNodeList::JSCNodeListPrivate* retPrivData = new JSCNodeList::JSCNodeListPrivate(); + 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 getElementsByTagNameNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::hasAttributeCallback(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 hasAttribute"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); + + bool retVal = privData->nativeObj->hasAttribute(localName); - bool retVal = privData->nativeObj->hasAttribute(localName); + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling hasAttribute"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCElement::hasAttributeNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in hasAttributeNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCElementPrivate* privData = (struct JSCElementPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); - - JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); - char* localLocalNameBuffer = new char[localLocalNameMaxSize]; - JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); - std::string localLocalName(localLocalNameBuffer); - JSStringRelease(stringReflocalLocalName); - free(localLocalNameBuffer); - - - bool retVal = privData->nativeObj->hasAttributeNS(localNamespaceURI, localLocalName); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); + + JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); + char* localLocalNameBuffer = new char[localLocalNameMaxSize]; + JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); + std::string localLocalName(localLocalNameBuffer); + JSStringRelease(stringReflocalLocalName); + free(localLocalNameBuffer); + + + bool retVal = privData->nativeObj->hasAttributeNS(localNamespaceURI, localLocalName); + + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling hasAttributeNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } - } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.cpp index f22ba32..8b2c8ef 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCFloat32Array.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCFloat32Array::staticValues[] = { JSStaticFunction JSCFloat32Array::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCFloat32Array::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Float32Array* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Float32Array(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Float32Array(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCFloat32Array::getTmpl())) { + + uscxml::Float32Array* localArray = ((struct JSCFloat32Array::JSCFloat32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Float32Array(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Float32Array(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Float32Array(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<float> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Float32Array(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Float32Array"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCFloat32Array::getTmpl(); + + struct JSCFloat32Array::JSCFloat32ArrayPrivate* retPrivData = new JSCFloat32Array::JSCFloat32ArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCFloat32Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCFloat32ArrayPrivate* privData = (struct JSCFloat32ArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCFloat32Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObj return JSValueMakeNumber(ctx, 4); } + JSValueRef JSCFloat32Array::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCFloat32ArrayPrivate* privData = (struct JSCFloat32ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - float retVal = privData->nativeObj->get(localIndex); + float retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCFloat32Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCFloat32ArrayPrivate* privData = (struct JSCFloat32ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - float localValue = (float)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCFloat32Array::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Float32Array* localArray = ((struct JSCFloat32Array::JSCFloat32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + float localValue = (float)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<float> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCFloat32Array::getTmpl())) { + uscxml::Float32Array* localArray = ((struct JSCFloat32Array::JSCFloat32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<float> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCFloat32Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCFloat32ArrayPrivate* privData = (struct JSCFloat32ArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Float32Array* retVal = new uscxml::Float32Array(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCFloat32Array::getTmpl(); + uscxml::Float32Array* retVal = new uscxml::Float32Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCFloat32Array::getTmpl(); - struct JSCFloat32Array::JSCFloat32ArrayPrivate* retPrivData = new JSCFloat32Array::JSCFloat32ArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCFloat32Array::JSCFloat32ArrayPrivate* retPrivData = new JSCFloat32Array::JSCFloat32ArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.h index 21d4c59..62fce52 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat32Array.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.cpp index 06ca510..2bf524c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCFloat64Array.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCFloat64Array::staticValues[] = { JSStaticFunction JSCFloat64Array::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCFloat64Array::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Float64Array* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Float64Array(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Float64Array(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCFloat64Array::getTmpl())) { + + uscxml::Float64Array* localArray = ((struct JSCFloat64Array::JSCFloat64ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Float64Array(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Float64Array(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Float64Array(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<double> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Float64Array(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Float64Array"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCFloat64Array::getTmpl(); + + struct JSCFloat64Array::JSCFloat64ArrayPrivate* retPrivData = new JSCFloat64Array::JSCFloat64ArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCFloat64Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCFloat64ArrayPrivate* privData = (struct JSCFloat64ArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCFloat64Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObj return JSValueMakeNumber(ctx, 8); } + JSValueRef JSCFloat64Array::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCFloat64ArrayPrivate* privData = (struct JSCFloat64ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - double retVal = privData->nativeObj->get(localIndex); + double retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCFloat64Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCFloat64ArrayPrivate* privData = (struct JSCFloat64ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - double localValue = (double)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCFloat64Array::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Float64Array* localArray = ((struct JSCFloat64Array::JSCFloat64ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + double localValue = (double)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<double> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCFloat64Array::getTmpl())) { + uscxml::Float64Array* localArray = ((struct JSCFloat64Array::JSCFloat64ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<double> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCFloat64Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCFloat64ArrayPrivate* privData = (struct JSCFloat64ArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Float64Array* retVal = new uscxml::Float64Array(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCFloat64Array::getTmpl(); + uscxml::Float64Array* retVal = new uscxml::Float64Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCFloat64Array::getTmpl(); - struct JSCFloat64Array::JSCFloat64ArrayPrivate* retPrivData = new JSCFloat64Array::JSCFloat64ArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCFloat64Array::JSCFloat64ArrayPrivate* retPrivData = new JSCFloat64Array::JSCFloat64ArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.h index f21962d..3b8fb44 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCFloat64Array.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.cpp index 2844b75..f0ca42a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCInt16Array.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCInt16Array::staticValues[] = { JSStaticFunction JSCInt16Array::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCInt16Array::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Int16Array* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Int16Array(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Int16Array(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt16Array::getTmpl())) { + + uscxml::Int16Array* localArray = ((struct JSCInt16Array::JSCInt16ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Int16Array(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Int16Array(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Int16Array(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<short> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Int16Array(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Int16Array"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCInt16Array::getTmpl(); + + struct JSCInt16Array::JSCInt16ArrayPrivate* retPrivData = new JSCInt16Array::JSCInt16ArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCInt16Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCInt16ArrayPrivate* privData = (struct JSCInt16ArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCInt16Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjec return JSValueMakeNumber(ctx, 2); } + JSValueRef JSCInt16Array::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt16ArrayPrivate* privData = (struct JSCInt16ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - short retVal = privData->nativeObj->get(localIndex); + short retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCInt16Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt16ArrayPrivate* privData = (struct JSCInt16ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - short localValue = (short)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt16Array::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Int16Array* localArray = ((struct JSCInt16Array::JSCInt16ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + short localValue = (short)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<short> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt16Array::getTmpl())) { + uscxml::Int16Array* localArray = ((struct JSCInt16Array::JSCInt16ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<short> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCInt16Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt16ArrayPrivate* privData = (struct JSCInt16ArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Int16Array* retVal = new uscxml::Int16Array(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCInt16Array::getTmpl(); + uscxml::Int16Array* retVal = new uscxml::Int16Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCInt16Array::getTmpl(); - struct JSCInt16Array::JSCInt16ArrayPrivate* retPrivData = new JSCInt16Array::JSCInt16ArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCInt16Array::JSCInt16ArrayPrivate* retPrivData = new JSCInt16Array::JSCInt16ArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.h index 7510336..992984e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt16Array.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.cpp index 09d8f76..b10fa96 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCInt32Array.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCInt32Array::staticValues[] = { JSStaticFunction JSCInt32Array::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCInt32Array::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Int32Array* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Int32Array(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Int32Array(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt32Array::getTmpl())) { + + uscxml::Int32Array* localArray = ((struct JSCInt32Array::JSCInt32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Int32Array(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Int32Array(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Int32Array(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<long> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Int32Array(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Int32Array"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCInt32Array::getTmpl(); + + struct JSCInt32Array::JSCInt32ArrayPrivate* retPrivData = new JSCInt32Array::JSCInt32ArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCInt32Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCInt32ArrayPrivate* privData = (struct JSCInt32ArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCInt32Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjec return JSValueMakeNumber(ctx, 4); } + JSValueRef JSCInt32Array::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt32ArrayPrivate* privData = (struct JSCInt32ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - long retVal = privData->nativeObj->get(localIndex); + long retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCInt32Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt32ArrayPrivate* privData = (struct JSCInt32ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - long localValue = (long)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt32Array::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Int32Array* localArray = ((struct JSCInt32Array::JSCInt32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + long localValue = (long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<long> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt32Array::getTmpl())) { + uscxml::Int32Array* localArray = ((struct JSCInt32Array::JSCInt32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<long> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCInt32Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt32ArrayPrivate* privData = (struct JSCInt32ArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Int32Array* retVal = new uscxml::Int32Array(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCInt32Array::getTmpl(); + uscxml::Int32Array* retVal = new uscxml::Int32Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCInt32Array::getTmpl(); - struct JSCInt32Array::JSCInt32ArrayPrivate* retPrivData = new JSCInt32Array::JSCInt32ArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCInt32Array::JSCInt32ArrayPrivate* retPrivData = new JSCInt32Array::JSCInt32ArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.h index 901eb3c..0174759 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt32Array.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp index 509481e..00c717c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCInt8Array.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCInt8Array::staticValues[] = { JSStaticFunction JSCInt8Array::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCInt8Array::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Int8Array* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Int8Array(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Int8Array(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt8Array::getTmpl())) { + + uscxml::Int8Array* localArray = ((struct JSCInt8Array::JSCInt8ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Int8Array(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Int8Array(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Int8Array(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Int8Array(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Int8Array"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCInt8Array::getTmpl(); + + struct JSCInt8Array::JSCInt8ArrayPrivate* retPrivData = new JSCInt8Array::JSCInt8ArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCInt8Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCInt8ArrayPrivate* privData = (struct JSCInt8ArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCInt8Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObject return JSValueMakeNumber(ctx, 1); } + JSValueRef JSCInt8Array::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt8ArrayPrivate* privData = (struct JSCInt8ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - char retVal = privData->nativeObj->get(localIndex); + char retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCInt8Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt8ArrayPrivate* privData = (struct JSCInt8ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt8Array::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Int8Array* localArray = ((struct JSCInt8Array::JSCInt8ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCInt8Array::getTmpl())) { + uscxml::Int8Array* localArray = ((struct JSCInt8Array::JSCInt8ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCInt8Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCInt8ArrayPrivate* privData = (struct JSCInt8ArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Int8Array* retVal = new uscxml::Int8Array(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCInt8Array::getTmpl(); + uscxml::Int8Array* retVal = new uscxml::Int8Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCInt8Array::getTmpl(); - struct JSCInt8Array::JSCInt8ArrayPrivate* retPrivData = new JSCInt8Array::JSCInt8ArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCInt8Array::JSCInt8ArrayPrivate* retPrivData = new JSCInt8Array::JSCInt8ArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.h index a693f2a..6d24a03 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCInt8Array.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp index c72b27b..4efde43 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNamedNodeMap.cpp @@ -29,239 +29,248 @@ JSValueRef JSCNamedNodeMap::lengthAttrGetter(JSContextRef ctx, JSObjectRef objec return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); } + JSValueRef JSCNamedNodeMap::getNamedItemCallback(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 getNamedItem"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->getNamedItem(localName)); + JSClassRef retClass = JSCNode::getTmpl(); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->getNamedItem(localName)); - JSClassRef retClass = JSCNode::getTmpl(); + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - 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 getNamedItem"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNamedNodeMap::setNamedItemCallback(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 setNamedItem"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Node<std::string>* localArg = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCNode::getTmpl())) { + Arabica::DOM::Node<std::string>* localArg = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->setNamedItem(*localArg)); + JSClassRef retClass = JSCNode::getTmpl(); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->setNamedItem(*localArg)); - JSClassRef retClass = JSCNode::getTmpl(); + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - 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 setNamedItem"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNamedNodeMap::removeNamedItemCallback(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 removeNamedItem"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); - char* localNameBuffer = new char[localNameMaxSize]; - JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); - std::string localName(localNameBuffer); - JSStringRelease(stringReflocalName); - free(localNameBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalName = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalName); + char* localNameBuffer = new char[localNameMaxSize]; + JSStringGetUTF8CString(stringReflocalName, localNameBuffer, localNameMaxSize); + std::string localName(localNameBuffer); + JSStringRelease(stringReflocalName); + free(localNameBuffer); + + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeNamedItem(localName)); + JSClassRef retClass = JSCNode::getTmpl(); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeNamedItem(localName)); - JSClassRef retClass = JSCNode::getTmpl(); + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - 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 removeNamedItem"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNamedNodeMap::itemCallback(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 item"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->item(localIndex)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->item(localIndex)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 item"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNamedNodeMap::getNamedItemNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in getNamedItemNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); + + JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); + char* localLocalNameBuffer = new char[localLocalNameMaxSize]; + JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); + std::string localLocalName(localLocalNameBuffer); + JSStringRelease(stringReflocalLocalName); + free(localLocalNameBuffer); - JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); - char* localLocalNameBuffer = new char[localLocalNameMaxSize]; - JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); - std::string localLocalName(localLocalNameBuffer); - JSStringRelease(stringReflocalLocalName); - free(localLocalNameBuffer); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->getNamedItemNS(localNamespaceURI, localLocalName)); + JSClassRef retClass = JSCNode::getTmpl(); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->getNamedItemNS(localNamespaceURI, localLocalName)); - JSClassRef retClass = JSCNode::getTmpl(); + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - 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 getNamedItemNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNamedNodeMap::setNamedItemNSCallback(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 setNamedItemNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Node<std::string>* localArg = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCNode::getTmpl())) { + Arabica::DOM::Node<std::string>* localArg = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->setNamedItemNS(*localArg)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->setNamedItemNS(*localArg)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 setNamedItemNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNamedNodeMap::removeNamedItemNSCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in removeNamedItemNS"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNamedNodeMapPrivate* privData = (struct JSCNamedNodeMapPrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); - char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; - JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); - std::string localNamespaceURI(localNamespaceURIBuffer); - JSStringRelease(stringReflocalNamespaceURI); - free(localNamespaceURIBuffer); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalNamespaceURI = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localNamespaceURIMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalNamespaceURI); + char* localNamespaceURIBuffer = new char[localNamespaceURIMaxSize]; + JSStringGetUTF8CString(stringReflocalNamespaceURI, localNamespaceURIBuffer, localNamespaceURIMaxSize); + std::string localNamespaceURI(localNamespaceURIBuffer); + JSStringRelease(stringReflocalNamespaceURI); + free(localNamespaceURIBuffer); - JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); - char* localLocalNameBuffer = new char[localLocalNameMaxSize]; - JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); - std::string localLocalName(localLocalNameBuffer); - JSStringRelease(stringReflocalLocalName); - free(localLocalNameBuffer); + JSStringRef stringReflocalLocalName = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localLocalNameMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalLocalName); + char* localLocalNameBuffer = new char[localLocalNameMaxSize]; + JSStringGetUTF8CString(stringReflocalLocalName, localLocalNameBuffer, localLocalNameMaxSize); + std::string localLocalName(localLocalNameBuffer); + JSStringRelease(stringReflocalLocalName); + free(localLocalNameBuffer); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeNamedItemNS(localNamespaceURI, localLocalName)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeNamedItemNS(localNamespaceURI, localLocalName)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 removeNamedItemNS"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp index 22d048c..2abf023 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNode.cpp @@ -105,7 +105,7 @@ JSValueRef JSCNode::parentNodeAttrGetter(JSContextRef ctx, JSObjectRef object, J retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -122,7 +122,7 @@ JSValueRef JSCNode::childNodesAttrGetter(JSContextRef ctx, JSObjectRef object, J retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -139,7 +139,7 @@ JSValueRef JSCNode::firstChildAttrGetter(JSContextRef ctx, JSObjectRef object, J retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -156,7 +156,7 @@ JSValueRef JSCNode::lastChildAttrGetter(JSContextRef ctx, JSObjectRef object, JS retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -173,7 +173,7 @@ JSValueRef JSCNode::previousSiblingAttrGetter(JSContextRef ctx, JSObjectRef obje retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -190,7 +190,7 @@ JSValueRef JSCNode::nextSiblingAttrGetter(JSContextRef ctx, JSObjectRef object, retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -207,7 +207,7 @@ JSValueRef JSCNode::ownerDocumentAttrGetter(JSContextRef ctx, JSObjectRef object retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } @@ -304,211 +304,244 @@ JSValueRef JSCNode::NOTATION_NODEConstGetter(JSContextRef ctx, JSObjectRef thisO return JSValueMakeNumber(ctx, 12); } + JSValueRef JSCNode::insertBeforeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in insertBefore"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; - Arabica::DOM::Node<std::string>* localRefChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCNode::getTmpl()) && + JSValueIsObject(ctx, arguments[1]) && JSValueIsObjectOfClass(ctx, arguments[1], JSCNode::getTmpl())) { + Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + Arabica::DOM::Node<std::string>* localRefChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], exception)))->nativeObj; - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->insertBefore(*localNewChild, *localRefChild)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->insertBefore(*localNewChild, *localRefChild)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 insertBefore"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNode::replaceChildCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in replaceChild"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; - Arabica::DOM::Node<std::string>* localOldChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCNode::getTmpl()) && + JSValueIsObject(ctx, arguments[1]) && JSValueIsObjectOfClass(ctx, arguments[1], JSCNode::getTmpl())) { + Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + Arabica::DOM::Node<std::string>* localOldChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[1], exception)))->nativeObj; - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->replaceChild(*localNewChild, *localOldChild)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->replaceChild(*localNewChild, *localOldChild)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 replaceChild"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNode::removeChildCallback(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 removeChild"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Node<std::string>* localOldChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCNode::getTmpl())) { + Arabica::DOM::Node<std::string>* localOldChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeChild(*localOldChild)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->removeChild(*localOldChild)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 removeChild"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNode::appendChildCallback(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 appendChild"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); - Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + if (false) { + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCNode::getTmpl())) { + Arabica::DOM::Node<std::string>* localNewChild = ((struct JSCNode::JSCNodePrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->appendChild(*localNewChild)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->appendChild(*localNewChild)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 appendChild"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNode::hasChildNodesCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { - bool retVal = privData->nativeObj->hasChildNodes(); + bool retVal = privData->nativeObj->hasChildNodes(); - JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling hasChildNodes"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNode::cloneNodeCallback(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 cloneNode"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); - bool localDeep = JSValueToBoolean(ctx, arguments[0]); + if (false) { + } else if (argumentCount == 1 && + JSValueIsBoolean(ctx, arguments[0])) { + bool localDeep = JSValueToBoolean(ctx, arguments[0]); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->cloneNode(localDeep)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->cloneNode(localDeep)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 cloneNode"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNode::normalizeCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { - privData->nativeObj->normalize(); + privData->nativeObj->normalize(); - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling normalize"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNode::isSupportedCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in isSupported"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalFeature = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localFeatureMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalFeature); - char* localFeatureBuffer = new char[localFeatureMaxSize]; - JSStringGetUTF8CString(stringReflocalFeature, localFeatureBuffer, localFeatureMaxSize); - std::string localFeature(localFeatureBuffer); - JSStringRelease(stringReflocalFeature); - free(localFeatureBuffer); - - JSStringRef stringReflocalVersion = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localVersionMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalVersion); - char* localVersionBuffer = new char[localVersionMaxSize]; - JSStringGetUTF8CString(stringReflocalVersion, localVersionBuffer, localVersionMaxSize); - std::string localVersion(localVersionBuffer); - JSStringRelease(stringReflocalVersion); - free(localVersionBuffer); - - - bool retVal = privData->nativeObj->isSupported(localFeature, localVersion); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalFeature = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localFeatureMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalFeature); + char* localFeatureBuffer = new char[localFeatureMaxSize]; + JSStringGetUTF8CString(stringReflocalFeature, localFeatureBuffer, localFeatureMaxSize); + std::string localFeature(localFeatureBuffer); + JSStringRelease(stringReflocalFeature); + free(localFeatureBuffer); + + JSStringRef stringReflocalVersion = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localVersionMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalVersion); + char* localVersionBuffer = new char[localVersionMaxSize]; + JSStringGetUTF8CString(stringReflocalVersion, localVersionBuffer, localVersionMaxSize); + std::string localVersion(localVersionBuffer); + JSStringRelease(stringReflocalVersion); + free(localVersionBuffer); + + + bool retVal = privData->nativeObj->isSupported(localFeature, localVersion); + + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling isSupported"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCNode::hasAttributesCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCNodePrivate* privData = (struct JSCNodePrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { - bool retVal = privData->nativeObj->hasAttributes(); + bool retVal = privData->nativeObj->hasAttributes(); - JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); - return jscRetVal; -} + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; + } + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling hasAttributes"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.cpp index b6e5723..793e989 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeList.cpp @@ -23,33 +23,34 @@ JSValueRef JSCNodeList::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, J return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); } + JSValueRef JSCNodeList::itemCallback(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 item"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCNodeListPrivate* privData = (struct JSCNodeListPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->item(localIndex)); - JSClassRef retClass = JSCNode::getTmpl(); + Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->item(localIndex)); + JSClassRef retClass = JSCNode::getTmpl(); - struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCNode::JSCNodePrivate* retPrivData = new JSCNode::JSCNodePrivate(); + 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 item"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp index adb366e..547288b 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeListCustom.cpp @@ -76,49 +76,5 @@ JSValueRef JSCNodeList::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef return JSValueMakeUndefined(ctx); } -#if 0 -v8::Handle<v8::Value> V8NodeList::indexedPropertyCustomGetter(uint32_t index, const v8::AccessorInfo &info) { - v8::Local<v8::Object> self = info.Holder(); - V8NodeListPrivate* privData = V8DOM::toClassPtr<V8NodeListPrivate >(self->GetInternalField(0)); - - if (privData->nativeObj->getLength() >= index) { - switch(privData->nativeObj->item(index).getNodeType()) { - case Node_base::ELEMENT_NODE: { - Arabica::DOM::Element<std::string>* retVal = new Arabica::DOM::Element<std::string>(privData->nativeObj->item(index)); - - v8::Handle<v8::Function> retCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; - - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - - retObj.MakeWeak(0, V8Element::jsDestructor); - return retObj; - } - default: { - Arabica::DOM::Node<std::string>* retVal = new Arabica::DOM::Node<std::string>(privData->nativeObj->item(index)); - - v8::Handle<v8::Function> retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance()); - - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; - - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; - } - } - } - - return v8::Undefined(); - -} -#endif } }
\ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp index 3aad9a4..ea7e64b 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCNodeSet.cpp @@ -30,17 +30,25 @@ JSValueRef JSCNodeSet::emptyAttrGetter(JSContextRef ctx, JSObjectRef object, JSS return JSValueMakeBoolean(ctx, privData->nativeObj->empty()); } + JSValueRef JSCNodeSet::toDocumentOrderCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCNodeSetPrivate* privData = (struct JSCNodeSetPrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { - privData->nativeObj->to_document_order(); + privData->nativeObj->to_document_order(); - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; -} + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling toDocumentOrder"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.cpp index de3a93f..9a7b8bb 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCSCXMLEvent.cpp @@ -84,7 +84,7 @@ JSValueRef JSCSCXMLEvent::domAttrGetter(JSContextRef ctx, JSObjectRef object, JS retPrivData->dom = privData->dom; retPrivData->nativeObj = arabicaRet; - JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet); + JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData); return arbaicaRetObj; } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp index f3c709b..4ad6f74 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCStorage.cpp @@ -26,130 +26,143 @@ JSValueRef JSCStorage::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JS return JSValueMakeNumber(ctx, privData->nativeObj->getLength()); } + JSValueRef JSCStorage::keyCallback(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 key"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - std::string retVal = privData->nativeObj->key(localIndex); + std::string retVal = privData->nativeObj->key(localIndex); - JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); - JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); - JSStringRelease(jscString); - return jscRetVal; + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling key"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCStorage::getItemCallback(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 getItem"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); - char* localKeyBuffer = new char[localKeyMaxSize]; - JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); - std::string localKey(localKeyBuffer); - JSStringRelease(stringReflocalKey); - free(localKeyBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); + char* localKeyBuffer = new char[localKeyMaxSize]; + JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); + std::string localKey(localKeyBuffer); + JSStringRelease(stringReflocalKey); + free(localKeyBuffer); - std::string retVal = privData->nativeObj->getItem(localKey); + std::string retVal = privData->nativeObj->getItem(localKey); - JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); - JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); - JSStringRelease(jscString); - return jscRetVal; + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling getItem"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCStorage::setItemCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in setItem"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); - char* localKeyBuffer = new char[localKeyMaxSize]; - JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); - std::string localKey(localKeyBuffer); - JSStringRelease(stringReflocalKey); - free(localKeyBuffer); - - JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[1], exception); - size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue); - char* localValueBuffer = new char[localValueMaxSize]; - JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize); - std::string localValue(localValueBuffer); - JSStringRelease(stringReflocalValue); - free(localValueBuffer); - - - privData->nativeObj->setItem(localKey, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsString(ctx, arguments[0]) && + JSValueIsString(ctx, arguments[1])) { + JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); + char* localKeyBuffer = new char[localKeyMaxSize]; + JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); + std::string localKey(localKeyBuffer); + JSStringRelease(stringReflocalKey); + free(localKeyBuffer); + + JSStringRef stringReflocalValue = JSValueToStringCopy(ctx, arguments[1], exception); + size_t localValueMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalValue); + char* localValueBuffer = new char[localValueMaxSize]; + JSStringGetUTF8CString(stringReflocalValue, localValueBuffer, localValueMaxSize); + std::string localValue(localValueBuffer); + JSStringRelease(stringReflocalValue); + free(localValueBuffer); + + + privData->nativeObj->setItem(localKey, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling setItem"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCStorage::removeItemCallback(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 removeItem"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); - JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); - size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); - char* localKeyBuffer = new char[localKeyMaxSize]; - JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); - std::string localKey(localKeyBuffer); - JSStringRelease(stringReflocalKey); - free(localKeyBuffer); + if (false) { + } else if (argumentCount == 1 && + JSValueIsString(ctx, arguments[0])) { + JSStringRef stringReflocalKey = JSValueToStringCopy(ctx, arguments[0], exception); + size_t localKeyMaxSize = JSStringGetMaximumUTF8CStringSize(stringReflocalKey); + char* localKeyBuffer = new char[localKeyMaxSize]; + JSStringGetUTF8CString(stringReflocalKey, localKeyBuffer, localKeyMaxSize); + std::string localKey(localKeyBuffer); + JSStringRelease(stringReflocalKey); + free(localKeyBuffer); - privData->nativeObj->removeItem(localKey); + privData->nativeObj->removeItem(localKey); - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling removeItem"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCStorage::clearCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCStoragePrivate* privData = (struct JSCStoragePrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { - privData->nativeObj->clear(); + privData->nativeObj->clear(); - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; -} + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling clear"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } 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); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCTypedArrayCustom.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCTypedArrayCustom.cpp new file mode 100644 index 0000000..4ef0b8e --- /dev/null +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCTypedArrayCustom.cpp @@ -0,0 +1,243 @@ +#include "../../TypedArray.h" +#include "JSCArrayBuffer.h" +#include "JSCInt8Array.h" +#include "JSCUint8Array.h" +#include "JSCUint8ClampedArray.h" +#include "JSCInt16Array.h" +#include "JSCUint16Array.h" +#include "JSCInt32Array.h" +#include "JSCUint32Array.h" +#include "JSCFloat32Array.h" +#include "JSCFloat64Array.h" +#include "JSCDataView.h" + +#define JSC_VALUE_TO_STRING(name, stringName)\ +size_t name##MaxSize = JSStringGetMaximumUTF8CStringSize(name);\ +char* name##Buffer = new char[name##MaxSize];\ +JSStringGetUTF8CString(name, name##Buffer, name##MaxSize);\ +std::string stringName(name##Buffer);\ +free(name##Buffer);\ + + +#define JSC_TYPED_ARRAY_GET_PROP_RETURN(type)\ +size_t propMaxSize = JSStringGetMaximumUTF8CStringSize(propertyName);\ +char* propBuffer = new char[propMaxSize];\ +JSStringGetUTF8CString(propertyName, propBuffer, propMaxSize);\ +std::string propName(propBuffer);\ +free(propBuffer);\ +if (strcmp(propName.c_str(), "prototype") == 0) {\ + JSStringRef prototypeName = JSStringCreateWithUTF8CString(#type);\ + JSValueRef prototype = JSObjectGetProperty(ctx, JSContextGetGlobalObject(ctx), prototypeName, exception);\ + assert(!JSValueIsUndefined(ctx, prototype) && !JSValueIsNull(ctx, prototype));\ + JSStringRelease(prototypeName);\ + return prototype;\ +}\ +JSStaticValue* prop = JSC##type::staticValues;\ +while(prop->name) {\ + if (strcmp(propName.c_str(), prop->name) == 0) {\ + return (prop->getProperty)(ctx, object, propertyName, exception);\ + }\ + prop++;\ +}\ +\ +JSC##type::JSC##type##Private* privObj = (JSC##type::JSC##type##Private*)JSObjectGetPrivate(object);\ +if (!privObj)\ + return JSValueMakeUndefined(ctx);\ +\ +uscxml::type* array = ((JSC##type::JSC##type##Private*)JSObjectGetPrivate(object))->nativeObj;\ +std::string base = "0123456789";\ +if (propName.find_first_not_of(base) != std::string::npos) {\ + return JSValueMakeUndefined(ctx);\ +}\ +unsigned long index = boost::lexical_cast<unsigned long>(propName);\ +return JSValueMakeNumber(ctx, array->get(index)); + + + +#define JSC_TYPED_ARRAY_SET_PROP_RETURN(type)\ +if (!JSValueIsNumber(ctx, value)) {\ + return false;\ +}\ +size_t propMaxSize = JSStringGetMaximumUTF8CStringSize(propertyName);\ +char* propBuffer = new char[propMaxSize];\ +JSStringGetUTF8CString(propertyName, propBuffer, propMaxSize);\ +std::string propName(propBuffer);\ +free(propBuffer);\ +uscxml::type* array = ((JSC##type::JSC##type##Private*)JSObjectGetPrivate(object))->nativeObj;\ +std::string base = "0123456789";\ +if (propName.find_first_not_of(base) != std::string::npos) {\ + return JSValueMakeUndefined(ctx);\ +}\ +unsigned long index = boost::lexical_cast<unsigned long>(propName);\ +if (index >= array->getLength()) {\ + return false;\ +}\ +array->set(index, JSValueToNumber(ctx, value, exception));\ +return true; + + +#define JSC_TYPED_ARRAY_HAS_PROP_RETURN(type)\ +size_t propertyNameMaxSize = JSStringGetMaximumUTF8CStringSize(propertyName);\ +char* propertyNameBuffer = new char[propertyNameMaxSize];\ +JSStringGetUTF8CString(propertyName, propertyNameBuffer, propertyNameMaxSize);\ +std::string propName(propertyNameBuffer);\ +free(propertyNameBuffer);\ +\ +if (strcmp(propName.c_str(), "prototype") == 0)\ + return true;\ +\ +if (strcmp(propName.c_str(), "length") == 0)\ + return true;\ +\ +JSStaticValue* prop = JSC##type::staticValues;\ +while(prop->name) {\ + if (strcmp(propName.c_str(), prop->name) == 0) {\ + return true;\ + }\ + prop++;\ +}\ +\ +JSC##type::JSC##type##Private* privObj = (JSC##type::JSC##type##Private*)JSObjectGetPrivate(object);\ +if (!privObj)\ + return false;\ +\ +uscxml::type* array = ((JSC##type::JSC##type##Private*)JSObjectGetPrivate(object))->nativeObj;\ +std::string base = "0123456789";\ +if (propName.find_first_not_of(base) != std::string::npos) {\ + return false;\ +}\ +unsigned long index = boost::lexical_cast<unsigned long>(propName);\ +if (array->getLength() > index)\ + return true;\ +return false;\ + +namespace Arabica { +namespace DOM { + +bool JSCInt8Array::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Int8Array); +} + +bool JSCInt16Array::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Int16Array); +} + +bool JSCInt32Array::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Int32Array); +} + +bool JSCUint8Array::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Uint8Array); +} + +bool JSCUint16Array::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Uint16Array); +} + +bool JSCUint32Array::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Uint32Array); +} + +bool JSCFloat32Array::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Float32Array); +} + +bool JSCFloat64Array::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Float64Array); +} + +bool JSCUint8ClampedArray::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(Uint8ClampedArray); +} + +bool JSCArrayBuffer::hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) { + JSC_TYPED_ARRAY_HAS_PROP_RETURN(ArrayBuffer); +} + +// ----------------- + +JSValueRef JSCInt8Array::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Int8Array); +} + +JSValueRef JSCInt16Array::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Int16Array); +} + +JSValueRef JSCInt32Array::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Int32Array); +} + +JSValueRef JSCUint8Array::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Uint8Array); +} + +JSValueRef JSCUint16Array::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Uint16Array); +} + +JSValueRef JSCUint32Array::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Uint32Array); +} + +JSValueRef JSCFloat32Array::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Float32Array); +} + +JSValueRef JSCFloat64Array::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Float64Array); +} + +JSValueRef JSCUint8ClampedArray::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(Uint8ClampedArray); +} + +JSValueRef JSCArrayBuffer::getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) { + JSC_TYPED_ARRAY_GET_PROP_RETURN(ArrayBuffer); +} + +// ---------------- + +bool JSCInt8Array::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Int8Array); +} + +bool JSCInt16Array::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Int16Array); +} + +bool JSCInt32Array::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Int32Array); +} + +bool JSCUint8Array::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Uint8Array); +} + +bool JSCUint16Array::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Uint16Array); +} + +bool JSCUint32Array::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Uint32Array); +} + +bool JSCFloat32Array::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Float32Array); +} + +bool JSCFloat64Array::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Float64Array); +} + +bool JSCUint8ClampedArray::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(Uint8ClampedArray); +} + +bool JSCArrayBuffer::setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) { + JSC_TYPED_ARRAY_SET_PROP_RETURN(ArrayBuffer); +} + + +} +}
\ No newline at end of file diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.cpp index 88e71d6..3ea7177 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCUint16Array.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCUint16Array::staticValues[] = { JSStaticFunction JSCUint16Array::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCUint16Array::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Uint16Array* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Uint16Array(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Uint16Array(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint16Array::getTmpl())) { + + uscxml::Uint16Array* localArray = ((struct JSCUint16Array::JSCUint16ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Uint16Array(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Uint16Array(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Uint16Array(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<unsigned short> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Uint16Array(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Uint16Array"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCUint16Array::getTmpl(); + + struct JSCUint16Array::JSCUint16ArrayPrivate* retPrivData = new JSCUint16Array::JSCUint16ArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCUint16Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCUint16ArrayPrivate* privData = (struct JSCUint16ArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCUint16Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObje return JSValueMakeNumber(ctx, 2); } + JSValueRef JSCUint16Array::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint16ArrayPrivate* privData = (struct JSCUint16ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned short retVal = privData->nativeObj->get(localIndex); + unsigned short retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCUint16Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint16ArrayPrivate* privData = (struct JSCUint16ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned short localValue = (unsigned short)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint16Array::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Uint16Array* localArray = ((struct JSCUint16Array::JSCUint16ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned short localValue = (unsigned short)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<unsigned short> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint16Array::getTmpl())) { + uscxml::Uint16Array* localArray = ((struct JSCUint16Array::JSCUint16ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<unsigned short> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCUint16Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint16ArrayPrivate* privData = (struct JSCUint16ArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Uint16Array* retVal = new uscxml::Uint16Array(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCUint16Array::getTmpl(); + uscxml::Uint16Array* retVal = new uscxml::Uint16Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCUint16Array::getTmpl(); - struct JSCUint16Array::JSCUint16ArrayPrivate* retPrivData = new JSCUint16Array::JSCUint16ArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCUint16Array::JSCUint16ArrayPrivate* retPrivData = new JSCUint16Array::JSCUint16ArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.h index dfc6cc8..90b92f4 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint16Array.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.cpp index 9887423..f259940 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCUint32Array.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCUint32Array::staticValues[] = { JSStaticFunction JSCUint32Array::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCUint32Array::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Uint32Array* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Uint32Array(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Uint32Array(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint32Array::getTmpl())) { + + uscxml::Uint32Array* localArray = ((struct JSCUint32Array::JSCUint32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Uint32Array(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Uint32Array(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Uint32Array(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<unsigned long> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Uint32Array(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Uint32Array"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCUint32Array::getTmpl(); + + struct JSCUint32Array::JSCUint32ArrayPrivate* retPrivData = new JSCUint32Array::JSCUint32ArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCUint32Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCUint32ArrayPrivate* privData = (struct JSCUint32ArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCUint32Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObje return JSValueMakeNumber(ctx, 4); } + JSValueRef JSCUint32Array::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint32ArrayPrivate* privData = (struct JSCUint32ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned long retVal = privData->nativeObj->get(localIndex); + unsigned long retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCUint32Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint32ArrayPrivate* privData = (struct JSCUint32ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned long localValue = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint32Array::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Uint32Array* localArray = ((struct JSCUint32Array::JSCUint32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned long localValue = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<unsigned long> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint32Array::getTmpl())) { + uscxml::Uint32Array* localArray = ((struct JSCUint32Array::JSCUint32ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<unsigned long> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCUint32Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint32ArrayPrivate* privData = (struct JSCUint32ArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Uint32Array* retVal = new uscxml::Uint32Array(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCUint32Array::getTmpl(); + uscxml::Uint32Array* retVal = new uscxml::Uint32Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCUint32Array::getTmpl(); - struct JSCUint32Array::JSCUint32ArrayPrivate* retPrivData = new JSCUint32Array::JSCUint32ArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCUint32Array::JSCUint32ArrayPrivate* retPrivData = new JSCUint32Array::JSCUint32ArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.h index 0fac7fc..9516f5f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint32Array.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.cpp index 62c49af..b828182 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCUint8Array.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCUint8Array::staticValues[] = { JSStaticFunction JSCUint8Array::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCUint8Array::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Uint8Array* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Uint8Array(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Uint8Array(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint8Array::getTmpl())) { + + uscxml::Uint8Array* localArray = ((struct JSCUint8Array::JSCUint8ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Uint8Array(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Uint8Array(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Uint8Array(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<unsigned char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Uint8Array(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Uint8Array"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCUint8Array::getTmpl(); + + struct JSCUint8Array::JSCUint8ArrayPrivate* retPrivData = new JSCUint8Array::JSCUint8ArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCUint8Array::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCUint8ArrayPrivate* privData = (struct JSCUint8ArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCUint8Array::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjec return JSValueMakeNumber(ctx, 1); } + JSValueRef JSCUint8Array::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint8ArrayPrivate* privData = (struct JSCUint8ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - char retVal = privData->nativeObj->get(localIndex); + unsigned char retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCUint8Array::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint8ArrayPrivate* privData = (struct JSCUint8ArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint8Array::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Uint8Array* localArray = ((struct JSCUint8Array::JSCUint8ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned char localValue = (unsigned char)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<unsigned char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint8Array::getTmpl())) { + uscxml::Uint8Array* localArray = ((struct JSCUint8Array::JSCUint8ArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<unsigned char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCUint8Array::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint8ArrayPrivate* privData = (struct JSCUint8ArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Uint8Array* retVal = new uscxml::Uint8Array(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCUint8Array::getTmpl(); + uscxml::Uint8Array* retVal = new uscxml::Uint8Array(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCUint8Array::getTmpl(); - struct JSCUint8Array::JSCUint8ArrayPrivate* retPrivData = new JSCUint8Array::JSCUint8ArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCUint8Array::JSCUint8ArrayPrivate* retPrivData = new JSCUint8Array::JSCUint8ArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.h index d45cee3..5510c99 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8Array.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.cpp index 85222dc..df5de18 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.cpp @@ -1,3 +1,5 @@ +#include "JSCArrayBuffer.h" +#include "JSCArrayBufferView.h" #include "JSCUint8ClampedArray.h" namespace Arabica { @@ -15,12 +17,84 @@ JSStaticValue JSCUint8ClampedArray::staticValues[] = { JSStaticFunction JSCUint8ClampedArray::staticFunctions[] = { { "get", getCallback, kJSPropertyAttributeDontDelete }, { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, - { "set", setCallback, kJSPropertyAttributeDontDelete }, { "subarray", subarrayCallback, kJSPropertyAttributeDontDelete }, { 0, 0, 0 } }; +JSObjectRef JSCUint8ClampedArray::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { + uscxml::Uint8ClampedArray* localInstance = NULL; + + if (false) { + } else if (argumentCount == 3 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1]) && + JSValueIsNumber(ctx, arguments[2])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[2], exception); + localInstance = new uscxml::Uint8ClampedArray(localBuffer, localByteOffset, localLength); + + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localByteOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + localInstance = new uscxml::Uint8ClampedArray(localBuffer, localByteOffset); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint8ClampedArray::getTmpl())) { + + uscxml::Uint8ClampedArray* localArray = ((struct JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Uint8ClampedArray(localArray); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCArrayBuffer::getTmpl())) { + + uscxml::ArrayBuffer* localBuffer = ((struct JSCArrayBuffer::JSCArrayBufferPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + localInstance = new uscxml::Uint8ClampedArray(localBuffer); + + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + + unsigned long localLength = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + localInstance = new uscxml::Uint8ClampedArray(localLength); + + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + + std::vector<unsigned char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + localInstance = new uscxml::Uint8ClampedArray(localArray); + + } + if (!localInstance) { + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for Uint8ClampedArray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return (JSObjectRef)JSValueMakeNull(ctx); + } + + JSClassRef retClass = JSCUint8ClampedArray::getTmpl(); + + struct JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate* retPrivData = new JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate(); + retPrivData->nativeObj = localInstance; + + JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData); + return retObj; +} + JSValueRef JSCUint8ClampedArray::lengthAttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) { struct JSCUint8ClampedArrayPrivate* privData = (struct JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(object); @@ -31,75 +105,138 @@ JSValueRef JSCUint8ClampedArray::BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, return JSValueMakeNumber(ctx, 1); } + JSValueRef JSCUint8ClampedArray::getCallback(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 get"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint8ClampedArrayPrivate* privData = (struct JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + if (false) { + } else if (argumentCount == 1 && + JSValueIsNumber(ctx, arguments[0])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - char retVal = privData->nativeObj->get(localIndex); + unsigned char retVal = privData->nativeObj->get(localIndex); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling get"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCUint8ClampedArray::setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in set"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint8ClampedArrayPrivate* privData = (struct JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(thisObj); - unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); - unsigned char localValue = (char)JSValueToNumber(ctx, arguments[1], exception); - - privData->nativeObj->set(localIndex, localValue); + if (false) { + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint8ClampedArray::getTmpl()) && + JSValueIsNumber(ctx, arguments[1])) { + uscxml::Uint8ClampedArray* localArray = ((struct JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + unsigned long localIndex = (unsigned long)JSValueToNumber(ctx, arguments[0], exception); + unsigned char localValue = (unsigned char)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localIndex, localValue); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 2 && + JSValueIsObject(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + + std::vector<unsigned char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + unsigned long localOffset = (unsigned long)JSValueToNumber(ctx, arguments[1], exception); + + privData->nativeObj->set(localArray, localOffset); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0]) && JSValueIsObjectOfClass(ctx, arguments[0], JSCUint8ClampedArray::getTmpl())) { + uscxml::Uint8ClampedArray* localArray = ((struct JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(JSValueToObject(ctx, arguments[0], exception)))->nativeObj; + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } else if (argumentCount == 1 && + JSValueIsObject(ctx, arguments[0])) { + + std::vector<unsigned char> localArray; + + JSValueRef localArrayItem; + unsigned int localArrayIndex = 0; + while((localArrayItem = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, arguments[0], exception), localArrayIndex, exception))) { + if (JSValueIsUndefined(ctx, localArrayItem)) + break; + if (JSValueIsNumber(ctx,localArrayItem)) + localArray.push_back(JSValueToNumber(ctx, localArrayItem, exception)); + localArrayIndex++; + } + + privData->nativeObj->set(localArray); + + JSValueRef jscRetVal = JSValueMakeUndefined(ctx); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeUndefined(ctx); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling set"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCUint8ClampedArray::subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { - if (argumentCount < 2) { - std::string errorMsg = "Wrong number of arguments in subarray"; - JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str()); - JSValueRef exceptionString =JSValueMakeString(ctx, string); - JSStringRelease(string); - *exception = JSValueToObject(ctx, exceptionString, NULL); - return NULL; - } struct JSCUint8ClampedArrayPrivate* privData = (struct JSCUint8ClampedArrayPrivate*)JSObjectGetPrivate(thisObj); - long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); - long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); + if (false) { + } else if (argumentCount == 2 && + JSValueIsNumber(ctx, arguments[0]) && + JSValueIsNumber(ctx, arguments[1])) { + long localStart = (long)JSValueToNumber(ctx, arguments[0], exception); + long localEnd = (long)JSValueToNumber(ctx, arguments[1], exception); - uscxml::Uint8ClampedArray* retVal = new uscxml::Uint8ClampedArray(privData->nativeObj->subarray(localStart, localEnd)); - JSClassRef retClass = JSCUint8ClampedArray::getTmpl(); + uscxml::Uint8ClampedArray* retVal = new uscxml::Uint8ClampedArray(privData->nativeObj->subarray(localStart, localEnd)); + JSClassRef retClass = JSCUint8ClampedArray::getTmpl(); - struct JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate* retPrivData = new JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate* retPrivData = new JSCUint8ClampedArray::JSCUint8ClampedArrayPrivate(); + 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 subarray"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.h b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.h index 76cd77b..36e7d8a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.h +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCUint8ClampedArray.h @@ -24,6 +24,7 @@ #include <string> #include "../../TypedArray.h" #include "DOM/Node.hpp" +#include "JSCArrayBufferView.h" #include <JavaScriptCore/JavaScriptCore.h> #include "uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h" @@ -43,8 +44,12 @@ public: static JSValueRef setCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); static JSValueRef subarrayCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception); + static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception); static JSValueRef lengthAttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); static JSValueRef BYTES_PER_ELEMENTConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception); + static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName); + static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception); + static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception); static JSStaticValue staticValues[]; @@ -57,6 +62,11 @@ public: classDef.staticValues = staticValues; classDef.staticFunctions = staticFunctions; classDef.finalize = jsDestructor; + classDef.hasProperty = hasPropertyCustomCallback; + classDef.getProperty = getPropertyCustomCallback; + classDef.setProperty = setPropertyCustomCallback; + classDef.callAsConstructor = jsConstructor; + classDef.parentClass = JSCArrayBufferView::getTmpl(); Tmpl = JSClassCreate(&classDef); JSClassRetain(Tmpl); diff --git a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp index 69b7969..a53585f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCXPathResult.cpp @@ -46,59 +46,91 @@ JSValueRef JSCXPathResult::booleanValueAttrGetter(JSContextRef ctx, JSObjectRef return JSValueMakeBoolean(ctx, privData->nativeObj->asBool()); } + JSValueRef JSCXPathResult::asNodeSetCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { + + Arabica::XPath::NodeSet<std::string>* retVal = new Arabica::XPath::NodeSet<std::string>(privData->nativeObj->asNodeSet()); + JSClassRef retClass = JSCNodeSet::getTmpl(); - Arabica::XPath::NodeSet<std::string>* retVal = new Arabica::XPath::NodeSet<std::string>(privData->nativeObj->asNodeSet()); - JSClassRef retClass = JSCNodeSet::getTmpl(); + struct JSCNodeSet::JSCNodeSetPrivate* retPrivData = new JSCNodeSet::JSCNodeSetPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - struct JSCNodeSet::JSCNodeSetPrivate* retPrivData = new JSCNodeSet::JSCNodeSetPrivate(); - 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 asNodeSet"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCXPathResult::asBoolCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { + + bool retVal = privData->nativeObj->asBool(); - bool retVal = privData->nativeObj->asBool(); + JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); + return jscRetVal; + } - JSValueRef jscRetVal = JSValueMakeBoolean(ctx, retVal); - return jscRetVal; + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling asBool"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCXPathResult::asStringCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { - std::string retVal = privData->nativeObj->asString(); + std::string retVal = privData->nativeObj->asString(); - JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); - JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); - JSStringRelease(jscString); - return jscRetVal; + JSStringRef jscString = JSStringCreateWithUTF8CString(retVal.c_str()); + JSValueRef jscRetVal = JSValueMakeString(ctx, jscString); + JSStringRelease(jscString); + return jscRetVal; + } + + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling asString"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); } JSValueRef JSCXPathResult::asNumberCallback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) { struct JSCXPathResultPrivate* privData = (struct JSCXPathResultPrivate*)JSObjectGetPrivate(thisObj); + if (false) { + } else if (argumentCount == 0) { - double retVal = privData->nativeObj->asNumber(); + double retVal = privData->nativeObj->asNumber(); - JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); - return jscRetVal; -} + JSValueRef jscRetVal = JSValueMakeNumber(ctx, retVal); + return jscRetVal; + } + JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling asNumber"); + *exception = JSValueMakeString(ctx, exceptionString); + JSStringRelease(exceptionString); + return JSValueMakeUndefined(ctx); +} } } |