diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-01 19:18:36 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-09-01 19:18:36 (GMT) |
commit | fd0778237785840ec754f98e847a524590cbf61c (patch) | |
tree | ebf4609be11843f9657810515d47faa3873c2db8 /src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp | |
parent | 99d2c52f1068b2dd4bd16b8c1c8231beeb94a649 (diff) | |
download | uscxml-fd0778237785840ec754f98e847a524590cbf61c.zip uscxml-fd0778237785840ec754f98e847a524590cbf61c.tar.gz uscxml-fd0778237785840ec754f98e847a524590cbf61c.tar.bz2 |
More work on TypedArrays
Diffstat (limited to 'src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp')
-rw-r--r-- | src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom/JSCDOMImplementation.cpp | 210 |
1 files changed, 109 insertions, 101 deletions
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); +} } } |