summaryrefslogtreecommitdiffstats
path: root/contrib/dom
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/dom')
-rw-r--r--contrib/dom/scripts/CodeGeneratorArabicaJSC.pm276
1 files changed, 161 insertions, 115 deletions
diff --git a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm
index affa51f..390bee0 100644
--- a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm
+++ b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm
@@ -47,7 +47,7 @@ my %headerIncludes = ();
# Default .h template
my $headerTemplate = << "EOF";
/*
- This file is part of the Arabica open source project.
+ This file is part of the Wrapper open source project.
This file has been generated by generate-bindings.pl. DO NOT MODIFY!
This library is free software; you can redistribute it and/or
@@ -146,6 +146,7 @@ sub GenerateHeader
$headerIncludes{"JSC${parent}.h"} = 1;
}
+ push(@headerContent, "#include \<string\>\n");
foreach my $headerInclude (sort keys(%headerIncludes)) {
if ($headerInclude =~ /wtf|JavaScriptCore\/JavaScriptCore\.h/) {
push(@headerContent, "#include \<${headerInclude}\>\n");
@@ -161,16 +162,20 @@ sub GenerateHeader
push(@headerContent, "\nclass JSC${interfaceName} {");
push(@headerContent, "\npublic:");
- my $arabicaType = IdlToArabicaType($interfaceName);
+ my $wrapperType = IdlToWrapperType($interfaceName);
push(@headerContent, <<END);
- struct JSC${interfaceName}Private {
- JSCDOM* dom;
- ${arabicaType}* arabicaThis;
- };
+ struct JSC${interfaceName}Private {
+ JSCDOM* dom;
+ ${wrapperType}* nativeObj;
+ };
END
- push(@headerContent, "\n JSC_DESTRUCTOR(JSC${interfaceName}Private);");
+ if ($extensions->{'DontDestroyWrapped'}) {
+ push(@headerContent, "\n JSC_DESTRUCTOR_KEEP_WRAPPED(JSC${interfaceName}Private);");
+ } else {
+ push(@headerContent, "\n JSC_DESTRUCTOR(JSC${interfaceName}Private);");
+ }
push(@headerContent, "\n");
@@ -190,27 +195,26 @@ END
my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : "");
my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : "");
push(@headerContent, "\n static JSValueRef ${name}${customGetter}AttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);");
- if (!IsReadonly($attribute)) {
+ if (!IsReadonly($attribute)) {
push(@headerContent, "\n static bool ${name}${customSetter}AttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);");
}
}
- push(@headerContent, "\n");
- # constant getters
- foreach my $constant (@{$interface->constants}) {
- my $name = $constant->name;
- push(@headerContent, "\n static JSValueRef ${name}ConstGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);");
- }
+ # const getters
+ foreach my $constant (@{$interface->constants}) {
+ my $name = $constant->name;
+ my $value = $constant->value;
+ my $getter = "${name}ConstGetter";
+ push(@headerContent, "\n static JSValueRef ${getter}(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);");
+ }
# if ($extensions->{'CustomIndexedGetter'}) {
- # push(@headerContent, "\n static v8::Handle<v8::Value> indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&);");
+ # push(@headerContent, "\n static JSValueRef indexedPropertyCustomGetter(uint32_t, const JSC::AccessorInfo&);");
# }
# if ($extensions->{'CustomIndexedSetter'}) {
- # push(@headerContent, "\n static v8::Handle<v8::Value> indexedPropertyCustomSetter(uint32_t, v8::Local<v8::Value>, const v8::AccessorInfo&);");
+ # push(@headerContent, "\n static JSValueRef indexedPropertyCustomSetter(uint32_t, JSC::Local<JSC::Value>, const JSC::AccessorInfo&);");
# }
- # push(@headerContent, "\n");
-
-# GenerateClassPrototypeHeader($interface);
+ push(@headerContent, "\n");
push(@headerContent, <<END);
@@ -220,17 +224,17 @@ END
static JSClassRef Tmpl;
static JSClassRef getTmpl() {
- if (Tmpl == NULL) {
- JSClassDefinition classDef = kJSClassDefinitionEmpty;
- classDef.staticValues = staticValues;
- classDef.staticFunctions = staticFunctions;
- classDef.finalize = jsDestructor;
-
- Tmpl = JSClassCreate(&classDef);
- JSClassRetain(Tmpl);
- }
- return Tmpl;
- }
+ if (Tmpl == NULL) {
+ JSClassDefinition classDef = kJSClassDefinitionEmpty;
+ classDef.staticValues = staticValues;
+ classDef.staticFunctions = staticFunctions;
+ classDef.finalize = jsDestructor;
+
+ Tmpl = JSClassCreate(&classDef);
+ JSClassRetain(Tmpl);
+ }
+ return Tmpl;
+ }
END
@@ -293,6 +297,7 @@ sub GenerateImplementationAttributes
{
my $interface = shift;
my $interfaceName = $interface->name;
+ my $extensions = $interface->extendedAttributes;
# Generate property accessors for attributes.
for (my $index = 0; $index < @{$interface->attributes}; $index++) {
@@ -301,59 +306,73 @@ sub GenerateImplementationAttributes
my $attrName = $attribute->signature->name;
my $attrExt = $attribute->signature->extendedAttributes;
- my $arabicaRetType = IdlToArabicaType($attrType);
- my $arabicaType = IdlToArabicaType($interfaceName);
- my $arabicaGetter = IdlToArabicaAttrGetter($interface, $attribute);
-
- next if ($attrExt->{'Custom'});
+ my $wrapperRetType = IdlToWrapperType($attrType);
+ my $wrapperType = IdlToWrapperType($interfaceName);
+ my $wrapperGetter;
+
+ if ($attrExt->{'AttributeIsPublic'} || $extensions->{'AttributesArePublic'}) {
+ $wrapperGetter = $attrName;
+ } else {
+ $wrapperGetter = IdlToWrapperAttrGetter($interface, $attribute)."()";
+
+ }
# getter
if (!$attrExt->{'CustomGetter'}) {
push(@implContent, <<END);
-JSValueRef JSC${interfaceName}::${attrName}AttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception) {
- struct JSC${interfaceName}Private* privData = static_cast<JSC${interfaceName}::JSC${interfaceName}Private* >(JSObjectGetPrivate(thisObj));
+ JSValueRef JSC${interfaceName}::${attrName}AttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) {
+ struct JSC${interfaceName}Private* privData = (struct JSC${interfaceName}Private*)JSObjectGetPrivate(object);
END
if (IsWrapperType($attrType)) {
AddToImplIncludes("JSC".$attrType.".h");
+ push(@implContent, "\n ".GenerateConditionalUndefReturn($interface, $attribute, "privData->nativeObj->${wrapperGetter}"));
+
push(@implContent, <<END);
- ${arabicaRetType}* arbaicaRet = new ${arabicaRetType}(privData->arabicaThis->${arabicaGetter}());
- struct JSC${attrType}::JSC${attrType}Private* retPrivData = new JSC${attrType}::JSC${attrType}Private();
- retPrivData->dom = privData->dom;
- retPrivData->arabicaThis = arbaicaRet;
-
- JSObjectRef arbaicaRetObj = JSObjectMake(ctx, JSC${attrType}::getTmpl(), retPrivData);
- return arbaicaRetObj;
+ ${wrapperRetType}* arabicaRet = new ${wrapperRetType}(privData->nativeObj->${wrapperGetter});
+
+ JSClassRef arbaicaRetClass = JSC${attrType}::getTmpl();
+
+ struct JSC${attrType}::JSC${attrType}Private* retPrivData = new JSC${attrType}::JSC${attrType}Private();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = arabicaRet;
+
+ JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, arabicaRet);
+ return arbaicaRetObj;
END
} else {
- my $jscType = IdlToJSCType($attrType);
- if ($attrType eq "DOMString") {
+ my $JSCType = IdlToJSCType($attrType);
+ if ($JSCType eq "String") {
+ if ($attrExt->{'EmptyAsNull'}) {
+ push(@implContent, "\n if (privData->nativeObj->${wrapperGetter}.length() == 0)");
+ push(@implContent, "\n return JSValueMakeUndefined(ctx);");
+ }
push(@implContent, <<END);
- JSStringRef retString = JSStringCreateWithUTF8CString(privData->arabicaThis->${arabicaGetter}().c_str());
- JSValueRef retObj = JSValueMakeString(ctx, retString);
- JSStringRelease(retString);
- return retObj;
+ JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->${wrapperGetter}.c_str());
+ return JSValueMakeString(ctx, stringRef);
END
- } else {
- push(@implContent, "\n return ${jscType}(ctx, privData->arabicaThis->${arabicaGetter}());");
+ } elsif($JSCType eq "Number") {
+ push(@implContent, "\n return JSValueMakeNumber(ctx, privData->nativeObj->${wrapperGetter});\n");
+ } elsif($JSCType eq "Boolean") {
+ push(@implContent, "\n return JSValueMakeNumber(ctx, privData->nativeObj->${wrapperGetter});\n");
}
}
- push(@implContent, "\n}\n");
+ push(@implContent, " }\n\n");
}
if (!$attrExt->{'CustomSetter'}) {
# setter
- if (!IsReadonly($attribute) && 0) {
- my $arabicaSetter = IdlToArabicaAttrSetter($attrName);
- push(@implContent, "\n void JSC${interfaceName}::${attrName}AttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {");
- push(@implContent, "\n v8::Local<v8::Object> self = info.Holder();");
- push(@implContent, "\n struct JSC${interfaceName}Private* privData = JSCDOM::toClassPtr<JSC${interfaceName}Private >(self->GetInternalField(0));");
+ if (!IsReadonly($attribute)) {
+ push(@implContent, "\n bool JSC${interfaceName}::${attrName}AttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {");
+ push(@implContent, "\n struct JSC${interfaceName}Private* privData = (struct JSC${interfaceName}Private*)JSObjectGetPrivate(thisObj);\n");
+ my $wrapperSetter = IdlToWrapperAttrSetter($attrName);
my ($handle, $deref) = IdlToArgHandle($attribute->signature->type, "local".ucfirst($attribute->signature->name), "value");
push(@implContent, "\n $handle");
- push(@implContent, "\n privData->arabicaThis->${arabicaSetter}(${deref});");
+ push(@implContent, "\n privData->nativeObj->${wrapperSetter}(${deref});");
+ push(@implContent, "\n return true;");
push(@implContent, "\n }\n");
}
@@ -361,48 +380,53 @@ END
}
}
+sub GenerateConditionalUndefReturn
+{
+ my $interface = shift;
+ my $attribute = shift;
+ my $getterExpression = shift;
+
+ return "" if ($attribute->signature->type eq "NamedNodeMap");
+ return "" if ($attribute->signature->type eq "NodeList");
+ return "if (!$getterExpression) return JSValueMakeUndefined(ctx);";
+}
+
sub GenerateImplementationFunctionCallbacks
{
my $interface = shift;
my $interfaceName = $interface->name;
- my $arabicaType = IdlToArabicaType($interfaceName);
+ my $wrapperType = IdlToWrapperType($interfaceName);
# Generate methods for functions.
foreach my $function (@{$interface->functions}) {
my $name = $function->signature->name;
my $attrExt = $function->signature->extendedAttributes;
my $retType = $function->signature->type;
- my $arabicaRetType = IdlToArabicaType($retType);
+ my $wrapperRetType = IdlToWrapperType($retType);
next if ($attrExt->{'Custom'});
# signature
push(@implContent, <<END);
- v8::Handle<v8::Value> JSC${interfaceName}::${name}Callback(const v8::Arguments& args) {
+ JSValueRef JSC${interfaceName}::${name}Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
END
# arguments count and type checking
push(@implContent, GenerateArgumentsCountCheck($function, $interface));
my $argCheckExpr = GenerateArgumentsTypeCheck($function, $interface);
- push(@implContent, <<END) if ($argCheckExpr);
- if (!${argCheckExpr})
- throw JSCException(\"Parameter mismatch while calling ${name}\");
-END
-
# get this
- push(@implContent, "\n v8::Local<v8::Object> self = args.Holder();");
- push(@implContent, "\n struct JSC${interfaceName}Private* privData = JSCDOM::toClassPtr<JSC${interfaceName}Private >(self->GetInternalField(0));");
+ push(@implContent, "\n struct JSC${interfaceName}Private* privData = (struct JSC${interfaceName}Private*)JSObjectGetPrivate(thisObj);\n");
# arguments to local handles
my $parameterIndex = 0;
my @argList;
foreach my $parameter (@{$function->parameters}) {
- my $value = "args[$parameterIndex]";
+ my $value = "arguments[$parameterIndex]";
my $type = $parameter->type;
AddToImplIncludes("JSC".$type.".h") if (IsWrapperType($type));
- my ($handle, $deref) = IdlToArgHandle($parameter->type, "local".ucfirst($parameter->name), "args[${parameterIndex}]");
+ my ($handle, $deref) = IdlToArgHandle($parameter->type, "local".ucfirst($parameter->name), "arguments[${parameterIndex}]");
push(@implContent, "\n ${handle}");
push(@argList, $deref);
@@ -411,13 +435,13 @@ END
# invoke native function with argument handles
my $retNativeType = IdlToNativeType($retType);
- my $arabicaFunctionName = IdlToArabicaFunction($interface, $function);
+ my $wrapperFunctionName = IdlToWrapperFunction($interface, $function);
if (IsWrapperType($retType)) {
- push(@implContent, "\n\n ${retNativeType}* retVal = new $arabicaRetType(privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . "));\n");
+ push(@implContent, "\n\n ${retNativeType}* retVal = new $wrapperRetType(privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . "));\n");
} elsif ($retNativeType eq "void") {
- push(@implContent, "\n\n privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . ");\n");
+ push(@implContent, "\n\n privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n");
} else {
- push(@implContent, "\n\n ${retNativeType} retVal = privData->arabicaThis->${arabicaFunctionName}(" . join(", ", @argList) . ");\n");
+ push(@implContent, "\n\n ${retNativeType} retVal = privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n");
}
# wrap return type if needed
@@ -425,21 +449,19 @@ END
AddToImplIncludes("JSC".$retType.".h");
push(@implContent, <<END);
- v8::Handle<v8::Function> retCtor = JSC${retType}::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
+ JSClassRef retClass = JSC${retType}::getTmpl();
- struct JSC${retType}::JSC${retType}Private* retPrivData = new JSC${retType}::JSC${retType}Private();
- retPrivData->dom = privData->dom;
- retPrivData->arabicaThis = retVal;
+ struct JSC${retType}::JSC${retType}Private* retPrivData = new JSC${retType}::JSC${retType}Private();
+ retPrivData->dom = privData->dom;
+ retPrivData->nativeObj = retVal;
- retObj->SetInternalField(0, JSCDOM::toExternal(retPrivData));
+ JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
- retObj.MakeWeak(0, JSC${retType}::jsDestructor);
return retObj;
END
} else {
- my $toHandleString = NativeToHandle($retNativeType, "retVal");
- push(@implContent, "\n return ${toHandleString};");
+ my $toHandleString = NativeToHandle($retNativeType, "retVal", "jscRetVal");
+ push(@implContent, "${toHandleString}\n return jscRetVal;");
}
push(@implContent, "\n }\n\n");
@@ -453,8 +475,8 @@ sub GenerateImplementation
my $interface = shift;
my $interfaceName = $interface->name;
my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
- my $v8InterfaceName = "JSC$interfaceName";
- my $arabicaType = IdlToArabicaType($interfaceName);
+ my $JSCInterfaceName = "JSC$interfaceName";
+ my $wrapperType = IdlToWrapperType($interfaceName);
AddToImplIncludes("JSC${interfaceName}.h");
@@ -472,13 +494,17 @@ sub GenerateImplementation
GenerateClassDefStatics($interface);
GenerateImplementationAttributes($interface);
-# GenerateImplementationFunctionCallbacks($interface);
+ GenerateImplementationFunctionCallbacks($interface);
push(@implContent, <<END);
}
}
END
+
+ # We've already added the header for this file in implContentHeader, so remove
+ # it from implIncludes to ensure we don't #include it twice.
+# delete $implIncludes{"${JSCInterfaceName}.h"};
}
sub WriteData
@@ -550,13 +576,13 @@ sub WriteData
sub IdlToJSCType
{
my $idlType = shift;
- return "JSValueMakeNumber" if ($idlType eq "unsigned short");
- return "JSValueMakeNumber" if ($idlType eq "short");
- return "JSValueMakeNumber" if ($idlType eq "unsigned long");
- return "JSValueMakeNumber" if ($idlType eq "long");
- return "JSValueMakeString" if ($idlType eq "DOMString");
- return "JSValueMakeBoolean" if ($idlType eq "boolean");
- return "JSValueMakeNumber" if ($idlType eq "double");
+ return "Number" if ($idlType eq "unsigned short");
+ return "Number" if ($idlType eq "short");
+ return "Number" if ($idlType eq "unsigned long");
+ return "Number" if ($idlType eq "long");
+ return "String" if ($idlType eq "DOMString");
+ return "Boolean" if ($idlType eq "boolean");
+ return "Number" if ($idlType eq "double");
die($idlType);
}
@@ -564,7 +590,7 @@ sub IdlToNativeType
{
my $idlType = shift;
- return IdlToArabicaType($idlType) if (IsWrapperType($idlType));
+ return IdlToWrapperType($idlType) if (IsWrapperType($idlType));
return "std::string" if ($idlType eq "DOMString");
return "bool" if ($idlType eq "boolean");
@@ -577,22 +603,27 @@ sub NativeToHandle
{
my $nativeType = shift;
my $nativeName = shift;
+ my $paramName = shift;
- return ("v8::Boolean::New(${nativeName})") if ($nativeType eq "bool");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "double");
- return ("v8::String::New(${nativeName}.c_str())") if ($nativeType eq "std::string");
- return ("v8::Undefined()") if ($nativeType eq "void");
+ return ("\n JSValueRef ${paramName} = JSValueMakeBoolean(ctx, ${nativeName});") if ($nativeType eq "bool");
+ return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "double");
+ return ("\n JSValueRef ${paramName} = JSValueMakeUndefined(ctx);") if ($nativeType eq "void");
+ return (
+ "\n JSStringRef jscString = JSStringCreateWithUTF8CString(${nativeName}.c_str());".
+ "\n JSValueRef ${paramName} = JSValueMakeString(ctx, jscString);"
+ ) if ($nativeType eq "std::string");
die($nativeType);
}
-sub IdlToArabicaType
+sub IdlToWrapperType
{
my $idlType = shift;
return "Arabica::XPath::XPathValue<std::string>" if ($idlType eq "XPathResult");
return "Arabica::XPath::NodeSet<std::string>" if ($idlType eq "NodeSet");
return "Arabica::DOM::Node<std::string>" if ($idlType eq "Node");
return "Arabica::DOM::Element<std::string>" if ($idlType eq "Element");
+ return "uscxml::Event" if ($idlType eq "SCXMLEvent");
return "Arabica::DOM::${idlType}<std::string>";
}
@@ -601,22 +632,30 @@ sub IdlToArgHandle
my $type = shift;
my $localName = shift;
my $paramName = shift;
-
- return ("v8::String::AsciiValue ${localName}(${paramName});", "*${localName}") if ($type eq "DOMString");
- return ("unsigned long ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned long");
- return ("unsigned short ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned short");
- return ("bool ${localName} = ${paramName}->ToBoolean()->BooleanValue();", ${localName}) if ($type eq "boolean");
+ if ($type eq "DOMString") {
+ return (
+ "JSStringRef stringRef${localName} = JSValueToStringCopy(ctx, ${paramName}, exception);\n" .
+ "\t\tsize_t ${localName}MaxSize = JSStringGetMaximumUTF8CStringSize(stringRef${localName});\n" .
+ "\t\tchar* ${localName}Buffer = new char[${localName}MaxSize];\n" .
+ "\t\tJSStringGetUTF8CString(stringRef${localName}, ${localName}Buffer, sizeof(${localName}Buffer));\n" .
+ "\t\tstd::string ${localName}(${localName}Buffer, ${localName}MaxSize);\n" .
+ "\t\tfree(${localName}Buffer);\n",
+ "${localName}") ;
+ }
+ return ("unsigned long ${localName} = (unsigned long)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "unsigned long");
+ return ("unsigned short ${localName} = (unsigned short)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "unsigned short");
+ return ("bool ${localName} = JSValueToBoolean(ctx, ${paramName});", ${localName}) if ($type eq "boolean");
if (IsWrapperType($type)) {
- my $arabicaType = IdlToArabicaType($type);
- return ("${arabicaType}* ${localName} = JSCDOM::toClassPtr<JSC${type}::JSC${type}Private >(${paramName}->ToObject()->GetInternalField(0))->arabicaThis;", "*${localName}");
+ my $wrapperType = IdlToWrapperType($type);
+ return ("${wrapperType}* ${localName} = ((struct JSC${type}::JSC${type}Private*)JSObjectGetPrivate(thisObj))->nativeObj;", "*${localName}");
}
print $type."\n";
die();
}
-sub IdlToArabicaAttrGetter
+sub IdlToWrapperAttrGetter
{
my $interface = shift;
my $attribute = shift;
@@ -630,7 +669,7 @@ sub IdlToArabicaAttrGetter
return "get" . ucfirst($attribute->signature->name);
}
-sub IdlToArabicaFunction
+sub IdlToWrapperFunction
{
my $interface = shift;
my $function = shift;
@@ -646,7 +685,7 @@ sub IdlToArabicaFunction
}
-sub IdlToArabicaAttrSetter
+sub IdlToWrapperAttrSetter
{
my $idlAttr = shift;
return "set" . ucfirst($idlAttr);
@@ -679,8 +718,15 @@ sub GenerateArgumentsCountCheck
my $argumentsCountCheckString = "";
if ($numMandatoryParams >= 1) {
- $argumentsCountCheckString .= " if (args.Length() < $numMandatoryParams)\n";
- $argumentsCountCheckString .= " throw JSCException(\"Wrong number of arguments in " . $function->signature->name . "\");\n";
+ $argumentsCountCheckString .=
+" if (argumentCount < $numMandatoryParams) {\n".
+" std::string errorMsg = \"Wrong number of arguments in " . $function->signature->name . "\";\n" .
+" JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());\n".
+" JSValueRef exceptionString =JSValueMakeString(ctx, string);\n".
+" JSStringRelease(string);\n".
+" *exception = JSValueToObject(ctx, exceptionString, NULL);\n".
+" return NULL;\n".
+" }\n";
}
return $argumentsCountCheckString;
}
@@ -772,14 +818,14 @@ sub IsWrapperType
sub GenerateHeaderContentHeader
{
my $interface = shift;
- my $v8InterfaceName = "JSC" . $interface->name;
+ my $JSCInterfaceName = "JSC" . $interface->name;
my $conditionalString = $codeGenerator->GenerateConditionalString($interface);
my @headerContentHeader = split("\r", $headerTemplate);
push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString;
- push(@headerContentHeader, "\n#ifndef ${v8InterfaceName}" . "_h");
- push(@headerContentHeader, "\n#define ${v8InterfaceName}" . "_h\n\n");
+ push(@headerContentHeader, "\n#ifndef ${JSCInterfaceName}" . "_h");
+ push(@headerContentHeader, "\n#define ${JSCInterfaceName}" . "_h\n\n");
return @headerContentHeader;
}