diff options
Diffstat (limited to 'WebCore/bindings/scripts')
39 files changed, 6057 insertions, 418 deletions
diff --git a/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/WebCore/bindings/scripts/CodeGeneratorGObject.pm index 2a38eff..1d03f08 100644 --- a/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -26,6 +26,10 @@ package CodeGeneratorGObject; my %implIncludes = (); my %hdrIncludes = (); +my @txtInstallProps = (); +my @txtSetProps = (); +my @txtGetProps = (); + my $className = ""; # Default constructor @@ -95,6 +99,16 @@ sub decamelize $s; } +sub FixUpDecamelizedName { + my $classname = shift; + + # FIXME: try to merge this somehow with the fixes in ClassNameToGobjectType + $classname =~ s/x_path/xpath/; + $classname =~ s/web_kit/webkit/; + + return $classname; +} + sub ClassNameToGObjectType { my $className = shift; my $CLASS_NAME = uc(decamelize($className)); @@ -102,6 +116,11 @@ sub ClassNameToGObjectType { # WebKitDOMCSS right, so we have to fix it manually (and there # might be more like this in the future) $CLASS_NAME =~ s/DOMCSS/DOM_CSS/; + $CLASS_NAME =~ s/DOMHTML/DOM_HTML/; + $CLASS_NAME =~ s/DOMDOM/DOM_DOM/; + $CLASS_NAME =~ s/DOMCDATA/DOM_CDATA/; + $CLASS_NAME =~ s/DOMX_PATH/DOM_XPATH/; + $CLASS_NAME =~ s/DOM_WEB_KIT/DOM_WEBKIT/; return $CLASS_NAME; } @@ -128,7 +147,8 @@ sub SkipAttribute { my $attribute = shift; if ($attribute->signature->extendedAttributes->{"CustomGetter"} || - $attribute->signature->extendedAttributes->{"CustomSetter"}) { + $attribute->signature->extendedAttributes->{"CustomSetter"} || + $attribute->signature->extendedAttributes->{"Replaceable"}) { return 1; } @@ -141,6 +161,55 @@ sub SkipAttribute { return 1; } + # This is for DOMWindow.idl location attribute + if ($attribute->signature->name eq "location") { + return 1; + } + + # This is for HTMLInput.idl valueAsDate + if ($attribute->signature->name eq "valueAsDate") { + return 1; + } + + # This is for DOMWindow.idl Crypto attribute + if ($attribute->signature->type eq "Crypto") { + return 1; + } + + return 0; +} + +sub SkipFunction { + my $function = shift; + my $decamelize = shift; + my $prefix = shift; + + my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($function->signature->name); + my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"} || + $function->signature->extendedAttributes->{"CustomArgumentHandling"}; + + if ($isCustomFunction && + $functionName ne "webkit_dom_node_replace_child" && + $functionName ne "webkit_dom_node_insert_before" && + $functionName ne "webkit_dom_node_replace_child" && + $functionName ne "webkit_dom_node_append_child" && + $functionName ne "webkit_dom_html_collection_item" && + $functionName ne "webkit_dom_html_collection_named_item") { + return 1; + } + + if ($function->signature->type eq "Event") { + return 1; + } + + if ($function->signature->name eq "getSVGDocument") { + return 1; + } + + if ($function->signature->name eq "getCSSCanvasContext") { + return 1; + } + return 0; } @@ -154,6 +223,7 @@ sub GetGValueTypeName { "boolean", "boolean", "char", "char", "long", "long", + "long long", "int64", "short", "int", "uchar", "uchar", "unsigned", "uint", @@ -172,11 +242,13 @@ sub GetGlibTypeName { my $name = GetClassName($type); my %types = ("DOMString", "gchar* ", + "CompareHow", "gushort", "float", "gfloat", "double", "gdouble", "boolean", "gboolean", "char", "gchar", "long", "glong", + "long long", "gint64", "short", "gshort", "uchar", "guchar", "unsigned", "guint", @@ -193,30 +265,192 @@ sub GetGlibTypeName { sub IsGDOMClassType { my $type = shift; - return 0 if $type eq "DOMString"; - return 0 if $type eq "float"; - return 0 if $type eq "double"; - return 0 if $type eq "boolean"; - return 0 if $type eq "char"; - return 0 if $type eq "long"; - return 0 if $type eq "short"; - return 0 if $type eq "uchar"; - return 0 if $type eq "unsigned"; - return 0 if $type eq "int"; - return 0 if $type eq "unsigned int"; - return 0 if $type eq "unsigned long"; - return 0 if $type eq "unsigned long long"; - return 0 if $type eq "unsigned short"; - return 0 if $type eq "void"; - + return 0 if $codeGenerator->IsNonPointerType($type) || $codeGenerator->IsStringType($type); return 1; } +sub GetReadableProperties { + my $properties = shift; + + my @result = (); + + foreach my $property (@{$properties}) { + if (!SkipAttribute($property)) { + push(@result, $property); + } + } + + return @result; +} + +sub GetWriteableProperties { + my $properties = shift; + my @result = (); + + foreach my $property (@{$properties}) { + my $writeable = $property->type !~ /^readonly/; + my $gtype = GetGValueTypeName($property->signature->type); + my $hasGtypeSignature = ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" || + $gtype eq "uint64" || $gtype eq "ulong" || $gtype eq "long" || + $gtype eq "uint" || $gtype eq "ushort" || $gtype eq "uchar" || + $gtype eq "char" || $gtype eq "string"); + if ($writeable && $hasGtypeSignature) { + push(@result, $property); + } + } + + return @result; +} + +sub GenerateProperty { + my $attribute = shift; + my $interfaceName = shift; + my @writeableProperties = @{shift @_}; + + my $camelPropName = $attribute->signature->name; + my $setPropNameFunction = $codeGenerator->WK_ucfirst($camelPropName); + my $getPropNameFunction = $codeGenerator->WK_lcfirst($camelPropName); + + my $propName = decamelize($camelPropName); + my $propNameCaps = uc($propName); + $propName =~ s/_/-/g; + my ${propEnum} = "PROP_${propNameCaps}"; + push(@cBodyPriv, " ${propEnum},\n"); + + my $propType = $attribute->signature->type; + my ${propGType} = decamelize($propType); + if ($propGType eq "event_target") { + $propGType = "event_target_node"; + } + my ${ucPropGType} = uc($propGType); + + my $gtype = GetGValueTypeName($propType); + my $gparamflag = "WEBKIT_PARAM_READABLE"; + my $writeable = $attribute->type !~ /^readonly/; + my $const = "read-only "; + my $custom = $attribute->signature->extendedAttributes->{"Custom"}; + if ($writeable && $custom) { + $const = "read-only (due to custom functions needed in webkitdom)"; + return; + } + if ($writeable && !$custom) { + $gparamflag = "WEBKIT_PARAM_READWRITE"; + $const = "read-write "; + } + + my $type = GetGlibTypeName($propType); + $nick = decamelize("${interfaceName}_${propName}"); + $long = "${const} ${type} ${interfaceName}.${propName}"; + + my $convertFunction = ""; + if ($gtype eq "string") { + $convertFunction = "WebCore::String::fromUTF8"; + } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { + $convertFunction = "WebCore::String::number"; + } + + my $setterContentHead; + my $getterContentHead; + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $camelPropName : ($reflect || $reflectURL); + my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + $implIncludes{"${namespace}.h"} = 1; + my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; + $setterContentHead = "coreSelf->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, ${convertFunction}(g_value_get_$gtype(value))"; + $getterContentHead = "coreSelf->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr"; + } else { + $setterContentHead = "coreSelf->set${setPropNameFunction}(${convertFunction}(g_value_get_$gtype(value))"; + $getterContentHead = "coreSelf->${getPropNameFunction}("; + } + + if (grep {$_ eq $attribute} @writeableProperties) { + push(@txtSetProps, " case ${propEnum}:\n {\n"); + push(@txtSetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; + push(@txtSetProps, " ${setterContentHead}"); + push(@txtSetProps, ", ec") if @{$attribute->setterExceptions}; + push(@txtSetProps, ");\n"); + push(@txtSetProps, " break;\n }\n"); + } + + push(@txtGetProps, " case ${propEnum}:\n {\n"); + + my $exception = ""; + if (@{$attribute->getterExceptions}) { + $exception = "ec"; + push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n"); + } + + my $postConvertFunction = ""; + my $done = 0; + if ($gtype eq "string") { + push(@txtGetProps, " g_value_take_string(value, convertToUTF8String(${getterContentHead}${exception})));\n"); + $done = 1; + } elsif ($gtype eq "object") { + $txtGetProp = << "EOF"; + RefPtr<WebCore::${propType}> ptr = coreSelf->${getPropNameFunction}(${exception}); + g_value_set_object(value, WebKit::kit(ptr.get())); +EOF + push(@txtGetProps, $txtGetProp); + $done = 1; + } + + if($attribute->signature->extendedAttributes->{"ConvertFromString"}) { + # TODO: Add other conversion functions for different types. Current + # IDLs only list longs. + if($gtype eq "long") { + $convertFunction = ""; + $postConvertFunction = ".toInt()"; + } else { + die "Can't convert to type ${gtype}."; + } + } + + # FIXME: get rid of this glitch? + my $_gtype = $gtype; + if ($gtype eq "ushort") { + $_gtype = "uint"; + } + + if (!$done) { + push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}coreSelf->${getPropNameFunction}(${exception})${postConvertFunction});\n"); + } + + push(@txtGetProps, " break;\n }\n"); + + my %param_spec_options = ("int", "G_MININT, /* min */\nG_MAXINT, /* max */\n0, /* default */", + "boolean", "FALSE, /* default */", + "float", "-G_MAXFLOAT, /* min */\nG_MAXFLOAT, /* max */\n0.0, /* default */", + "double", "-G_MAXDOUBLE, /* min */\nG_MAXDOUBLE, /* max */\n0.0, /* default */", + "uint64", "0, /* min */\nG_MAXUINT64, /* min */\n0, /* default */", + "long", "G_MINLONG, /* min */\nG_MAXLONG, /* max */\n0, /* default */", + "int64", "G_MININT64, /* min */\nG_MAXINT64, /* max */\n0, /* default */", + "ulong", "0, /* min */\nG_MAXULONG, /* max */\n0, /* default */", + "uint", "0, /* min */\nG_MAXUINT, /* max */\n0, /* default */", + "ushort", "0, /* min */\nG_MAXUINT16, /* max */\n0, /* default */", + "uchar", "G_MININT8, /* min */\nG_MAXINT8, /* max */\n0, /* default */", + "char", "0, /* min */\nG_MAXUINT8, /* max */\n0, /* default */", + "string", "\"\", /* default */", + "object", "WEBKIT_TYPE_DOM_${ucPropGType}, /* gobject type */"); + + my $txtInstallProp = << "EOF"; + g_object_class_install_property(gobjectClass, + ${propEnum}, + g_param_spec_${_gtype}("${propName}", /* name */ + "$nick", /* short description */ + "$long", /* longer - could do with some extra doc stuff here */ + $param_spec_options{$gtype} + ${gparamflag})); +EOF + push(@txtInstallProps, $txtInstallProp); +} + sub GenerateProperties { my ($object, $interfaceName, $dataNode) = @_; my $clsCaps = substr(ClassNameToGObjectType($className), 12); - my $lowerCaseIfaceName = "webkit_dom_" . (decamelize($interfaceName)); + my $lowerCaseIfaceName = "webkit_dom_" . (FixUpDecamelizedName(decamelize($interfaceName))); # Properties my $implContent = ""; @@ -228,169 +462,51 @@ enum { EOF push(@cBodyPriv, $implContent); - my @txtInstallProps = (); - my @txtSetProps = (); - my @txtGetProps = (); + my @readableProperties = GetReadableProperties($dataNode->attributes); my $privFunction = GetCoreObject($interfaceName, "coreSelf", "self"); my $txtGetProp = << "EOF"; static void ${lowerCaseIfaceName}_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { +EOF + push(@txtGetProps, $txtGetProp); + if (scalar @readableProperties > 0) { + $txtGetProp = << "EOF"; ${className}* self = WEBKIT_DOM_${clsCaps}(object); $privFunction +EOF + push(@txtGetProps, $txtGetProp); + } + $txtGetProp = << "EOF"; switch (prop_id) { EOF push(@txtGetProps, $txtGetProp); + my @writeableProperties = GetWriteableProperties(\@readableProperties); + my $txtSetProps = << "EOF"; static void ${lowerCaseIfaceName}_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) { +EOF + push(@txtSetProps, $txtSetProps); + + if (scalar @writeableProperties > 0) { + $txtSetProps = << "EOF"; ${className} *self = WEBKIT_DOM_${clsCaps}(object); $privFunction +EOF + push(@txtSetProps, $txtSetProps); + } + $txtSetProps = << "EOF"; switch (prop_id) { EOF push(@txtSetProps, $txtSetProps); - # Iterate over the interface attributes and generate a property for - # each one of them. - SKIPENUM: - foreach my $attribute (@{$dataNode->attributes}) { - if (SkipAttribute($attribute)) { - next SKIPENUM; - } - - my $camelPropName = $attribute->signature->name; - my $setPropNameFunction = $codeGenerator->WK_ucfirst($camelPropName); - my $getPropNameFunction = $codeGenerator->WK_lcfirst($camelPropName); - - my $propName = decamelize($camelPropName); - my $propNameCaps = uc($propName); - $propName =~ s/_/-/g; - my ${propEnum} = "PROP_${propNameCaps}"; - push(@cBodyPriv, " ${propEnum},\n"); - - my $propType = $attribute->signature->type; - my ${propGType} = decamelize($propType); - if ($propGType eq "event_target") { - $propGType = "event_target_node"; - } - my ${ucPropGType} = uc($propGType); - - my $gtype = GetGValueTypeName($propType); - my $gparamflag = "WEBKIT_PARAM_READABLE"; - my $writeable = $attribute->type !~ /^readonly/; - my $const = "read-only "; - if ($writeable && $custom) { - $const = "read-only (due to custom functions needed in webkitdom)"; - next SKIPENUM; - } - if ($writeable && !$custom) { - $gparamflag = "WEBKIT_PARAM_READWRITE"; - $const = "read-write "; - } - - my $type = GetGlibTypeName($propType); - $nick = decamelize("${interfaceName}_${propName}"); - $long = "${const} ${type} ${interfaceName}.${propName}"; - - my $convertFunction = ""; - - if ($writeable && ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" || - $gtype eq "uint64" || $gtype eq "ulong" || $gtype eq "long" || - $gtype eq "uint" || $gtype eq "ushort" || $gtype eq "uchar" || - $gtype eq "char" || $gtype eq "string")) { - - push(@txtSetProps, " case ${propEnum}:\n {\n"); - push(@txtSetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; - - if ($gtype eq "string") { - $convertFunction = "WebCore::String::fromUTF8"; - } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $convertFunction = "WebCore::String::number"; - } - - push(@txtSetProps, " coreSelf->set${setPropNameFunction}(${convertFunction}(g_value_get_$gtype(value))"); - push(@txtSetProps, ", ec") if @{$attribute->setterExceptions}; - push(@txtSetProps, ");\n"); - - push(@txtSetProps, " break;\n }\n"); - } - - push(@txtGetProps, " case ${propEnum}:\n {\n"); - - my $exception = ""; - if (@{$attribute->getterExceptions}) { - $exception = "ec"; - push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n"); - } - - my $postConvertFunction = ""; - my $done = 0; - if ($gtype eq "string") { - push(@txtGetProps, " g_value_take_string(value, convertToUTF8String(coreSelf->${getPropNameFunction}(${exception})));\n"); - $done = 1; - } elsif ($gtype eq "object") { - - $txtGetProp = << "EOF"; - RefPtr<WebCore::${propType}> ptr = coreSelf->${getPropNameFunction}(${exception}); - g_value_set_object(value, WebKit::kit(ptr.get())); -EOF - push(@txtGetProps, $txtGetProp); - - $done = 1; - } - - if($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - # TODO: Add other conversion functions for different types. Current - # IDLs only list longs. - if($gtype eq "long") { - $convertFunction = ""; - $postConvertFunction = ".toInt()"; - } else { - die "Can't convert to type ${gtype}."; - } - } - - # FIXME: get rid of this glitch? - my $_gtype = $gtype; - if ($gtype eq "ushort") { - $_gtype = "uint"; - } - - if (!$done) { - push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}coreSelf->${getPropNameFunction}(${exception})${postConvertFunction});\n"); - } - - push(@txtGetProps, " break;\n }\n"); - -my %param_spec_options = ("int", "G_MININT, /* min */\nG_MAXINT, /* max */\n0, /* default */", - "boolean", "FALSE, /* default */", - "float", "G_MINFLOAT, /* min */\nG_MAXFLOAT, /* max */\n0.0, /* default */", - "double", "G_MINDOUBLE, /* min */\nG_MAXDOUBLE, /* max */\n0.0, /* default */", - "uint64", "0, /* min */\nG_MAXUINT64, /* min */\n0, /* default */", - "long", "G_MINLONG, /* min */\nG_MAXLONG, /* max */\n0, /* default */", - "ulong", "0, /* min */\nG_MAXULONG, /* max */\n0, /* default */", - "uint", "0, /* min */\nG_MAXUINT, /* max */\n0, /* default */", - "ushort", "0, /* min */\nG_MAXUINT16, /* max */\n0, /* default */", - "uchar", "G_MININT8, /* min */\nG_MAXINT8, /* max */\n0, /* default */", - "char", "0, /* min */\nG_MAXUINT8, /* max */\n0, /* default */", - "string", "\"\", /* default */", - "object", "WEBKIT_TYPE_DOM_${ucPropGType}, /* gobject type */"); - - my $txtInstallProp = << "EOF"; - g_object_class_install_property(gobjectClass, - ${propEnum}, - g_param_spec_${_gtype}("${propName}", /* name */ - "$nick", /* short description */ - "$long", /* longer - could do with some extra doc stuff here */ - $param_spec_options{$gtype} - ${gparamflag})); -EOF - push(@txtInstallProps, $txtInstallProp); - $txtInstallProp = "/* TODO! $gtype */\n"; + foreach my $attribute (@readableProperties) { + GenerateProperty($attribute, $interfaceName, \@writeableProperties); } push(@cBodyPriv, "};\n\n"); @@ -483,11 +599,11 @@ EOF push(@hBodyPre, $implContent); - my $clsCaps = uc(decamelize($interfaceName)); - my $lowerCaseIfaceName = "webkit_dom_" . (decamelize($interfaceName)); + my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); + my $clsCaps = uc($decamelize); + my $lowerCaseIfaceName = "webkit_dom_" . ($decamelize); $implContent = << "EOF"; - #define WEBKIT_TYPE_DOM_${clsCaps} (${lowerCaseIfaceName}_get_type()) #define WEBKIT_DOM_${clsCaps}(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_${clsCaps}, ${className})) #define WEBKIT_DOM_${clsCaps}_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_${clsCaps}, ${className}Class) @@ -517,6 +633,7 @@ sub getIncludeHeader { return "" if $type eq "int"; return "" if $type eq "long"; + return "" if $type eq "long long"; return "" if $type eq "short"; return "" if $type eq "char"; return "" if $type eq "float"; @@ -533,6 +650,7 @@ sub getIncludeHeader { return "" if $type eq "float"; return "" if $type eq "boolean"; return "" if $type eq "void"; + return "" if $type eq "CompareHow"; return "$name.h"; } @@ -540,6 +658,10 @@ sub getIncludeHeader { sub addIncludeInBody { my $type = shift; + if ($type eq "DOMObject") { + return; + } + my $header = getIncludeHeader($type); if ($header eq "") { return; @@ -555,9 +677,15 @@ sub addIncludeInBody { sub GenerateFunction { my ($object, $interfaceName, $function, $prefix) = @_; + my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); + + if (SkipFunction($function, $decamelize, $prefix)) { + return; + } + my $functionSigName = $function->signature->name; my $functionSigType = $function->signature->type; - my $functionName = "webkit_dom_" . decamelize($interfaceName) . "_" . $prefix . decamelize($functionSigName); + my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($functionSigName); my $returnType = GetGlibTypeName($functionSigType); my $returnValueIsGDOMType = IsGDOMClassType($functionSigType); @@ -571,7 +699,7 @@ sub GenerateFunction { foreach my $param (@{$function->parameters}) { my $paramIDLType = $param->type; - if ($paramIDLType eq "Event") { + if ($paramIDLType eq "Event" || $paramIDLType eq "EventListener") { push(@hBody, "\n/* TODO: event function ${functionName} */\n\n"); push(@cBody, "\n/* TODO: event function ${functionName} */\n\n"); return; @@ -588,7 +716,7 @@ sub GenerateFunction { $implIncludes{"webkit/WebKitDOM${paramIDLType}Private.h"} = 1; } } - if ($paramIsGDOMType || ($paramIDLType eq "DOMString")) { + if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) { $paramName = "_g_" . $paramName; } if ($callImplParams) { @@ -598,13 +726,7 @@ sub GenerateFunction { } } - if ($functionSigType eq "Event") { - push(@hBody, "\n/* TODO: event function ${functionName} */\n\n"); - push(@cBody, "\n/* TODO: event function ${functionName} */\n\n"); - return; - } - - if ($returnType ne "void" && $returnValueIsGDOMType) { + if ($returnType ne "void" && $returnValueIsGDOMType && $functionSigType ne "DOMObject") { if ($functionSigType ne "EventTarget") { $implIncludes{"webkit/WebKitDOM${functionSigType}Private.h"} = 1; $implIncludes{"webkit/WebKitDOM${functionSigType}.h"} = 1; @@ -613,19 +735,6 @@ sub GenerateFunction { $implIncludes{"${functionSigType}.h"} = 1; } - # skip custom functions for now - # but skip from here to allow some headers to be created - # for a successful compile. - if ($isCustomFunction && - $functionName ne "webkit_dom_node_remove_child" && - $functionName ne "webkit_dom_node_insert_before" && - $functionName ne "webkit_dom_node_replace_child" && - $functionName ne "webkit_dom_node_append_child") { - push(@hBody, "\n/* TODO: custom function ${functionName} */\n\n"); - push(@cBody, "\n/* TODO: custom function ${functionName} */\n\n"); - return; - } - if(@{$function->raisesExceptions}) { $functionSig .= ", GError **error"; } @@ -667,8 +776,9 @@ sub GenerateFunction { my $paramIsGDOMType = IsGDOMClassType($paramIDLType); if ($paramIDLType eq "DOMString") { push(@cBody, " WebCore::String _g_${paramName} = WebCore::String::fromUTF8($paramName);\n"); - } - if ($paramIsGDOMType) { + } elsif ($paramIDLType eq "CompareHow") { + push(@cBody, " WebCore::Range::CompareHow _g_${paramName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); + } elsif ($paramIsGDOMType) { push(@cBody, " WebCore::${paramIDLType} * _g_${paramName} = WebKit::core($paramName);\n"); if ($returnType ne "void") { # TODO: return proper default result @@ -684,7 +794,15 @@ sub GenerateFunction { my $assignPre = ""; my $assignPost = ""; - if ($returnType ne "void" && !$isCustomFunction) { + # We need to special-case these Node methods because their C++ + # signature is different from what we'd expect given their IDL + # description; see Node.h. + my $functionHasCustomReturn = $functionName eq "webkit_dom_node_append_child" || + $functionName eq "webkit_dom_node_insert_before" || + $functionName eq "webkit_dom_node_replace_child" || + $functionName eq "webkit_dom_node_remove_child"; + + if ($returnType ne "void" && !$functionHasCustomReturn) { if ($returnValueIsGDOMType) { $assign = "PassRefPtr<WebCore::${functionSigType}> g_res = "; $assignPre = "WTF::getPtr("; @@ -703,12 +821,7 @@ sub GenerateFunction { } } - # We need to special-case these Node methods because their C++ signature is different - # from what we'd expect given their IDL description; see Node.h. - if ($functionName eq "webkit_dom_node_append_child" || - $functionName eq "webkit_dom_node_insert_before" || - $functionName eq "webkit_dom_node_replace_child" || - $functionName eq "webkit_dom_node_remove_child") { + if ($functionHasCustomReturn) { my $customNodeAppendChild = << "EOF"; bool ok = item->${functionSigName}(${callImplParams}${exceptions}); if (ok) @@ -732,13 +845,40 @@ EOF push(@cBody, "}\n\n"); return; } elsif ($functionSigType eq "DOMString") { - push(@cBody, " ${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n" ); + my $getterContentHead; + my $reflect = $function->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $function->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $functionSigName : ($reflect || $reflectURL); + my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + $implIncludes{"${namespace}.h"} = 1; + my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; + $getterContentHead = "${assign}convertToUTF8String(item->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr));\n"; + } else { + $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n"; + } + + push(@cBody, " ${getterContentHead}"); } else { - push(@cBody, " ${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n" ); + my $setterContentHead; + my $reflect = $function->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $function->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $functionSigName : ($reflect || $reflectURL); + $contentAttributeName =~ s/set//; + $contentAttributeName = $codeGenerator->WK_lcfirst($contentAttributeName); + my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + $implIncludes{"${namespace}.h"} = 1; + $setterContentHead = "${assign}${assignPre}item->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, ${callImplParams}${exceptions}${assignPost});\n"; + } else { + $setterContentHead = "${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n"; + } + + push(@cBody, " ${setterContentHead}"); if(@{$function->raisesExceptions}) { my $exceptionHandling = << "EOF"; - if(ec) { + if (ec) { WebCore::ExceptionCodeDescription ecdesc; WebCore::getExceptionCodeDescription(ec, ecdesc); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); @@ -748,7 +888,7 @@ EOF } } - if ($returnType ne "void" && !$isCustomFunction) { + if ($returnType ne "void" && !$functionHasCustomReturn) { if ($functionSigType ne "DOMObject") { if ($returnValueIsGDOMType) { push(@cBody, " ${returnType} res = static_cast<${returnType}>(WebKit::kit(g_res.get()));\n"); @@ -813,9 +953,7 @@ sub GenerateFunctions { $function->raisesExceptions($attribute->getterExceptions); $object->GenerateFunction($interfaceName, $function, "get_"); - if ($attribute->type =~ /^readonly/ || - $attribute->signature->extendedAttributes->{"Replaceable"} # can't handle this yet - ) { + if ($attribute->type =~ /^readonly/) { next TOP; } @@ -846,8 +984,8 @@ sub GenerateCFile { my ($object, $interfaceName, $parentClassName, $parentGObjType, $dataNode) = @_; my $implContent = ""; - my $clsCaps = uc(decamelize($interfaceName)); - my $lowerCaseIfaceName = "webkit_dom_" . decamelize($interfaceName); + my $clsCaps = uc(FixUpDecamelizedName(decamelize($interfaceName))); + my $lowerCaseIfaceName = "webkit_dom_" . FixUpDecamelizedName(decamelize($interfaceName)); $implContent = << "EOF"; G_DEFINE_TYPE(${className}, ${lowerCaseIfaceName}, ${parentGObjType}) @@ -962,12 +1100,10 @@ EOF close(PRIVHEADER); } -sub UsesManualToJSImplementation { +sub UsesManualKitImplementation { my $type = shift; - return 1 if $type eq "Node" or $type eq "Document" or $type eq "HTMLCollection" or - $type eq "SVGPathSeg" or $type eq "StyleSheet" or $type eq "CSSRule" or $type eq "CSSValue" or - $type eq "Event" or $type eq "Element" or $type eq "Text"; + return 1 if $type eq "Node" or $type eq "Element"; return 0; } @@ -996,7 +1132,7 @@ sub Generate { $hdrIncludes{"webkit/${parentClassName}.h"} = 1; - if ($className ne "WebKitDOMNode") { + if (!UsesManualKitImplementation($interfaceName)) { my $converter = << "EOF"; namespace WebKit { diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 919e321..dc21314 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -101,8 +101,13 @@ sub GenerateInterface my $defines = shift; # Start actual generation - $object->GenerateHeader($dataNode); - $object->GenerateImplementation($dataNode); + if ($dataNode->extendedAttributes->{"Callback"}) { + $object->GenerateCallbackHeader($dataNode); + $object->GenerateCallbackImplementation($dataNode); + } else { + $object->GenerateHeader($dataNode); + $object->GenerateImplementation($dataNode); + } my $name = $dataNode->name; @@ -121,6 +126,25 @@ sub GenerateInterface } } +sub GenerateEventListenerCall +{ + my $className = shift; + my $functionName = shift; + my $passRefPtrHandling = ($functionName eq "add") ? "" : ".get()"; + + $implIncludes{"JSEventListener.h"} = 1; + + my @GenerateEventListenerImpl = (); + push(@GenerateEventListenerImpl, <<END); + JSValue listener = args.at(1); + if (!listener.isObject()) + return jsUndefined(); + imp->${functionName}EventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec))$passRefPtrHandling, args.at(2).toBoolean(exec)); + return jsUndefined(); +END + return @GenerateEventListenerImpl; +} + # Params: 'idlDocument' struct sub GenerateModule { @@ -168,6 +192,7 @@ sub IndexGetterReturnsStrings sub AddIncludesForType { my $type = $codeGenerator->StripModule(shift); + my $isCallback = @_ ? shift : 0; # When we're finished with the one-file-per-class # reorganization, we won't need these special cases. @@ -180,6 +205,8 @@ sub AddIncludesForType } elsif ($type eq "XPathNSResolver") { $implIncludes{"JSXPathNSResolver.h"} = 1; $implIncludes{"JSCustomXPathNSResolver.h"} = 1; + } elsif ($isCallback) { + $implIncludes{"JS${type}.h"} = 1; } else { # default, include the same named file $implIncludes{"${type}.h"} = 1; @@ -290,6 +317,29 @@ sub prototypeHashTableAccessor } } +sub GenerateConditionalStringFromAttributeValue +{ + my $conditional = shift; + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } +} + +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + return GenerateConditionalStringFromAttributeValue($conditional); + } else { + return ""; + } +} + sub GenerateGetOwnPropertySlotBody { my ($dataNode, $interfaceName, $className, $implClassName, $hasAttributes, $inlined) = @_; @@ -475,6 +525,36 @@ sub GenerateGetOwnPropertyDescriptorBody return @getOwnPropertyDescriptorImpl; } +sub GenerateHeaderContentHeader +{ + my $dataNode = shift; + my $className = "JS" . $dataNode->name; + + my @headerContentHeader = split("\r", $headerTemplate); + + # - Add header protection + push(@headerContentHeader, "\n#ifndef $className" . "_h"); + push(@headerContentHeader, "\n#define $className" . "_h\n\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@headerContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; + return @headerContentHeader; +} + +sub GenerateImplementationContentHeader +{ + my $dataNode = shift; + my $className = "JS" . $dataNode->name; + + my @implContentHeader = split("\r", $headerTemplate); + + push(@implContentHeader, "\n#include \"config.h\"\n"); + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; + push(@implContentHeader, "#include \"$className.h\"\n\n"); + return @implContentHeader; +} + sub GenerateHeader { my $object = shift; @@ -496,22 +576,11 @@ sub GenerateHeader my $hasRealParent = @{$dataNode->parents} > 0; my $hasParent = $hasLegacyParent || $hasRealParent; my $parentClassName = GetParentClassName($dataNode); - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; my $eventTarget = $dataNode->extendedAttributes->{"EventTarget"}; my $needsMarkChildren = $dataNode->extendedAttributes->{"CustomMarkFunction"} || $dataNode->extendedAttributes->{"EventTarget"}; - # - Add default header template - @headerContentHeader = split("\r", $headerTemplate); - - # - Add header protection - push(@headerContentHeader, "\n#ifndef $className" . "_h"); - push(@headerContentHeader, "\n#define $className" . "_h\n\n"); - - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@headerContentHeader, "#if ${conditionalString}\n\n"); - } + # - Add default header template and header protection + push(@headerContentHeader, GenerateHeaderContentHeader($dataNode)); if ($hasParent) { $headerIncludes{"$parentClassName.h"} = 1; @@ -905,8 +974,9 @@ sub GenerateHeader } } + my $conditionalString = GenerateConditionalString($dataNode); push(@headerContent, "\n} // namespace WebCore\n\n"); - push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditional; + push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; push(@headerContent, "#endif\n"); # - Generate dependencies. @@ -916,6 +986,73 @@ sub GenerateHeader } } +sub GenerateAttributesHashTable($$) +{ + my ($object, $dataNode) = @_; + + # FIXME: These should be functions on $dataNode. + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add all attributes in a hashtable definition + my $numAttributes = @{$dataNode->attributes}; + $numAttributes++ if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})); + + return 0 if !$numAttributes; + + my $hashSize = $numAttributes; + my $hashName = $className . "Table"; + + my @hashKeys = (); + my @hashSpecials = (); + my @hashValue1 = (); + my @hashValue2 = (); + my %conditionals = (); + + my @entries = (); + + foreach my $attribute (@{$dataNode->attributes}) { + my $name = $attribute->signature->name; + push(@hashKeys, $name); + + my @specials = (); + push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; + push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"DontEnum"}; + push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; + my $special = (@specials > 0) ? join("|", @specials) : "0"; + push(@hashSpecials, $special); + + my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + push(@hashValue1, $getter); + + if ($attribute->type =~ /readonly/) { + push(@hashValue2, "0"); + } else { + my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + push(@hashValue2, $setter); + } + + my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; + if ($conditional) { + $conditionals{$name} = $conditional; + } + } + + if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { + push(@hashKeys, "constructor"); + my $getter = "js" . $interfaceName . "Constructor"; + push(@hashValue1, $getter); + push(@hashValue2, "0"); + push(@hashSpecials, "DontEnum|ReadOnly"); # FIXME: Setting the constructor should be possible. + } + + $object->GenerateHashTable($hashName, $hashSize, + \@hashKeys, \@hashSpecials, + \@hashValue1, \@hashValue2, + \%conditionals); + return $numAttributes; +} + sub GenerateImplementation { my ($object, $dataNode) = @_; @@ -928,21 +1065,12 @@ sub GenerateImplementation my $hasRealParent = @{$dataNode->parents} > 0; my $hasParent = $hasLegacyParent || $hasRealParent; my $parentClassName = GetParentClassName($dataNode); - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; my $visibleClassName = GetVisibleClassName($interfaceName); my $eventTarget = $dataNode->extendedAttributes->{"EventTarget"}; my $needsMarkChildren = $dataNode->extendedAttributes->{"CustomMarkFunction"} || $dataNode->extendedAttributes->{"EventTarget"}; # - Add default header template - @implContentHeader = split("\r", $headerTemplate); - - push(@implContentHeader, "\n#include \"config.h\"\n"); - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implContentHeader, "\n#if ${conditionalString}\n\n"); - } - push(@implContentHeader, "#include \"$className.h\"\n\n"); + push(@implContentHeader, GenerateImplementationContentHeader($dataNode)); AddIncludesForSVGAnimatedType($interfaceName) if $className =~ /^JSSVGAnimated/; @@ -958,62 +1086,7 @@ sub GenerateImplementation push(@implContent, "ASSERT_CLASS_FITS_IN_CELL($className);\n\n"); - # - Add all attributes in a hashtable definition - my $numAttributes = @{$dataNode->attributes}; - $numAttributes++ if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})); - - if ($numAttributes > 0) { - my $hashSize = $numAttributes; - my $hashName = $className . "Table"; - - my @hashKeys = (); - my @hashSpecials = (); - my @hashValue1 = (); - my @hashValue2 = (); - my %conditionals = (); - - my @entries = (); - - foreach my $attribute (@{$dataNode->attributes}) { - my $name = $attribute->signature->name; - push(@hashKeys, $name); - - my @specials = (); - push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; - push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"DontEnum"}; - push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; - my $special = (@specials > 0) ? join("|", @specials) : "0"; - push(@hashSpecials, $special); - - my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); - push(@hashValue1, $getter); - - if ($attribute->type =~ /readonly/) { - push(@hashValue2, "0"); - } else { - my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); - push(@hashValue2, $setter); - } - - my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionals{$name} = $conditional; - } - } - - if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { - push(@hashKeys, "constructor"); - my $getter = "js" . $interfaceName . "Constructor"; - push(@hashValue1, $getter); - push(@hashValue2, "0"); - push(@hashSpecials, "DontEnum|ReadOnly"); # FIXME: Setting the constructor should be possible. - } - - $object->GenerateHashTable($hashName, $hashSize, - \@hashKeys, \@hashSpecials, - \@hashValue1, \@hashValue2, - \%conditionals); - } + my $numAttributes = GenerateAttributesHashTable($object, $dataNode); my $numConstants = @{$dataNode->constants}; my $numFunctions = @{$dataNode->functions}; @@ -1044,7 +1117,7 @@ sub GenerateImplementation my $protoClassName; $protoClassName = "${className}Prototype"; - push(@implContent, constructorFor($className, $protoClassName, $interfaceName, $visibleClassName, $dataNode->extendedAttributes->{"CanBeConstructed"})); + push(@implContent, constructorFor($className, $protoClassName, $interfaceName, $visibleClassName, $dataNode)); } # - Add functions and constants to a hashtable definition @@ -1305,11 +1378,8 @@ sub GenerateImplementation my $getFunctionName = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); my $implGetterFunctionName = $codeGenerator->WK_lcfirst($name); - my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implContent, "#if ${conditionalString}\n"); - } + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue slotBase, const Identifier&)\n"); push(@implContent, "{\n"); @@ -1417,9 +1487,7 @@ sub GenerateImplementation push(@implContent, "}\n"); - if ($conditional) { - push(@implContent, "#endif\n"); - } + push(@implContent, "#endif\n") if $attributeConditionalString; push(@implContent, "\n"); } @@ -1486,11 +1554,8 @@ sub GenerateImplementation my $putFunctionName = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); my $implSetterFunctionName = $codeGenerator->WK_ucfirst($name); - my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implContent, "#if ${conditionalString}\n"); - } + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, "void ${putFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n"); push(@implContent, "{\n"); @@ -1537,8 +1602,8 @@ sub GenerateImplementation push(@implContent, " // Shadowing a built-in object\n"); push(@implContent, " static_cast<$className*>(thisObject)->putDirect(Identifier(exec, \"$name\"), value);\n"); } else { - push(@implContent, " $className* castedThisObj = static_cast<$className*>(thisObject);\n"); - push(@implContent, " $implType* imp = static_cast<$implType*>(castedThisObj->impl());\n"); + push(@implContent, " $className* castedThis = static_cast<$className*>(thisObject);\n"); + push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n"); if ($podType) { push(@implContent, " $podType podImp(*imp);\n"); if ($podType eq "float") { # Special case for JSSVGNumber @@ -1546,7 +1611,7 @@ sub GenerateImplementation } else { push(@implContent, " podImp.set$implSetterFunctionName(" . JSValueToNative($attribute->signature, "value") . ");\n"); } - push(@implContent, " imp->commitChange(podImp, castedThisObj);\n"); + push(@implContent, " imp->commitChange(podImp, castedThis);\n"); } else { my $nativeValue = JSValueToNative($attribute->signature, "value"); push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; @@ -1564,16 +1629,14 @@ sub GenerateImplementation push(@implContent, ");\n"); push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions}; if (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@implContent, " JSSVGContextCache::propagateSVGDOMChange(castedThisObj, imp->associatedAttributeName());\n"); + push(@implContent, " JSSVGContextCache::propagateSVGDOMChange(castedThis, imp->associatedAttributeName());\n"); } } } push(@implContent, "}\n"); - if ($conditional) { - push(@implContent, "#endif\n"); - } + push(@implContent, "#endif\n") if $attributeConditionalString; push(@implContent, "\n"); } @@ -1614,22 +1677,22 @@ sub GenerateImplementation $implIncludes{"<runtime/Error.h>"} = 1; if ($interfaceName eq "DOMWindow") { - push(@implContent, " $className* castedThisObj = toJSDOMWindow(thisValue.toThisObject(exec));\n"); - push(@implContent, " if (!castedThisObj)\n"); + push(@implContent, " $className* castedThis = toJSDOMWindow(thisValue.toThisObject(exec));\n"); + push(@implContent, " if (!castedThis)\n"); push(@implContent, " return throwError(exec, TypeError);\n"); } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { - push(@implContent, " $className* castedThisObj = to${className}(thisValue.toThisObject(exec));\n"); - push(@implContent, " if (!castedThisObj)\n"); + push(@implContent, " $className* castedThis = to${className}(thisValue.toThisObject(exec));\n"); + push(@implContent, " if (!castedThis)\n"); push(@implContent, " return throwError(exec, TypeError);\n"); } else { push(@implContent, " if (!thisValue.inherits(&${className}::s_info))\n"); push(@implContent, " return throwError(exec, TypeError);\n"); - push(@implContent, " $className* castedThisObj = static_cast<$className*>(asObject(thisValue));\n"); + push(@implContent, " $className* castedThis = static_cast<$className*>(asObject(thisValue));\n"); } if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { - push(@implContent, " if (!castedThisObj->allowsAccessFrom(exec))\n"); + push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n"); push(@implContent, " return jsUndefined();\n"); } @@ -1649,14 +1712,14 @@ sub GenerateImplementation } if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}) { - push(@implContent, " return castedThisObj->" . $functionImplementationName . "(exec, args);\n"); + push(@implContent, " return castedThis->" . $functionImplementationName . "(exec, args);\n"); } elsif ($svgPODListType) { $implIncludes{"JS${svgPODListType}.h"} = 1; $implIncludes{"JSSVGPODListCustom.h"} = 1; push(@implContent, " return JSSVGPODListCustom::$functionImplementationName<$className, " . GetNativeType($svgPODListType) - . ">(castedThisObj, exec, args, to" . $svgPODListType . ");\n"); + . ">(castedThis, exec, args, to" . $svgPODListType . ");\n"); } else { - push(@implContent, " $implType* imp = static_cast<$implType*>(castedThisObj->impl());\n"); + push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n"); push(@implContent, " $podType podImp(*imp);\n") if $podType; my $numParameters = @{$function->parameters}; @@ -1676,72 +1739,94 @@ sub GenerateImplementation $implIncludes{"JSDOMBinding.h"} = 1; } - my $paramIndex = 0; - my $functionString = ($podType ? "podImp." : "imp->") . $functionImplementationName . "("; + if ($function->signature->name eq "addEventListener") { + push(@implContent, GenerateEventListenerCall($className, "add")); + } elsif ($function->signature->name eq "removeEventListener") { + push(@implContent, GenerateEventListenerCall($className, "remove")); + } else { + my $paramIndex = 0; + my $functionString = ($podType ? "podImp." : "imp->") . $functionImplementationName . "("; - my $hasOptionalArguments = 0; + my $hasOptionalArguments = 0; - if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { - push(@implContent, " ScriptCallStack callStack(exec, args, $numParameters);\n"); - $implIncludes{"ScriptCallStack.h"} = 1; - } - - foreach my $parameter (@{$function->parameters}) { - if (!$hasOptionalArguments && $parameter->extendedAttributes->{"Optional"}) { - push(@implContent, "\n int argsCount = args.size();\n"); - $hasOptionalArguments = 1; + if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { + push(@implContent, " ScriptCallStack callStack(exec, args, $numParameters);\n"); + $implIncludes{"ScriptCallStack.h"} = 1; } - if ($hasOptionalArguments) { - push(@implContent, " if (argsCount < " . ($paramIndex + 1) . ") {\n"); - GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName); - push(@implContent, " }\n\n"); + my $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith) { + my $callWithArg = "COMPILE_ASSERT(false)"; + if ($callWith eq "DynamicFrame") { + push(@implContent, " Frame* dynamicFrame = toDynamicFrame(exec);\n"); + push(@implContent, " if (!dynamicFrame)\n"); + push(@implContent, " return jsUndefined();\n"); + $callWithArg = "dynamicFrame"; + } elsif ($callWith eq "ScriptState") { + $callWithArg = "exec"; + } + $functionString .= ", " if $paramIndex; + $functionString .= $callWithArg; + $paramIndex++; } - my $name = $parameter->name; + foreach my $parameter (@{$function->parameters}) { + if (!$hasOptionalArguments && $parameter->extendedAttributes->{"Optional"}) { + push(@implContent, "\n int argsCount = args.size();\n"); + $hasOptionalArguments = 1; + } + + if ($hasOptionalArguments) { + push(@implContent, " if (argsCount < " . ($paramIndex + 1) . ") {\n"); + GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName); + push(@implContent, " }\n\n"); + } + + my $name = $parameter->name; - if ($parameter->type eq "XPathNSResolver") { - push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n"); - push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(args.at($paramIndex));\n"); - push(@implContent, " if (!resolver) {\n"); - push(@implContent, " customResolver = JSCustomXPathNSResolver::create(exec, args.at($paramIndex));\n"); - push(@implContent, " if (exec->hadException())\n"); - push(@implContent, " return jsUndefined();\n"); - push(@implContent, " resolver = customResolver.get();\n"); - push(@implContent, " }\n"); - } else { - push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args.at($paramIndex)") . ";\n"); - - # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception. - # But this needs to be done in the bindings, because the type is unsigned and the fact that it - # was negative will be lost by the time we're inside the DOM. - if ($parameter->extendedAttributes->{"IsIndex"}) { - $implIncludes{"ExceptionCode.h"} = 1; - push(@implContent, " if ($name < 0) {\n"); - push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n"); - push(@implContent, " return jsUndefined();\n"); + if ($parameter->type eq "XPathNSResolver") { + push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n"); + push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(args.at($paramIndex));\n"); + push(@implContent, " if (!resolver) {\n"); + push(@implContent, " customResolver = JSCustomXPathNSResolver::create(exec, args.at($paramIndex));\n"); + push(@implContent, " if (exec->hadException())\n"); + push(@implContent, " return jsUndefined();\n"); + push(@implContent, " resolver = customResolver.get();\n"); push(@implContent, " }\n"); + } else { + push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args.at($paramIndex)") . ";\n"); + + # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception. + # But this needs to be done in the bindings, because the type is unsigned and the fact that it + # was negative will be lost by the time we're inside the DOM. + if ($parameter->extendedAttributes->{"IsIndex"}) { + $implIncludes{"ExceptionCode.h"} = 1; + push(@implContent, " if ($name < 0) {\n"); + push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n"); + push(@implContent, " return jsUndefined();\n"); + push(@implContent, " }\n"); + } } - } - $functionString .= ", " if $paramIndex; + $functionString .= ", " if $paramIndex; - if ($parameter->type eq "NodeFilter") { - $functionString .= "$name.get()"; - } else { - $functionString .= $name; + if ($parameter->type eq "NodeFilter") { + $functionString .= "$name.get()"; + } else { + $functionString .= $name; + } + $paramIndex++; } - $paramIndex++; - } - if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { - $functionString .= ", " if $paramIndex; - $functionString .= "processingUserGesture(exec)"; - $paramIndex++; - } + if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { + $functionString .= ", " if $paramIndex; + $functionString .= "processingUserGesture(exec)"; + $paramIndex++; + } - push(@implContent, "\n"); - GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " ", $podType, $implClassName); + push(@implContent, "\n"); + GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " ", $podType, $implClassName); + } } push(@implContent, "}\n\n"); } @@ -1827,7 +1912,156 @@ sub GenerateImplementation push(@implContent, "\n}\n"); - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional; + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; +} + +sub GenerateCallbackHeader +{ + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add default header template and header protection + push(@headerContentHeader, GenerateHeaderContentHeader($dataNode)); + + $headerIncludes{"$interfaceName.h"} = 1; + $headerIncludes{"JSCallbackData.h"} = 1; + $headerIncludes{"<wtf/Forward.h>"} = 1; + + push(@headerContent, "\nnamespace WebCore {\n\n"); + push(@headerContent, "class $className : public $interfaceName {\n"); + push(@headerContent, "public:\n"); + + # The static create() method. + push(@headerContent, " static PassRefPtr<$className> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)\n"); + push(@headerContent, " {\n"); + push(@headerContent, " return adoptRef(new $className(callback, globalObject));\n"); + push(@headerContent, " }\n\n"); + + # Destructor + push(@headerContent, " virtual ~$className();\n"); + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@headerContent, "\n // Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if (!$function->signature->extendedAttributes->{"Custom"} && + !(GetNativeType($function->signature->type) eq "bool")) { + push(@headerContent, " COMPILE_ASSERT(false)"); + } + + push(@headerContent, " virtual " . GetNativeType($function->signature->type) . " " . $function->signature->name . "(ScriptExecutionContext*"); + foreach my $param (@params) { + push(@headerContent, ", " . GetNativeType($param->type) . " " . $param->name); + } + + push(@headerContent, ");\n"); + } + } + + push(@headerContent, "\nprivate:\n"); + + # Constructor + push(@headerContent, " $className(JSC::JSObject* callback, JSDOMGlobalObject*);\n\n"); + + # Private members + push(@headerContent, " JSCallbackData* m_data;\n"); + push(@headerContent, " RefPtr<DOMWrapperWorld> m_isolatedWorld;\n"); + push(@headerContent, "};\n\n"); + + push(@headerContent, "} // namespace WebCore\n\n"); + my $conditionalString = GenerateConditionalString($dataNode); + push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; + push(@headerContent, "#endif\n"); +} + +sub GenerateCallbackImplementation +{ + my ($object, $dataNode) = @_; + + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add default header template + push(@implContentHeader, GenerateImplementationContentHeader($dataNode)); + + $implIncludes{"ScriptExecutionContext.h"} = 1; + $implIncludes{"<runtime/JSLock.h>"} = 1; + $implIncludes{"<wtf/MainThread.h>"} = 1; + + @implContent = (); + + push(@implContent, "\nusing namespace JSC;\n\n"); + push(@implContent, "namespace WebCore {\n\n"); + + # Constructor + push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n"); + push(@implContent, " : m_data(new JSCallbackData(callback, globalObject))\n"); + push(@implContent, " , m_isolatedWorld(globalObject->world())\n"); + push(@implContent, "{\n"); + push(@implContent, "}\n\n"); + + # Destructor + push(@implContent, "${className}::~${className}()\n"); + push(@implContent, "{\n"); + push(@implContent, " callOnMainThread(JSCallbackData::deleteData, m_data);\n"); + push(@implContent, "#ifndef NDEBUG\n"); + push(@implContent, " m_data = 0;\n"); + push(@implContent, "#endif\n"); + push(@implContent, "}\n"); + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@implContent, "\n// Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if ($function->signature->extendedAttributes->{"Custom"} || + !(GetNativeType($function->signature->type) eq "bool")) { + next; + } + + AddIncludesForType($function->signature->type); + push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(ScriptExecutionContext* context"); + + foreach my $param (@params) { + AddIncludesForType($param->type, 1); + push(@implContent, ", " . GetNativeType($param->type) . " " . $param->name); + } + + push(@implContent, ")\n"); + + push(@implContent, "{\n"); + push(@implContent, " ASSERT(m_data);\n"); + push(@implContent, " ASSERT(context);\n\n"); + push(@implContent, " RefPtr<$className> protect(this);\n\n"); + push(@implContent, " JSLock lock(SilenceAssertionsOnly);\n\n"); + push(@implContent, " JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());\n"); + push(@implContent, " if (!globalObject)\n"); + push(@implContent, " return true;\n\n"); + push(@implContent, " ExecState* exec = globalObject->globalExec();\n"); + push(@implContent, " MarkedArgumentBuffer args;\n"); + + foreach my $param (@params) { + my $paramName = $param->name; + push(@implContent, " args.append(toJS(exec, ${paramName}));\n"); + } + + push(@implContent, "\n bool raisedException = false;\n"); + push(@implContent, " m_data->invokeCallback(args, &raisedException);\n"); + push(@implContent, " return !raisedException;\n"); + push(@implContent, "}\n"); + } + } + + push(@implContent, "\n}\n"); + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } sub GenerateImplementationFunctionCall() @@ -1854,16 +2088,22 @@ sub GenerateImplementationFunctionCall() if ($function->signature->type eq "void") { push(@implContent, $indent . "$functionString;\n"); push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; - push(@implContent, $indent . "imp->commitChange(podImp, castedThisObj);\n") if $podType; + push(@implContent, $indent . "imp->commitChange(podImp, castedThis);\n") if $podType; push(@implContent, $indent . "return jsUndefined();\n"); } else { - push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, "", $functionString, "castedThisObj") . ";\n"); + push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, "", $functionString, "castedThis") . ";\n"); push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; + $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith and $callWith eq "ScriptState") { + push(@implContent, $indent . "if (exec->hadException())\n"); + push(@implContent, $indent . " return jsUndefined();\n"); + } + if ($podType and not $function->signature->extendedAttributes->{"Immutable"}) { # Immutable methods do not commit changes back to the instance, thus producing # a new instance rather than mutating existing one. - push(@implContent, $indent . "imp->commitChange(podImp, castedThisObj);\n"); + push(@implContent, $indent . "imp->commitChange(podImp, castedThis);\n"); } push(@implContent, $indent . "return result;\n"); @@ -1888,6 +2128,7 @@ my %nativeType = ( "DOMString" => "const String&", "DOMObject" => "ScriptValue", "NodeFilter" => "RefPtr<NodeFilter>", + "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", "SVGAngle" => "SVGAngle", "SVGLength" => "SVGLength", "SVGMatrix" => "AffineTransform", @@ -1992,6 +2233,8 @@ sub NativeToJSValue die "Unknown value for ConvertNullStringTo extended attribute"; } + $conv = $signature->extendedAttributes->{"ConvertScriptString"}; + return "jsOwnedStringOrNull(exec, $value)" if $conv; $implIncludes{"<runtime/JSString.h>"} = 1; return "jsString(exec, $value)"; } @@ -2181,6 +2424,11 @@ tableSizeLoop: # Dump the hash table my $count = scalar @{$keys} + 1; + push(@implContent, "#if ENABLE(JIT)\n"); + push(@implContent, "#define THUNK_GENERATOR(generator) , generator\n"); + push(@implContent, "#else\n"); + push(@implContent, "#define THUNK_GENERATOR(generator)\n"); + push(@implContent, "#endif\n"); push(@implContent, "\nstatic const HashTableValue $nameEntries\[$count\] =\n\{\n"); $i = 0; foreach my $key (@{$keys}) { @@ -2191,7 +2439,7 @@ tableSizeLoop: $conditional = $conditionals->{$key}; } if ($conditional) { - my $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + my $conditionalString = GenerateConditionalStringFromAttributeValue($conditional); push(@implContent, "#if ${conditionalString}\n"); } @@ -2200,14 +2448,15 @@ tableSizeLoop: } else { $targetType = "static_cast<PropertySlot::GetValueFunc>"; } - push(@implContent, " { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i] },\n"); + push(@implContent, " { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i] THUNK_GENERATOR(0) },\n"); if ($conditional) { push(@implContent, "#endif\n"); } ++$i; } - push(@implContent, " { 0, 0, 0, 0 }\n"); + push(@implContent, " { 0, 0, 0, 0 THUNK_GENERATOR(0) }\n"); push(@implContent, "};\n\n"); + push(@implContent, "#undef THUNK_GENERATOR\n"); my $perfectSizeMask = $perfectSize - 1; my $compactSizeMask = $numEntries - 1; push(@implContent, "static JSC_CONST_HASHTABLE HashTable $name =\n"); @@ -2350,8 +2599,10 @@ sub constructorFor my $protoClassName = shift; my $interfaceName = shift; my $visibleClassName = shift; - my $canConstruct = shift; + my $dataNode = shift; my $constructorClassName = "${className}Constructor"; + my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"}; + my $callWith = $dataNode->extendedAttributes->{"CallWith"}; my $implContent = << "EOF"; class ${constructorClassName} : public DOMConstructorObject { @@ -2379,7 +2630,20 @@ EOF $implContent .= << "EOF"; static JSObject* construct${interfaceName}(ExecState* exec, JSObject* constructor, const ArgList&) { - return asObject(toJS(exec, static_cast<${constructorClassName}*>(constructor)->globalObject(), ${interfaceName}::create())); +EOF + + my $constructorArg = ""; + if ($callWith and $callWith eq "ScriptExecutionContext") { + $constructorArg = "context"; +$implContent .= << "EOF"; + ScriptExecutionContext* context = static_cast<${constructorClassName}*>(constructor)->scriptExecutionContext(); + if (!context) + return throwError(exec, ReferenceError); +EOF + } + +$implContent .= << "EOF"; + return asObject(toJS(exec, static_cast<${constructorClassName}*>(constructor)->globalObject(), ${interfaceName}::create(${constructorArg}))); } virtual ConstructType getConstructData(ConstructData& constructData) { diff --git a/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 3c5fe45..7132e22 100644 --- a/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -269,6 +269,23 @@ sub ReadPublicInterfaces $interfaceAvailabilityVersion = "WEBKIT_VERSION_LATEST" if $newPublicClass; } +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } + } else { + return ""; + } +} + # Params: 'domClass' struct sub GenerateInterface { @@ -1014,7 +1031,6 @@ sub GenerateImplementation my $implClassNameWithNamespace = "WebCore::" . $implClassName; my $baseClass = GetBaseClass($parentImplClassName); my $classHeaderName = GetClassHeaderName($className); - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; my $numAttributes = @{$dataNode->attributes}; my $numFunctions = @{$dataNode->functions}; @@ -1032,11 +1048,8 @@ sub GenerateImplementation # - INCLUDES - push(@implContentHeader, "\n#import \"config.h\"\n"); - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implContentHeader, "\n#if ${conditionalString}\n\n"); - } + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; push(@implContentHeader, "#import \"DOMInternal.h\"\n\n"); push(@implContentHeader, "#import \"$classHeaderName.h\"\n\n"); @@ -1585,7 +1598,7 @@ sub GenerateImplementation } # - End the ifdef conditional if necessary - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional; + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; # - Generate dependencies. if ($writeDependencies && @ancestorInterfaceNames) { diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index 1c5f398..9553b8b 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -99,8 +99,13 @@ sub GenerateInterface my $defines = shift; # Start actual generation - $object->GenerateHeader($dataNode); - $object->GenerateImplementation($dataNode); + if ($dataNode->extendedAttributes->{"Callback"}) { + $object->GenerateCallbackHeader($dataNode); + $object->GenerateCallbackImplementation($dataNode); + } else { + $object->GenerateHeader($dataNode); + $object->GenerateImplementation($dataNode); + } my $name = $dataNode->name; @@ -189,7 +194,13 @@ sub GenerateConditionalString my $node = shift; my $conditional = $node->extendedAttributes->{"Conditional"}; if ($conditional) { - return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } } else { return ""; } @@ -226,14 +237,9 @@ sub GenerateHeader $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@allParents, 1); my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; - my $conditionalString = GenerateConditionalString($dataNode); # - Add default header template - @headerContent = split("\r", $headerTemplate); - - push(@headerContent, "\n#if ${conditionalString}\n\n") if $conditionalString; - push(@headerContent, "\n#ifndef $className" . "_h"); - push(@headerContent, "\n#define $className" . "_h\n\n"); + push(@headerContent, GenerateHeaderContentHeader($dataNode)); # Get correct pass/store types respecting PODType flag my $podType = $dataNode->extendedAttributes->{"PODType"}; @@ -351,6 +357,7 @@ END push(@headerContent, "}\n\n"); push(@headerContent, "#endif // $className" . "_h\n"); + my $conditionalString = GenerateConditionalString($dataNode); push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; } @@ -1218,7 +1225,8 @@ END if ($parameter->type eq "SerializedScriptValue") { push(@implContentDecls, "SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n"); - push(@implContentDecls, " if (${parameterName}DidThrow)\n return v8::Undefined();\n"); + push(@implContentDecls, " if (${parameterName}DidThrow)\n"); + push(@implContentDecls, " return v8::Undefined();\n"); } else { push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]", BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef) . ";\n"); @@ -1570,16 +1578,9 @@ sub GenerateImplementation my $implClassName = $interfaceName; my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; - my $conditionalString = GenerateConditionalString($dataNode); # - Add default header template - @implContentHeader = split("\r", $headerTemplate); - - push(@implFixedHeader, - "\n#include \"config.h\"\n" . - "#include \"${className}.h\"\n\n"); - - push(@implFixedHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; + push(@implFixedHeader, GenerateImplementationContentHeader($dataNode)); $implIncludes{"RuntimeEnabledFeatures.h"} = 1; $implIncludes{"V8Proxy.h"} = 1; @@ -1780,11 +1781,18 @@ END # In namespace WebCore, add generated implementation for 'CanBeConstructed'. if ($dataNode->extendedAttributes->{"CanBeConstructed"} && !$dataNode->extendedAttributes->{"CustomConstructor"}) { + my $v8ConstructFunction; + my $callWith = $dataNode->extendedAttributes->{"CallWith"}; + if ($callWith and $callWith eq "ScriptExecutionContext") { + $v8ConstructFunction = "constructDOMObjectWithScriptExecutionContext"; + } else { + $v8ConstructFunction = "constructDOMObject"; + } push(@implContent, <<END); v8::Handle<v8::Value> ${className}::constructorCallback(const v8::Arguments& args) { INC_STATS("DOM.${interfaceName}.Contructor"); - return V8Proxy::constructDOMObject<$interfaceName>(args, &info); + return V8Proxy::${v8ConstructFunction}<$interfaceName>(args, &info); } END } @@ -2087,6 +2095,7 @@ END } // namespace WebCore END + my $conditionalString = GenerateConditionalString($dataNode); push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; # We've already added the header for this file in implFixedHeader, so remove @@ -2094,6 +2103,190 @@ END delete $implIncludes{"${className}.h"}; } +sub GenerateHeaderContentHeader +{ + my $dataNode = shift; + my $className = "V8" . $dataNode->name; + my $conditionalString = GenerateConditionalString($dataNode); + + my @headerContentHeader = split("\r", $headerTemplate); + + push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString; + push(@headerContentHeader, "\n#ifndef ${className}" . "_h"); + push(@headerContentHeader, "\n#define ${className}" . "_h\n\n"); + return @headerContentHeader; +} + +sub GenerateImplementationContentHeader +{ + my $dataNode = shift; + my $className = "V8" . $dataNode->name; + my $conditionalString = GenerateConditionalString($dataNode); + + my @implContentHeader = split("\r", $headerTemplate); + + push(@implContentHeader, "\n#include \"config.h\"\n"); + push(@implContentHeader, "#include \"${className}.h\"\n\n"); + push(@implContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; + return @implContentHeader; +} + +sub GenerateCallbackHeader +{ + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = "V8$interfaceName"; + + + # - Add default header template + push(@headerContent, GenerateHeaderContentHeader($dataNode)); + + if ("$interfaceName.h" lt "WorldContextHandle.h") { + push(@headerContent, "#include \"$interfaceName.h\"\n"); + push(@headerContent, "#include \"WorldContextHandle.h\"\n"); + } else { + push(@headerContent, "#include \"WorldContextHandle.h\"\n"); + push(@headerContent, "#include \"$interfaceName.h\"\n"); + } + push(@headerContent, "#include <v8.h>\n"); + push(@headerContent, "#include <wtf/Forward.h>\n"); + + push(@headerContent, "\nnamespace WebCore {\n\n"); + push(@headerContent, "class Frame;\n\n"); + push(@headerContent, "class $className : public $interfaceName {\n"); + + push(@headerContent, <<END); +public: + static PassRefPtr<${className}> create(v8::Local<v8::Value> value, Frame* frame) + { + ASSERT(value->IsObject()); + return adoptRef(new ${className}(value->ToObject(), frame)); + } + + virtual ~${className}(); + +END + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@headerContent, " // Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if (!$function->signature->extendedAttributes->{"Custom"} && + !(GetNativeType($function->signature->type) eq "bool")) { + push(@headerContent, " COMPILE_ASSERT(false)"); + } + + push(@headerContent, " virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "(ScriptExecutionContext*"); + foreach my $param (@params) { + push(@headerContent, ", " . GetNativeTypeForCallbacks($param->type) . " " . $param->name); + } + + push(@headerContent, ");\n"); + } + } + + push(@headerContent, <<END); + +private: + ${className}(v8::Local<v8::Object>, Frame*); + + v8::Persistent<v8::Object> m_callback; + RefPtr<Frame> m_frame; + WorldContextHandle m_worldContext; +}; + +END + + push(@headerContent, "}\n\n"); + push(@headerContent, "#endif // $className" . "_h\n\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalString; +} + +sub GenerateCallbackImplementation +{ + my $object = shift; + my $dataNode = shift; + my $interfaceName = $dataNode->name; + my $className = "V8$interfaceName"; + + # - Add default header template + push(@implFixedHeader, GenerateImplementationContentHeader($dataNode)); + + $implIncludes{"Frame.h"} = 1; + $implIncludes{"ScriptExecutionContext.h"} = 1; + $implIncludes{"V8CustomVoidCallback.h"} = 1; + + push(@implContent, "namespace WebCore {\n\n"); + push(@implContent, <<END); +${className}::${className}(v8::Local<v8::Object> callback, Frame* frame) + : m_callback(v8::Persistent<v8::Object>::New(callback)) + , m_frame(frame) + , m_worldContext(UseCurrentWorld) +{ +} + +${className}::~${className}() +{ + m_callback.Dispose(); +} + +END + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@implContent, "// Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if ($function->signature->extendedAttributes->{"Custom"} || + !(GetNativeTypeForCallbacks($function->signature->type) eq "bool")) { + next; + } + + AddIncludesForType($function->signature->type); + push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(ScriptExecutionContext* context"); + + foreach my $param (@params) { + AddIncludesForType($param->type); + push(@implContent, ", " . GetNativeTypeForCallbacks($param->type) . " " . $param->name); + } + + push(@implContent, ")\n"); + push(@implContent, "{\n"); + push(@implContent, " v8::HandleScope handleScope;\n\n"); + push(@implContent, " v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext);\n"); + push(@implContent, " if (v8Context.IsEmpty())\n"); + push(@implContent, " return true;\n\n"); + push(@implContent, " v8::Context::Scope scope(v8Context);\n\n"); + push(@implContent, " v8::Handle<v8::Value> argv[] = {\n"); + + my @argvs = (); + foreach my $param (@params) { + my $paramName = $param->name; + push(@argvs, " toV8(${paramName})"); + } + push(@implContent, join(",\n", @argvs)); + + push(@implContent, "\n };\n\n"); + push(@implContent, " RefPtr<Frame> protect(m_frame);\n\n"); + push(@implContent, " bool callbackReturnValue = false;\n"); + push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params). ", argv, callbackReturnValue);\n"); + push(@implContent, "}\n"); + } + } + + push(@implContent, "\n} // namespace WebCore\n\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; +} + sub GenerateToV8Converters { my $dataNode = shift; @@ -2326,15 +2519,33 @@ sub GenerateFunctionCallString() $functionString = "listImp->${name}("; } - my $first = 1; my $index = 0; + my $hasScriptState = 0; + + my $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith) { + my $callWithArg = "COMPILE_ASSERT(false)"; + if ($callWith eq "DynamicFrame") { + $result .= $indent . "Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();\n"; + $result .= $indent . "if (!enteredFrame)\n"; + $result .= $indent . " return v8::Undefined();\n"; + $callWithArg = "enteredFrame"; + } elsif ($callWith eq "ScriptState") { + $result .= $indent . "EmptyScriptState state;\n"; + $callWithArg = "&state"; + $hasScriptState = 1; + } + $functionString .= ", " if $index; + $functionString .= $callWithArg; + $index++; + $numberOfParameters++ + } foreach my $parameter (@{$function->parameters}) { if ($index eq $numberOfParameters) { last; } - if ($first) { $first = 0; } - else { $functionString .= ", "; } + $functionString .= ", " if $index; my $paramName = $parameter->name; my $paramType = $parameter->type; @@ -2353,22 +2564,23 @@ sub GenerateFunctionCallString() } if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { - $functionString .= ", " if not $first; + $functionString .= ", " if $index; $functionString .= "callStack.get()"; - if ($first) { $first = 0; } + $index++; } if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { - $functionString .= ", " if not $first; + $functionString .= ", " if $index; # FIXME: We need to pass DOMWrapperWorld as a parameter. # See http://trac.webkit.org/changeset/54182 $functionString .= "processingUserGesture()"; - if ($first) { $first = 0; } + $index++; } if (@{$function->raisesExceptions}) { - $functionString .= ", " if not $first; + $functionString .= ", " if $index; $functionString .= "ec"; + $index++; } $functionString .= ")"; @@ -2381,7 +2593,7 @@ sub GenerateFunctionCallString() $result .= $indent . GetNativeType($returnType, 0) . " result = *imp;\n" . $indent . "$functionString;\n"; } elsif ($returnsListItemPodType) { $result .= $indent . "RefPtr<SVGPODListItem<$nativeReturnType> > result = $functionString;\n"; - } elsif (@{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) { + } elsif ($hasScriptState or @{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) { $result .= $indent . $nativeReturnType . " result = $functionString;\n"; } else { # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary @@ -2390,7 +2602,13 @@ sub GenerateFunctionCallString() } if (@{$function->raisesExceptions}) { - $result .= $indent . "if (UNLIKELY(ec))\n" . $indent . " goto fail;\n"; + $result .= $indent . "if (UNLIKELY(ec))\n"; + $result .= $indent . " goto fail;\n"; + } + + if ($hasScriptState) { + $result .= $indent . "if (state.hadException())\n"; + $result .= $indent . " return throwError(state.exception());\n" } # If the return type is a POD type, separate out the wrapper generation @@ -2537,6 +2755,8 @@ sub GetNativeType # temporary hack return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; + return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; + # necessary as resolvers could be constructed on fly. return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; @@ -2546,6 +2766,15 @@ sub GetNativeType return "${type}*"; } +sub GetNativeTypeForCallbacks +{ + my $type = shift; + return "const String&" if $type eq "DOMString"; + + # Callbacks use raw pointers, so pass isParameter = 1 + return GetNativeType($type, 1); +} + sub TranslateParameter { my $signature = shift; @@ -2735,6 +2964,7 @@ sub RequiresCustomSignature } +# FIXME: Sort this array. my %non_wrapper_types = ( 'float' => 1, 'double' => 1, @@ -2749,6 +2979,7 @@ my %non_wrapper_types = ( 'unsigned long long' => 1, 'DOMString' => 1, 'CompareHow' => 1, + 'SerializedScriptValue' => 1, 'SVGAngle' => 1, 'SVGRect' => 1, 'SVGPoint' => 1, @@ -2821,6 +3052,8 @@ sub ReturnNativeToJSValue return "return v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned"; return "return v8DateOrNull($value)" if $type eq "Date"; + # long long and unsigned long long are not representable in ECMAScript. + return "return v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long"; return "return v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType"; return "return $value.v8Value()" if $nativeType eq "ScriptValue"; @@ -2833,6 +3066,8 @@ sub ReturnNativeToJSValue die "Unknown value for ConvertNullStringTo extended attribute"; } + $conv = $signature->extendedAttributes->{"ConvertScriptString"}; + return "v8StringOrNull(exec, $value)" if $conv; return "return v8String($value)"; } diff --git a/WebCore/bindings/scripts/IDLParser.pm b/WebCore/bindings/scripts/IDLParser.pm index 7db7747..c6742dc 100644 --- a/WebCore/bindings/scripts/IDLParser.pm +++ b/WebCore/bindings/scripts/IDLParser.pm @@ -80,10 +80,11 @@ sub Parse print " | *** Starting to parse $fileName...\n |\n" unless $beQuiet; - open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), (map { "-D$_" } split(' ', $defines)), $fileName); + $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), (map { "-D$_" } split(' ', $defines)), $fileName); close PP_IN; my @documentContent = <PP_OUT>; close PP_OUT; + waitpid($pid, 0); my $dataAvailable = 0; diff --git a/WebCore/bindings/scripts/IDLStructure.pm b/WebCore/bindings/scripts/IDLStructure.pm index 6224e54..e060252 100644 --- a/WebCore/bindings/scripts/IDLStructure.pm +++ b/WebCore/bindings/scripts/IDLStructure.pm @@ -96,7 +96,7 @@ $typeNamespaceSelector = '((?:' . $idlId . '*::)*)\s*(' . $idlDataType . '*)'; $exceptionSelector = 'exception\s*(' . $idlIdNs . '*)\s*([a-zA-Z\s{;]*};)'; $exceptionSubSelector = '{\s*' . $supportedTypes . '\s*(' . $idlType . '*)\s*;\s*}'; -$interfaceSelector = 'interface\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([a-zA-Z0-9_=\s(),;:\[\]]*)'; +$interfaceSelector = 'interface\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([a-zA-Z0-9_=\s(),;:\[\]&\|]*)'; $interfaceMethodSelector = '\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]]*)'; $interfaceParameterSelector = 'in\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)'; diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp new file mode 100644 index 0000000..6cfec74 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -0,0 +1,186 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <glib-object.h> +#include "config.h" + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "ExceptionCode.h" +#include "TestCallback.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMClass1.h" +#include "webkit/WebKitDOMClass1Private.h" +#include "webkit/WebKitDOMClass2.h" +#include "webkit/WebKitDOMClass2Private.h" +#include "webkit/WebKitDOMClass3.h" +#include "webkit/WebKitDOMClass3Private.h" +#include "webkit/WebKitDOMTestCallback.h" +#include "webkit/WebKitDOMTestCallbackPrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +gpointer kit(WebCore::TestCallback* obj) +{ + g_return_val_if_fail(obj != 0, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return ret; + + return DOMObjectCache::put(obj, WebKit::wrapTestCallback(obj)); +} + +} // namespace WebKit // + +gboolean +webkit_dom_test_callback_callback_with_class1param (WebKitDOMTestCallback *self, WebKitDOMClass1* class1param) +{ + g_return_val_if_fail (self, 0); + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail (class1param, 0); + WebCore::Class1 * _g_class1param = WebKit::core(class1param); + g_return_val_if_fail (_g_class1param, 0); + gboolean res = item->callbackWithClass1Param(_g_class1param); + return res; + +} + +gboolean +webkit_dom_test_callback_callback_with_class2param (WebKitDOMTestCallback *self, WebKitDOMClass2* class2param, gchar* str_arg) +{ + g_return_val_if_fail (self, 0); + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail (class2param, 0); + g_return_val_if_fail (str_arg, 0); + WebCore::Class2 * _g_class2param = WebKit::core(class2param); + g_return_val_if_fail (_g_class2param, 0); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + gboolean res = item->callbackWithClass2Param(_g_class2param, _g_str_arg); + return res; + +} + +glong +webkit_dom_test_callback_callback_with_non_bool_return_type (WebKitDOMTestCallback *self, WebKitDOMClass3* class3param) +{ + g_return_val_if_fail (self, 0); + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail (class3param, 0); + WebCore::Class3 * _g_class3param = WebKit::core(class3param); + g_return_val_if_fail (_g_class3param, 0); + glong res = item->callbackWithNonBoolReturnType(_g_class3param); + return res; + +} + + +G_DEFINE_TYPE(WebKitDOMTestCallback, webkit_dom_test_callback, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebKitDOMTestCallback* wrapTestCallback(WebCore::TestCallback* coreObject) +{ + g_return_val_if_fail(coreObject != 0, 0); + + WebKitDOMTestCallback* wrapper = WEBKIT_DOM_TEST_CALLBACK(g_object_new(WEBKIT_TYPE_DOM_TEST_CALLBACK, NULL)); + g_return_val_if_fail(wrapper != 0, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + + coreObject->ref(); + WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; + + return wrapper; +} + +WebCore::TestCallback* core(WebKitDOMTestCallback* request) +{ + g_return_val_if_fail(request != 0, 0); + + WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject != 0, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, +}; + + +static void webkit_dom_test_callback_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject != NULL) { + WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_callback_parent_class)->finalize(object); +} + +static void webkit_dom_test_callback_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_callback_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_callback_class_init(WebKitDOMTestCallbackClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_callback_finalize; + gobjectClass->set_property = webkit_dom_test_callback_set_property; + gobjectClass->get_property = webkit_dom_test_callback_get_property; + + + + +} + +static void webkit_dom_test_callback_init(WebKitDOMTestCallback* request) +{ +} + diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h new file mode 100644 index 0000000..088c457 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h @@ -0,0 +1,60 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebKitDOMTestCallback_h +#define WebKitDOMTestCallback_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_CALLBACK (webkit_dom_test_callback_get_type()) +#define WEBKIT_DOM_TEST_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallback)) +#define WEBKIT_DOM_TEST_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallbackClass) +#define WEBKIT_DOM_IS_TEST_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK)) +#define WEBKIT_DOM_IS_TEST_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_CALLBACK)) +#define WEBKIT_DOM_TEST_CALLBACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallbackClass)) + +struct _WebKitDOMTestCallback { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestCallbackClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_callback_get_type (void); + +WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_class1param (WebKitDOMTestCallback *self, WebKitDOMClass1* class1param); + +WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_class2param (WebKitDOMTestCallback *self, WebKitDOMClass2* class2param, gchar* str_arg); + +WEBKIT_API glong +webkit_dom_test_callback_callback_with_non_bool_return_type (WebKitDOMTestCallback *self, WebKitDOMClass3* class3param); + +G_END_DECLS + +#endif /* WebKitDOMTestCallback_h */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h new file mode 100644 index 0000000..45884b2 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h @@ -0,0 +1,39 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H +#define WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestCallback.h" +namespace WebKit { + WebKitDOMTestCallback * + wrapTestCallback(WebCore::TestCallback *coreObject); + + WebCore::TestCallback * + core(WebKitDOMTestCallback *request); + + gpointer + kit(WebCore::TestCallback* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp new file mode 100644 index 0000000..2be0277 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp @@ -0,0 +1,139 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <glib-object.h> +#include "config.h" + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "ExceptionCode.h" +#include "TestInterface.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMTestInterface.h" +#include "webkit/WebKitDOMTestInterfacePrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +gpointer kit(WebCore::TestInterface* obj) +{ + g_return_val_if_fail(obj != 0, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return ret; + + return DOMObjectCache::put(obj, WebKit::wrapTestInterface(obj)); +} + +} // namespace WebKit // + + +G_DEFINE_TYPE(WebKitDOMTestInterface, webkit_dom_test_interface, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebKitDOMTestInterface* wrapTestInterface(WebCore::TestInterface* coreObject) +{ + g_return_val_if_fail(coreObject != 0, 0); + + WebKitDOMTestInterface* wrapper = WEBKIT_DOM_TEST_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_INTERFACE, NULL)); + g_return_val_if_fail(wrapper != 0, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + + coreObject->ref(); + WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; + + return wrapper; +} + +WebCore::TestInterface* core(WebKitDOMTestInterface* request) +{ + g_return_val_if_fail(request != 0, 0); + + WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject != 0, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, +}; + + +static void webkit_dom_test_interface_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject != NULL) { + WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_interface_parent_class)->finalize(object); +} + +static void webkit_dom_test_interface_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_interface_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_interface_class_init(WebKitDOMTestInterfaceClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_interface_finalize; + gobjectClass->set_property = webkit_dom_test_interface_set_property; + gobjectClass->get_property = webkit_dom_test_interface_get_property; + + + + +} + +static void webkit_dom_test_interface_init(WebKitDOMTestInterface* request) +{ +} + diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h new file mode 100644 index 0000000..f9af866 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h @@ -0,0 +1,51 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebKitDOMTestInterface_h +#define WebKitDOMTestInterface_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_INTERFACE (webkit_dom_test_interface_get_type()) +#define WEBKIT_DOM_TEST_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterface)) +#define WEBKIT_DOM_TEST_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterfaceClass) +#define WEBKIT_DOM_IS_TEST_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE)) +#define WEBKIT_DOM_IS_TEST_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_INTERFACE)) +#define WEBKIT_DOM_TEST_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterfaceClass)) + +struct _WebKitDOMTestInterface { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestInterfaceClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_interface_get_type (void); + +G_END_DECLS + +#endif /* WebKitDOMTestInterface_h */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h new file mode 100644 index 0000000..45fb949 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h @@ -0,0 +1,39 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H +#define WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestInterface.h" +namespace WebKit { + WebKitDOMTestInterface * + wrapTestInterface(WebCore::TestInterface *coreObject); + + WebCore::TestInterface * + core(WebKitDOMTestInterface *request); + + gpointer + kit(WebCore::TestInterface* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp new file mode 100644 index 0000000..8c1bae2 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -0,0 +1,779 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <glib-object.h> +#include "config.h" + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "ExceptionCode.h" +#include "TestObj.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMSerializedScriptValue.h" +#include "webkit/WebKitDOMSerializedScriptValuePrivate.h" +#include "webkit/WebKitDOMTestObj.h" +#include "webkit/WebKitDOMTestObjPrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +gpointer kit(WebCore::TestObj* obj) +{ + g_return_val_if_fail(obj != 0, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return ret; + + return DOMObjectCache::put(obj, WebKit::wrapTestObj(obj)); +} + +} // namespace WebKit // + +void +webkit_dom_test_obj_void_method (WebKitDOMTestObj *self) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->voidMethod(); + +} + +void +webkit_dom_test_obj_void_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail (str_arg); + g_return_if_fail (obj_arg); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); + g_return_if_fail (_g_obj_arg); + item->voidMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg); + +} + +glong +webkit_dom_test_obj_int_method (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->intMethod(); + return res; + +} + +glong +webkit_dom_test_obj_int_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail (str_arg, 0); + g_return_val_if_fail (obj_arg, 0); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail (_g_obj_arg, 0); + glong res = item->intMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg); + return res; + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_obj_method (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethod()); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail (str_arg, 0); + g_return_val_if_fail (obj_arg, 0); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail (_g_obj_arg, 0); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg)); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +void +webkit_dom_test_obj_serialized_value (WebKitDOMTestObj *self, WebKitDOMSerializedScriptValue* serialized_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail (serialized_arg); + WebCore::SerializedScriptValue * _g_serialized_arg = WebKit::core(serialized_arg); + g_return_if_fail (_g_serialized_arg); + item->serializedValue(_g_serialized_arg); + +} + +void +webkit_dom_test_obj_method_with_exception (WebKitDOMTestObj *self, GError **error) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->methodWithException(ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + +} + + +/* TODO: event function webkit_dom_test_obj_add_event_listener */ + + +/* TODO: event function webkit_dom_test_obj_remove_event_listener */ + +void +webkit_dom_test_obj_with_dynamic_frame (WebKitDOMTestObj *self) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrame(); + +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_arg (WebKitDOMTestObj *self, glong int_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndArg(int_arg); + +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_optional_arg (WebKitDOMTestObj *self, glong int_arg, glong optional_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndOptionalArg(int_arg, optional_arg); + +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture (WebKitDOMTestObj *self, glong int_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndUserGesture(int_arg); + +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad (WebKitDOMTestObj *self, glong int_arg, glong optional_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndUserGestureASAD(int_arg, optional_arg); + +} + +void +webkit_dom_test_obj_with_script_state_void (WebKitDOMTestObj *self) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withScriptStateVoid(); + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObj()); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +void +webkit_dom_test_obj_with_script_state_void_exception (WebKitDOMTestObj *self, GError **error) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->withScriptStateVoidException(ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj_exception (WebKitDOMTestObj *self, GError **error) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObjException(ec)); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +void +webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->methodWithOptionalArg(opt); + +} + +void +webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg (WebKitDOMTestObj *self, glong non_opt, glong opt) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->methodWithNonOptionalArgAndOptionalArg(non_opt, opt); + +} + +void +webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args (WebKitDOMTestObj *self, glong non_opt, glong opt1, glong opt2) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->methodWithNonOptionalArgAndTwoOptionalArgs(non_opt, opt1, opt2); + +} + +glong +webkit_dom_test_obj_get_read_only_int_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->readOnlyIntAttr(); + return res; + +} + +gchar* +webkit_dom_test_obj_get_read_only_string_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->readOnlyStringAttr()); + return res; + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_get_read_only_test_obj_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->readOnlyTestObjAttr()); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +glong +webkit_dom_test_obj_get_int_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->intAttr(); + return res; + +} + +void +webkit_dom_test_obj_set_int_attr (WebKitDOMTestObj *self, glong value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setIntAttr(value); + +} + +gint64 +webkit_dom_test_obj_get_long_long_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + gint64 res = item->longLongAttr(); + return res; + +} + +void +webkit_dom_test_obj_set_long_long_attr (WebKitDOMTestObj *self, gint64 value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setLongLongAttr(value); + +} + +guint64 +webkit_dom_test_obj_get_unsigned_long_long_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + guint64 res = item->unsignedLongLongAttr(); + return res; + +} + +void +webkit_dom_test_obj_set_unsigned_long_long_attr (WebKitDOMTestObj *self, guint64 value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setUnsignedLongLongAttr(value); + +} + +gchar* +webkit_dom_test_obj_get_string_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->stringAttr()); + return res; + +} + +void +webkit_dom_test_obj_set_string_attr (WebKitDOMTestObj *self, gchar* value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail (value); + WebCore::String _g_value = WebCore::String::fromUTF8(value); + item->setStringAttr(_g_value); + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_get_test_obj_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->testObjAttr()); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +void +webkit_dom_test_obj_set_test_obj_attr (WebKitDOMTestObj *self, WebKitDOMTestObj* value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail (value); + WebCore::TestObj * _g_value = WebKit::core(value); + g_return_if_fail (_g_value); + item->setTestObjAttr(_g_value); + +} + +glong +webkit_dom_test_obj_get_attr_with_exception (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->attrWithException(); + return res; + +} + +void +webkit_dom_test_obj_set_attr_with_exception (WebKitDOMTestObj *self, glong value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setAttrWithException(value); + +} + +glong +webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->attrWithSetterException(); + return res; + +} + +void +webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setAttrWithSetterException(value); + +} + +glong +webkit_dom_test_obj_get_attr_with_getter_exception (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->attrWithGetterException(); + return res; + +} + +void +webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setAttrWithGetterException(value); + +} + +gchar* +webkit_dom_test_obj_get_script_string_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->scriptStringAttr()); + return res; + +} + + +G_DEFINE_TYPE(WebKitDOMTestObj, webkit_dom_test_obj, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebKitDOMTestObj* wrapTestObj(WebCore::TestObj* coreObject) +{ + g_return_val_if_fail(coreObject != 0, 0); + + WebKitDOMTestObj* wrapper = WEBKIT_DOM_TEST_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_OBJ, NULL)); + g_return_val_if_fail(wrapper != 0, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + + coreObject->ref(); + WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; + + return wrapper; +} + +WebCore::TestObj* core(WebKitDOMTestObj* request) +{ + g_return_val_if_fail(request != 0, 0); + + WebCore::TestObj* coreObject = static_cast<WebCore::TestObj*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject != 0, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, + PROP_READ_ONLY_INT_ATTR, + PROP_READ_ONLY_STRING_ATTR, + PROP_READ_ONLY_TEST_OBJ_ATTR, + PROP_INT_ATTR, + PROP_LONG_LONG_ATTR, + PROP_UNSIGNED_LONG_LONG_ATTR, + PROP_STRING_ATTR, + PROP_TEST_OBJ_ATTR, + PROP_ATTR_WITH_EXCEPTION, + PROP_ATTR_WITH_SETTER_EXCEPTION, + PROP_ATTR_WITH_GETTER_EXCEPTION, + PROP_CUSTOM_ATTR, + PROP_SCRIPT_STRING_ATTR, +}; + + +static void webkit_dom_test_obj_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject != NULL) { + WebCore::TestObj* coreObject = static_cast<WebCore::TestObj *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->finalize(object); +} + +static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebKitDOMTestObj *self = WEBKIT_DOM_TEST_OBJ(object); + WebCore::TestObj* coreSelf = WebKit::core(self); + switch (prop_id) { + case PROP_INT_ATTR: + { + coreSelf->setIntAttr((g_value_get_long(value)) ); + break; + } + case PROP_UNSIGNED_LONG_LONG_ATTR: + { + coreSelf->setUnsignedLongLongAttr((g_value_get_uint64(value)) ); + break; + } + case PROP_STRING_ATTR: + { + coreSelf->setStringAttr(WebCore::String::fromUTF8(g_value_get_string(value)) ); + break; + } + case PROP_ATTR_WITH_EXCEPTION: + { + coreSelf->setAttrWithException((g_value_get_long(value)) ); + break; + } + case PROP_ATTR_WITH_SETTER_EXCEPTION: + { + coreSelf->setAttrWithSetterException((g_value_get_long(value)) ); + break; + } + case PROP_ATTR_WITH_GETTER_EXCEPTION: + { + coreSelf->setAttrWithGetterException((g_value_get_long(value)) ); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); + WebCore::TestObj* coreSelf = WebKit::core(self); + switch (prop_id) { + case PROP_READ_ONLY_INT_ATTR: + { + g_value_set_long(value, coreSelf->readOnlyIntAttr()); + break; + } + case PROP_READ_ONLY_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->readOnlyStringAttr())); + break; + } + case PROP_READ_ONLY_TEST_OBJ_ATTR: + { + RefPtr<WebCore::TestObj> ptr = coreSelf->readOnlyTestObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_INT_ATTR: + { + g_value_set_long(value, coreSelf->intAttr()); + break; + } + case PROP_LONG_LONG_ATTR: + { + g_value_set_int64(value, coreSelf->longLongAttr()); + break; + } + case PROP_UNSIGNED_LONG_LONG_ATTR: + { + g_value_set_uint64(value, coreSelf->unsignedLongLongAttr()); + break; + } + case PROP_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttr())); + break; + } + case PROP_TEST_OBJ_ATTR: + { + RefPtr<WebCore::TestObj> ptr = coreSelf->testObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_ATTR_WITH_EXCEPTION: + { + g_value_set_long(value, coreSelf->attrWithException()); + break; + } + case PROP_ATTR_WITH_SETTER_EXCEPTION: + { + g_value_set_long(value, coreSelf->attrWithSetterException()); + break; + } + case PROP_ATTR_WITH_GETTER_EXCEPTION: + { + g_value_set_long(value, coreSelf->attrWithGetterException()); + break; + } + case PROP_SCRIPT_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->scriptStringAttr())); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_obj_class_init(WebKitDOMTestObjClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_obj_finalize; + gobjectClass->set_property = webkit_dom_test_obj_set_property; + gobjectClass->get_property = webkit_dom_test_obj_get_property; + + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_INT_ATTR, + g_param_spec_long("read-only-int-attr", /* name */ + "test_obj_read-only-int-attr", /* short description */ + "read-only glong TestObj.read-only-int-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_STRING_ATTR, + g_param_spec_string("read-only-string-attr", /* name */ + "test_obj_read-only-string-attr", /* short description */ + "read-only gchar* TestObj.read-only-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_TEST_OBJ_ATTR, + g_param_spec_object("read-only-test-obj-attr", /* name */ + "test_obj_read-only-test-obj-attr", /* short description */ + "read-only WebKitDOMTestObj* TestObj.read-only-test-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_INT_ATTR, + g_param_spec_long("int-attr", /* name */ + "test_obj_int-attr", /* short description */ + "read-write glong TestObj.int-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_LONG_LONG_ATTR, + g_param_spec_int64("long-long-attr", /* name */ + "test_obj_long-long-attr", /* short description */ + "read-write gint64 TestObj.long-long-attr", /* longer - could do with some extra doc stuff here */ + G_MININT64, /* min */ +G_MAXINT64, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_UNSIGNED_LONG_LONG_ATTR, + g_param_spec_uint64("unsigned-long-long-attr", /* name */ + "test_obj_unsigned-long-long-attr", /* short description */ + "read-write guint64 TestObj.unsigned-long-long-attr", /* longer - could do with some extra doc stuff here */ + 0, /* min */ +G_MAXUINT64, /* min */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRING_ATTR, + g_param_spec_string("string-attr", /* name */ + "test_obj_string-attr", /* short description */ + "read-write gchar* TestObj.string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_TEST_OBJ_ATTR, + g_param_spec_object("test-obj-attr", /* name */ + "test_obj_test-obj-attr", /* short description */ + "read-write WebKitDOMTestObj* TestObj.test-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_EXCEPTION, + g_param_spec_long("attr-with-exception", /* name */ + "test_obj_attr-with-exception", /* short description */ + "read-write glong TestObj.attr-with-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_SETTER_EXCEPTION, + g_param_spec_long("attr-with-setter-exception", /* name */ + "test_obj_attr-with-setter-exception", /* short description */ + "read-write glong TestObj.attr-with-setter-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_GETTER_EXCEPTION, + g_param_spec_long("attr-with-getter-exception", /* name */ + "test_obj_attr-with-getter-exception", /* short description */ + "read-write glong TestObj.attr-with-getter-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_SCRIPT_STRING_ATTR, + g_param_spec_string("script-string-attr", /* name */ + "test_obj_script-string-attr", /* short description */ + "read-only gchar* TestObj.script-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + + + +} + +static void webkit_dom_test_obj_init(WebKitDOMTestObj* request) +{ +} + diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h new file mode 100644 index 0000000..f8ad9c4 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h @@ -0,0 +1,177 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebKitDOMTestObj_h +#define WebKitDOMTestObj_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_OBJ (webkit_dom_test_obj_get_type()) +#define WEBKIT_DOM_TEST_OBJ(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObj)) +#define WEBKIT_DOM_TEST_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObjClass) +#define WEBKIT_DOM_IS_TEST_OBJ(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_OBJ)) +#define WEBKIT_DOM_IS_TEST_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_OBJ)) +#define WEBKIT_DOM_TEST_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObjClass)) + +struct _WebKitDOMTestObj { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestObjClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_obj_get_type (void); + +WEBKIT_API void +webkit_dom_test_obj_void_method (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_void_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API glong +webkit_dom_test_obj_int_method (WebKitDOMTestObj *self); + +WEBKIT_API glong +webkit_dom_test_obj_int_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_obj_method (WebKitDOMTestObj *self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API void +webkit_dom_test_obj_serialized_value (WebKitDOMTestObj *self, WebKitDOMSerializedScriptValue* serialized_arg); + +WEBKIT_API void +webkit_dom_test_obj_method_with_exception (WebKitDOMTestObj *self, GError **error); + + +/* TODO: event function webkit_dom_test_obj_add_event_listener */ + + +/* TODO: event function webkit_dom_test_obj_remove_event_listener */ + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_arg (WebKitDOMTestObj *self, glong int_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_optional_arg (WebKitDOMTestObj *self, glong int_arg, glong optional_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture (WebKitDOMTestObj *self, glong int_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad (WebKitDOMTestObj *self, glong int_arg, glong optional_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_script_state_void (WebKitDOMTestObj *self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_with_script_state_void_exception (WebKitDOMTestObj *self, GError **error); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj_exception (WebKitDOMTestObj *self, GError **error); + +WEBKIT_API void +webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt); + +WEBKIT_API void +webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg (WebKitDOMTestObj *self, glong non_opt, glong opt); + +WEBKIT_API void +webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args (WebKitDOMTestObj *self, glong non_opt, glong opt1, glong opt2); + +WEBKIT_API glong +webkit_dom_test_obj_get_read_only_int_attr (WebKitDOMTestObj *self); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_read_only_string_attr (WebKitDOMTestObj *self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_get_read_only_test_obj_attr (WebKitDOMTestObj *self); + +WEBKIT_API glong +webkit_dom_test_obj_get_int_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_int_attr (WebKitDOMTestObj *self, glong value); + +WEBKIT_API gint64 +webkit_dom_test_obj_get_long_long_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_long_long_attr (WebKitDOMTestObj *self, gint64 value); + +WEBKIT_API guint64 +webkit_dom_test_obj_get_unsigned_long_long_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_unsigned_long_long_attr (WebKitDOMTestObj *self, guint64 value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_string_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_string_attr (WebKitDOMTestObj *self, gchar* value); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_get_test_obj_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_test_obj_attr (WebKitDOMTestObj *self, WebKitDOMTestObj* value); + +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_exception (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_exception (WebKitDOMTestObj *self, glong value); + +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value); + +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_getter_exception (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_script_string_attr (WebKitDOMTestObj *self); + +G_END_DECLS + +#endif /* WebKitDOMTestObj_h */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h new file mode 100644 index 0000000..78cd87f --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h @@ -0,0 +1,39 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WEB_KIT_DOM_TEST_OBJ_PRIVATE_H +#define WEB_KIT_DOM_TEST_OBJ_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestObj.h" +namespace WebKit { + WebKitDOMTestObj * + wrapTestObj(WebCore::TestObj *coreObject); + + WebCore::TestObj * + core(WebKitDOMTestObj *request); + + gpointer + kit(WebCore::TestObj* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_OBJ_PRIVATE_H */ diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp new file mode 100644 index 0000000..2d0cfae --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -0,0 +1,100 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" + +#if ENABLE(DATABASE) + +#include "JSTestCallback.h" + +#include "JSClass1.h" +#include "JSClass2.h" +#include "ScriptExecutionContext.h" +#include <runtime/JSLock.h> +#include <wtf/MainThread.h> + +using namespace JSC; + +namespace WebCore { + +JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject) + : m_data(new JSCallbackData(callback, globalObject)) + , m_isolatedWorld(globalObject->world()) +{ +} + +JSTestCallback::~JSTestCallback() +{ + callOnMainThread(JSCallbackData::deleteData, m_data); +#ifndef NDEBUG + m_data = 0; +#endif +} + +// Functions + +bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param) +{ + ASSERT(m_data); + ASSERT(context); + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); + if (!globalObject) + return true; + + ExecState* exec = globalObject->globalExec(); + MarkedArgumentBuffer args; + args.append(toJS(exec, class1Param)); + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + +bool JSTestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg) +{ + ASSERT(m_data); + ASSERT(context); + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); + if (!globalObject) + return true; + + ExecState* exec = globalObject->globalExec(); + MarkedArgumentBuffer args; + args.append(toJS(exec, class2Param)); + args.append(toJS(exec, strArg)); + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + +} + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/WebCore/bindings/scripts/test/JS/JSTestCallback.h new file mode 100644 index 0000000..6e8f083 --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -0,0 +1,58 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef JSTestCallback_h +#define JSTestCallback_h + +#if ENABLE(DATABASE) + +#include "JSCallbackData.h" +#include "TestCallback.h" +#include <wtf/Forward.h> + +namespace WebCore { + +class JSTestCallback : public TestCallback { +public: + static PassRefPtr<JSTestCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) + { + return adoptRef(new JSTestCallback(callback, globalObject)); + } + + virtual ~JSTestCallback(); + + // Functions + virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param); + virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param); + virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param); + +private: + JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*); + + JSCallbackData* m_data; + RefPtr<DOMWrapperWorld> m_isolatedWorld; +}; + +} // namespace WebCore + +#endif // ENABLE(DATABASE) + +#endif diff --git a/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp new file mode 100644 index 0000000..8855481 --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -0,0 +1,193 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "JSTestInterface.h" + +#include "TestInterface.h" +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestInterface); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfaceTableValues[2] = +{ + { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfaceTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSTestInterfaceTableValues, 0 }; +#else + { 2, 1, JSTestInterfaceTableValues, 0 }; +#endif + +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfaceConstructorTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfaceConstructorTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSTestInterfaceConstructorTableValues, 0 }; +#else + { 1, 0, JSTestInterfaceConstructorTableValues, 0 }; +#endif + +class JSTestInterfaceConstructor : public DOMConstructorObject { +public: + JSTestInterfaceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestInterfaceConstructor::createStructure(globalObject->objectPrototype()), globalObject) + { + putDirect(exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), None); + } + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); + virtual const ClassInfo* classInfo() const { return &s_info; } + static const ClassInfo s_info; + + static PassRefPtr<Structure> createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); + } + +protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSObject* constructTestInterface(ExecState* exec, JSObject* constructor, const ArgList&) + { + ScriptExecutionContext* context = static_cast<JSTestInterfaceConstructor*>(constructor)->scriptExecutionContext(); + if (!context) + return throwError(exec, ReferenceError); + return asObject(toJS(exec, static_cast<JSTestInterfaceConstructor*>(constructor)->globalObject(), TestInterface::create(context))); + } + virtual ConstructType getConstructData(ConstructData& constructData) + { + constructData.native.function = constructTestInterface; + return ConstructTypeHost; + } +}; + +const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", 0, &JSTestInterfaceConstructorTable, 0 }; + +bool JSTestInterfaceConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestInterfaceConstructor, DOMObject>(exec, &JSTestInterfaceConstructorTable, this, propertyName, slot); +} + +bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestInterfaceConstructor, DOMObject>(exec, &JSTestInterfaceConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfacePrototypeTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfacePrototypeTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSTestInterfacePrototypeTableValues, 0 }; +#else + { 1, 0, JSTestInterfacePrototypeTableValues, 0 }; +#endif + +const ClassInfo JSTestInterfacePrototype::s_info = { "TestInterfacePrototype", 0, &JSTestInterfacePrototypeTable, 0 }; + +JSObject* JSTestInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestInterface>(exec, globalObject); +} + +const ClassInfo JSTestInterface::s_info = { "TestInterface", 0, &JSTestInterfaceTable, 0 }; + +JSTestInterface::JSTestInterface(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestInterface> impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSTestInterface::~JSTestInterface() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSTestInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSTestInterfacePrototype(JSTestInterfacePrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSTestInterface::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestInterface, Base>(exec, &JSTestInterfaceTable, this, propertyName, slot); +} + +bool JSTestInterface::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestInterface, Base>(exec, &JSTestInterfaceTable, this, propertyName, descriptor); +} + +JSValue jsTestInterfaceConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestInterface* domObject = static_cast<JSTestInterface*>(asObject(slotBase)); + return JSTestInterface::getConstructor(exec, domObject->globalObject()); +} +JSValue JSTestInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestInterface* object) +{ + return getDOMObjectWrapper<JSTestInterface>(exec, globalObject, object); +} +TestInterface* toTestInterface(JSC::JSValue value) +{ + return value.inherits(&JSTestInterface::s_info) ? static_cast<JSTestInterface*>(asObject(value))->impl() : 0; +} + +} diff --git a/WebCore/bindings/scripts/test/JS/JSTestInterface.h b/WebCore/bindings/scripts/test/JS/JSTestInterface.h new file mode 100644 index 0000000..c076dbd --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestInterface.h @@ -0,0 +1,81 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef JSTestInterface_h +#define JSTestInterface_h + +#include "JSDOMBinding.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class TestInterface; + +class JSTestInterface : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSTestInterface(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestInterface>); + virtual ~JSTestInterface(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + TestInterface* impl() const { return m_impl.get(); } + +private: + RefPtr<TestInterface> m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestInterface*); +TestInterface* toTestInterface(JSC::JSValue); + +class JSTestInterfacePrototype : public JSC::JSObject { + typedef JSC::JSObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + JSTestInterfacePrototype(NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObject(structure) { } +protected: + static const unsigned StructureFlags = Base::StructureFlags; +}; + +// Attributes + +JSC::JSValue jsTestInterfaceConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp new file mode 100644 index 0000000..da99de2 --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -0,0 +1,813 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "JSTestObj.h" + +#include "JSEventListener.h" +#include "JSTestObj.h" +#include "JSlog.h" +#include "KURL.h" +#include "ScriptCallStack.h" +#include "SerializedScriptValue.h" +#include "TestObj.h" +#include <runtime/Error.h> +#include <runtime/JSNumberCell.h> +#include <runtime/JSString.h> +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestObj); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjTableValues[15] = +{ + { "readOnlyIntAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyIntAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyTestObjAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyTestObjAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "intAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjIntAttr), (intptr_t)setJSTestObjIntAttr THUNK_GENERATOR(0) }, + { "longLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjLongLongAttr), (intptr_t)setJSTestObjLongLongAttr THUNK_GENERATOR(0) }, + { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongAttr), (intptr_t)setJSTestObjUnsignedLongLongAttr THUNK_GENERATOR(0) }, + { "stringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttr), (intptr_t)setJSTestObjStringAttr THUNK_GENERATOR(0) }, + { "testObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestObjAttr), (intptr_t)setJSTestObjTestObjAttr THUNK_GENERATOR(0) }, + { "attrWithException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithException), (intptr_t)setJSTestObjAttrWithException THUNK_GENERATOR(0) }, + { "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t)setJSTestObjAttrWithSetterException THUNK_GENERATOR(0) }, + { "attrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterException), (intptr_t)setJSTestObjAttrWithGetterException THUNK_GENERATOR(0) }, + { "customAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCustomAttr), (intptr_t)setJSTestObjCustomAttr THUNK_GENERATOR(0) }, + { "scriptStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjScriptStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 127, JSTestObjTableValues, 0 }; +#else + { 34, 31, JSTestObjTableValues, 0 }; +#endif + +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjConstructorTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjConstructorTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSTestObjConstructorTableValues, 0 }; +#else + { 1, 0, JSTestObjConstructorTableValues, 0 }; +#endif + +class JSTestObjConstructor : public DOMConstructorObject { +public: + JSTestObjConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestObjConstructor::createStructure(globalObject->objectPrototype()), globalObject) + { + putDirect(exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), None); + } + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); + virtual const ClassInfo* classInfo() const { return &s_info; } + static const ClassInfo s_info; + + static PassRefPtr<Structure> createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); + } + +protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; +}; + +const ClassInfo JSTestObjConstructor::s_info = { "TestObjConstructor", 0, &JSTestObjConstructorTable, 0 }; + +bool JSTestObjConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, slot); +} + +bool JSTestObjConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjPrototypeTableValues[26] = +{ + { "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "voidMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "intMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "intMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "objMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "objMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "serializedValue", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1 THUNK_GENERATOR(0) }, + { "methodWithException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "customMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "customMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "customArgsAndException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomArgsAndException), (intptr_t)1 THUNK_GENERATOR(0) }, + { "addEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "removeEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "withDynamicFrame", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrame), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndUserGesture", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture), (intptr_t)1 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndUserGestureASAD", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD), (intptr_t)2 THUNK_GENERATOR(0) }, + { "withScriptStateVoid", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateObj", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateVoidException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoidException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateObjException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObjException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "methodWithOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "methodWithNonOptionalArgAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "methodWithNonOptionalArgAndTwoOptionalArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 8191, JSTestObjPrototypeTableValues, 0 }; +#else + { 67, 63, JSTestObjPrototypeTableValues, 0 }; +#endif + +const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 }; + +JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestObj>(exec, globalObject); +} + +bool JSTestObjPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticFunctionSlot<JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, slot); +} + +bool JSTestObjPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticFunctionDescriptor<JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, descriptor); +} + +const ClassInfo JSTestObj::s_info = { "TestObj", 0, &JSTestObjTable, 0 }; + +JSTestObj::JSTestObj(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestObj> impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSTestObj::~JSTestObj() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSTestObj::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSTestObjPrototype(JSTestObjPrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSTestObj::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestObj, Base>(exec, &JSTestObjTable, this, propertyName, slot); +} + +bool JSTestObj::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestObj, Base>(exec, &JSTestObjTable, this, propertyName, descriptor); +} + +JSValue jsTestObjReadOnlyIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->readOnlyIntAttr()); + return result; +} + +JSValue jsTestObjReadOnlyStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->readOnlyStringAttr()); + return result; +} + +JSValue jsTestObjReadOnlyTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->readOnlyTestObjAttr())); + return result; +} + +JSValue jsTestObjIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->intAttr()); + return result; +} + +JSValue jsTestObjLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->longLongAttr()); + return result; +} + +JSValue jsTestObjUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->unsignedLongLongAttr()); + return result; +} + +JSValue jsTestObjStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->stringAttr()); + return result; +} + +JSValue jsTestObjTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->testObjAttr())); + return result; +} + +JSValue jsTestObjAttrWithException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->attrWithException()); + return result; +} + +JSValue jsTestObjAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->attrWithSetterException()); + return result; +} + +JSValue jsTestObjAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->attrWithGetterException()); + return result; +} + +JSValue jsTestObjCustomAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + return castedThis->customAttr(exec); +} + +JSValue jsTestObjScriptStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsOwnedStringOrNull(exec, imp->scriptStringAttr()); + return result; +} + +JSValue jsTestObjConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* domObject = static_cast<JSTestObj*>(asObject(slotBase)); + return JSTestObj::getConstructor(exec, domObject->globalObject()); +} +void JSTestObj::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + lookupPut<JSTestObj, Base>(exec, propertyName, value, &JSTestObjTable, this, slot); +} + +void setJSTestObjIntAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setIntAttr(value.toInt32(exec)); +} + +void setJSTestObjLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setLongLongAttr(static_cast<long long>(value.toInteger(exec))); +} + +void setJSTestObjUnsignedLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setUnsignedLongLongAttr(static_cast<unsigned long long>(value.toInteger(exec))); +} + +void setJSTestObjStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setStringAttr(ustringToString(value.toString(exec))); +} + +void setJSTestObjTestObjAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setTestObjAttr(toTestObj(value)); +} + +void setJSTestObjAttrWithException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttrWithException(value.toInt32(exec)); +} + +void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttrWithSetterException(value.toInt32(exec)); +} + +void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttrWithGetterException(value.toInt32(exec)); +} + +void setJSTestObjCustomAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + static_cast<JSTestObj*>(thisObject)->setCustomAttr(exec, value); +} + +JSValue JSTestObj::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestObjConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + imp->voidMethod(); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = args.at(0).toInt32(exec); + const String& strArg = ustringToString(args.at(1).toString(exec)); + TestObj* objArg = toTestObj(args.at(2)); + + imp->voidMethodWithArgs(intArg, strArg, objArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = jsNumber(exec, imp->intMethod()); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = args.at(0).toInt32(exec); + const String& strArg = ustringToString(args.at(1).toString(exec)); + TestObj* objArg = toTestObj(args.at(2)); + + + JSC::JSValue result = jsNumber(exec, imp->intMethodWithArgs(intArg, strArg, objArg)); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethod())); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = args.at(0).toInt32(exec); + const String& strArg = ustringToString(args.at(1).toString(exec)); + TestObj* objArg = toTestObj(args.at(2)); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethodWithArgs(intArg, strArg, objArg))); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, args.at(0)); + + imp->serializedValue(serializedArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + imp->methodWithException(ec); + setDOMException(exec, ec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + return castedThis->customMethod(exec, args); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + return castedThis->customMethodWithArgs(exec, args); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + ScriptCallStack callStack(exec, args, 1); + log* intArg = tolog(args.at(0)); + + imp->customArgsAndException(intArg, &callStack, ec); + setDOMException(exec, ec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue listener = args.at(1); + if (!listener.isObject()) + return jsUndefined(); + imp->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), args.at(2).toBoolean(exec)); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue listener = args.at(1); + if (!listener.isObject()) + return jsUndefined(); + imp->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + + imp->withDynamicFrame(dynamicFrame); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + int intArg = args.at(1).toInt32(exec); + + imp->withDynamicFrameAndArg(dynamicFrame, intArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + int intArg = args.at(1).toInt32(exec); + + int argsCount = args.size(); + if (argsCount < 3) { + imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg); + return jsUndefined(); + } + + int optionalArg = args.at(2).toInt32(exec); + + imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + int intArg = args.at(1).toInt32(exec); + + imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec)); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + int intArg = args.at(1).toInt32(exec); + + int argsCount = args.size(); + if (argsCount < 3) { + imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg); + return jsUndefined(); + } + + int optionalArg = args.at(2).toInt32(exec); + + imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec)); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + imp->withScriptStateVoid(exec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->withScriptStateObj(exec))); + if (exec->hadException()) + return jsUndefined(); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + imp->withScriptStateVoidException(exec, ec); + setDOMException(exec, ec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->withScriptStateObjException(exec, ec))); + setDOMException(exec, ec); + if (exec->hadException()) + return jsUndefined(); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + int argsCount = args.size(); + if (argsCount < 1) { + imp->methodWithOptionalArg(); + return jsUndefined(); + } + + int opt = args.at(0).toInt32(exec); + + imp->methodWithOptionalArg(opt); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int nonOpt = args.at(0).toInt32(exec); + + int argsCount = args.size(); + if (argsCount < 2) { + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); + return jsUndefined(); + } + + int opt = args.at(1).toInt32(exec); + + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int nonOpt = args.at(0).toInt32(exec); + + int argsCount = args.size(); + if (argsCount < 2) { + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); + return jsUndefined(); + } + + int opt1 = args.at(1).toInt32(exec); + if (argsCount < 3) { + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1); + return jsUndefined(); + } + + int opt2 = args.at(2).toInt32(exec); + + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); + return jsUndefined(); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* object) +{ + return getDOMObjectWrapper<JSTestObj>(exec, globalObject, object); +} +TestObj* toTestObj(JSC::JSValue value) +{ + return value.inherits(&JSTestObj::s_info) ? static_cast<JSTestObj*>(asObject(value))->impl() : 0; +} + +} diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.h b/WebCore/bindings/scripts/test/JS/JSTestObj.h new file mode 100644 index 0000000..f726efb --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -0,0 +1,141 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef JSTestObj_h +#define JSTestObj_h + +#include "JSDOMBinding.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class TestObj; + +class JSTestObj : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSTestObj(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestObj>); + virtual ~JSTestObj(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom attributes + JSC::JSValue customAttr(JSC::ExecState*) const; + void setCustomAttr(JSC::ExecState*, JSC::JSValue); + + // Custom functions + JSC::JSValue customMethod(JSC::ExecState*, const JSC::ArgList&); + JSC::JSValue customMethodWithArgs(JSC::ExecState*, const JSC::ArgList&); + TestObj* impl() const { return m_impl.get(); } + +private: + RefPtr<TestObj> m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestObj*); +TestObj* toTestObj(JSC::JSValue); + +class JSTestObjPrototype : public JSC::JSObject { + typedef JSC::JSObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + JSTestObjPrototype(NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObject(structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +// Functions + +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +// Attributes + +JSC::JSValue jsTestObjReadOnlyIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjReadOnlyStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjReadOnlyTestObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjIntAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjLongLongAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjUnsignedLongLongAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjUnsignedLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjTestObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjTestObjAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjCustomAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjCustomAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjScriptStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h b/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h new file mode 100644 index 0000000..1213c6f --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class DOMClass1; +@class DOMClass2; +@class DOMClass3; +@class DOMClass5; +@class DOMClass6; +@class NSString; + +@interface DOMTestCallback : DOMObject +- (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param; +- (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg; +- (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param; +- (int)customCallback:(DOMClass5 *)class5Param class6Param:(DOMClass6 *)class6Param; +@end + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm new file mode 100644 index 0000000..5201a91 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm @@ -0,0 +1,122 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" + +#if ENABLE(DATABASE) + +#import "DOMInternal.h" + +#import "DOMTestCallback.h" + +#import "Class1.h" +#import "Class2.h" +#import "Class3.h" +#import "Class5.h" +#import "Class6.h" +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMClass1Internal.h" +#import "DOMClass2Internal.h" +#import "DOMClass3Internal.h" +#import "DOMClass5Internal.h" +#import "DOMClass6Internal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestCallbackInternal.h" +#import "ExceptionHandlers.h" +#import "KURL.h" +#import "TestCallback.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestCallback*>(_internal) + +@implementation DOMTestCallback + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestCallback class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param +{ + return IMPL->callbackWithClass1Param(core(class1Param)); +} + +- (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg +{ + return IMPL->callbackWithClass2Param(core(class2Param), strArg); +} + +- (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param +{ + return IMPL->callbackWithNonBoolReturnType(core(class3Param)); +} + +- (int)customCallback:(DOMClass5 *)class5Param class6Param:(DOMClass6 *)class6Param +{ + return IMPL->customCallback(core(class5Param), core(class6Param)); +} + +@end + +WebCore::TestCallback* core(DOMTestCallback *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestCallback*>(wrapper->_internal) : 0; +} + +DOMTestCallback *kit(WebCore::TestCallback* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestCallback *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestCallback *wrapper = [[DOMTestCallback alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h b/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h new file mode 100644 index 0000000..d8ea940 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h @@ -0,0 +1,38 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMTestCallback.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestCallback; +} + +WebCore::TestCallback* core(DOMTestCallback *); +DOMTestCallback *kit(WebCore::TestCallback*); + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h new file mode 100644 index 0000000..db7be28 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@interface DOMTestInterface : DOMObject +@end + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm new file mode 100644 index 0000000..a88b366 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm @@ -0,0 +1,86 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "DOMInternal.h" + +#import "DOMTestInterface.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestInterfaceInternal.h" +#import "ExceptionHandlers.h" +#import "TestInterface.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestInterface*>(_internal) + +@implementation DOMTestInterface + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestInterface class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +@end + +WebCore::TestInterface* core(DOMTestInterface *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestInterface*>(wrapper->_internal) : 0; +} + +DOMTestInterface *kit(WebCore::TestInterface* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestInterface *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestInterface *wrapper = [[DOMTestInterface alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h b/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h new file mode 100644 index 0000000..fef60a3 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h @@ -0,0 +1,38 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMTestInterface.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestInterface; +} + +WebCore::TestInterface* core(DOMTestInterface *); +DOMTestInterface *kit(WebCore::TestInterface*); + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h new file mode 100644 index 0000000..dd9d2ee --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class DOMTestObj; +@class DOMlog; +@class NSString; +@protocol DOMEventListener; + +@interface DOMTestObj : DOMObject +- (int)readOnlyIntAttr; +- (NSString *)readOnlyStringAttr; +- (DOMTestObj *)readOnlyTestObjAttr; +- (int)intAttr; +- (void)setIntAttr:(int)newIntAttr; +- (long long)longLongAttr; +- (void)setLongLongAttr:(long long)newLongLongAttr; +- (unsigned long long)unsignedLongLongAttr; +- (void)setUnsignedLongLongAttr:(unsigned long long)newUnsignedLongLongAttr; +- (NSString *)stringAttr; +- (void)setStringAttr:(NSString *)newStringAttr; +- (DOMTestObj *)testObjAttr; +- (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr; +- (int)attrWithException; +- (void)setAttrWithException:(int)newAttrWithException; +- (int)attrWithSetterException; +- (void)setAttrWithSetterException:(int)newAttrWithSetterException; +- (int)attrWithGetterException; +- (void)setAttrWithGetterException:(int)newAttrWithGetterException; +- (int)customAttr; +- (void)setCustomAttr:(int)newCustomAttr; +- (NSString *)scriptStringAttr; +- (void)voidMethod; +- (void)voidMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (int)intMethod; +- (int)intMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (DOMTestObj *)objMethod; +- (DOMTestObj *)objMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (void)serializedValue:(NSString *)serializedArg; +- (void)methodWithException; +- (void)customMethod; +- (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (void)customArgsAndException:(DOMlog *)intArg; +- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture; +- (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture; +- (void)withDynamicFrame; +- (void)withDynamicFrameAndArg:(int)intArg; +- (void)withDynamicFrameAndOptionalArg:(int)intArg optionalArg:(int)optionalArg; +- (void)withDynamicFrameAndUserGesture:(int)intArg; +- (void)withDynamicFrameAndUserGestureASAD:(int)intArg optionalArg:(int)optionalArg; +- (void)withScriptStateVoid; +- (DOMTestObj *)withScriptStateObj; +- (void)withScriptStateVoidException; +- (DOMTestObj *)withScriptStateObjException; +- (void)methodWithOptionalArg:(int)opt; +- (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt; +- (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2; +@end + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm new file mode 100644 index 0000000..b964e36 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -0,0 +1,340 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "DOMInternal.h" + +#import "DOMTestObj.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestObjInternal.h" +#import "DOMlogInternal.h" +#import "EventListener.h" +#import "ExceptionHandlers.h" +#import "KURL.h" +#import "ObjCEventListener.h" +#import "SerializedScriptValue.h" +#import "TestObj.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import "log.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestObj*>(_internal) + +@implementation DOMTestObj + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestObj class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (int)readOnlyIntAttr +{ + return IMPL->readOnlyIntAttr(); +} + +- (NSString *)readOnlyStringAttr +{ + return IMPL->readOnlyStringAttr(); +} + +- (DOMTestObj *)readOnlyTestObjAttr +{ + return kit(WTF::getPtr(IMPL->readOnlyTestObjAttr())); +} + +- (int)intAttr +{ + return IMPL->intAttr(); +} + +- (void)setIntAttr:(int)newIntAttr +{ + IMPL->setIntAttr(newIntAttr); +} + +- (long long)longLongAttr +{ + return IMPL->longLongAttr(); +} + +- (void)setLongLongAttr:(long long)newLongLongAttr +{ + IMPL->setLongLongAttr(newLongLongAttr); +} + +- (unsigned long long)unsignedLongLongAttr +{ + return IMPL->unsignedLongLongAttr(); +} + +- (void)setUnsignedLongLongAttr:(unsigned long long)newUnsignedLongLongAttr +{ + IMPL->setUnsignedLongLongAttr(newUnsignedLongLongAttr); +} + +- (NSString *)stringAttr +{ + return IMPL->stringAttr(); +} + +- (void)setStringAttr:(NSString *)newStringAttr +{ + IMPL->setStringAttr(newStringAttr); +} + +- (DOMTestObj *)testObjAttr +{ + return kit(WTF::getPtr(IMPL->testObjAttr())); +} + +- (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr +{ + ASSERT(newTestObjAttr); + + IMPL->setTestObjAttr(core(newTestObjAttr)); +} + +- (int)attrWithException +{ + return IMPL->attrWithException(); +} + +- (void)setAttrWithException:(int)newAttrWithException +{ + IMPL->setAttrWithException(newAttrWithException); +} + +- (int)attrWithSetterException +{ + return IMPL->attrWithSetterException(); +} + +- (void)setAttrWithSetterException:(int)newAttrWithSetterException +{ + IMPL->setAttrWithSetterException(newAttrWithSetterException); +} + +- (int)attrWithGetterException +{ + return IMPL->attrWithGetterException(); +} + +- (void)setAttrWithGetterException:(int)newAttrWithGetterException +{ + IMPL->setAttrWithGetterException(newAttrWithGetterException); +} + +- (int)customAttr +{ + return IMPL->customAttr(); +} + +- (void)setCustomAttr:(int)newCustomAttr +{ + IMPL->setCustomAttr(newCustomAttr); +} + +- (NSString *)scriptStringAttr +{ + return IMPL->scriptStringAttr(); +} + +- (void)voidMethod +{ + IMPL->voidMethod(); +} + +- (void)voidMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + IMPL->voidMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (int)intMethod +{ + return IMPL->intMethod(); +} + +- (int)intMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + return IMPL->intMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (DOMTestObj *)objMethod +{ + return kit(WTF::getPtr(IMPL->objMethod())); +} + +- (DOMTestObj *)objMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + return kit(WTF::getPtr(IMPL->objMethodWithArgs(intArg, strArg, core(objArg)))); +} + +- (void)serializedValue:(NSString *)serializedArg +{ + IMPL->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); +} + +- (void)methodWithException +{ + WebCore::ExceptionCode ec = 0; + IMPL->methodWithException(ec); + WebCore::raiseOnDOMError(ec); +} + +- (void)customMethod +{ + IMPL->customMethod(); +} + +- (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + IMPL->customMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (void)customArgsAndException:(DOMlog *)intArg +{ + WebCore::ExceptionCode ec = 0; + IMPL->customArgsAndException(core(intArg), ec); + WebCore::raiseOnDOMError(ec); +} + +- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture +{ + RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap(listener); + IMPL->addEventListener(type, WTF::getPtr(nativeEventListener), useCapture); +} + +- (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture +{ + RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap(listener); + IMPL->removeEventListener(type, WTF::getPtr(nativeEventListener), useCapture); +} + +- (void)withDynamicFrame +{ + IMPL->withDynamicFrame(); +} + +- (void)withDynamicFrameAndArg:(int)intArg +{ + IMPL->withDynamicFrameAndArg(intArg); +} + +- (void)withDynamicFrameAndOptionalArg:(int)intArg optionalArg:(int)optionalArg +{ + IMPL->withDynamicFrameAndOptionalArg(intArg, optionalArg); +} + +- (void)withDynamicFrameAndUserGesture:(int)intArg +{ + IMPL->withDynamicFrameAndUserGesture(intArg); +} + +- (void)withDynamicFrameAndUserGestureASAD:(int)intArg optionalArg:(int)optionalArg +{ + IMPL->withDynamicFrameAndUserGestureASAD(intArg, optionalArg); +} + +- (void)withScriptStateVoid +{ + IMPL->withScriptStateVoid(); +} + +- (DOMTestObj *)withScriptStateObj +{ + return kit(WTF::getPtr(IMPL->withScriptStateObj())); +} + +- (void)withScriptStateVoidException +{ + WebCore::ExceptionCode ec = 0; + IMPL->withScriptStateVoidException(ec); + WebCore::raiseOnDOMError(ec); +} + +- (DOMTestObj *)withScriptStateObjException +{ + WebCore::ExceptionCode ec = 0; + DOMTestObj *result = kit(WTF::getPtr(IMPL->withScriptStateObjException(ec))); + WebCore::raiseOnDOMError(ec); + return result; +} + +- (void)methodWithOptionalArg:(int)opt +{ + IMPL->methodWithOptionalArg(opt); +} + +- (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt +{ + IMPL->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); +} + +- (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2 +{ + IMPL->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); +} + +@end + +WebCore::TestObj* core(DOMTestObj *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestObj*>(wrapper->_internal) : 0; +} + +DOMTestObj *kit(WebCore::TestObj* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestObj *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestObj *wrapper = [[DOMTestObj alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h b/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h new file mode 100644 index 0000000..c24ea84 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h @@ -0,0 +1,38 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMTestObj.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestObj; +} + +WebCore::TestObj* core(DOMTestObj *); +DOMTestObj *kit(WebCore::TestObj*); + +#endif diff --git a/WebCore/bindings/scripts/test/TestCallback.idl b/WebCore/bindings/scripts/test/TestCallback.idl new file mode 100644 index 0000000..25db4c6 --- /dev/null +++ b/WebCore/bindings/scripts/test/TestCallback.idl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary formstrArg, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIEstrArg, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// This IDL file is for testing the bindings code generator with an interface +// that has the "Callback" attribute and for tracking changes in its ouput. +module test { + interface [ + Conditional=DATABASE, + Callback + ] TestCallback { + boolean callbackWithClass1Param(in Class1 class1Param); + boolean callbackWithClass2Param(in Class2 class2Param, in DOMString strArg); + long callbackWithNonBoolReturnType(in Class3 class3Param); + [Custom] long customCallback(in Class5 class5Param, in Class6 class6Param); + }; +} diff --git a/WebCore/bindings/scripts/test/TestInterface.idl b/WebCore/bindings/scripts/test/TestInterface.idl new file mode 100644 index 0000000..5a8b008 --- /dev/null +++ b/WebCore/bindings/scripts/test/TestInterface.idl @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2010 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary formstrArg, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIEstrArg, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// This IDL file is for testing the bindings code generator and for tracking +// changes in its ouput. +module test { + interface [ + CanBeConstructed, + CallWith=ScriptExecutionContext + ] TestInterface { + }; +} diff --git a/WebCore/bindings/scripts/test/TestObj.idl b/WebCore/bindings/scripts/test/TestObj.idl new file mode 100644 index 0000000..b14328d --- /dev/null +++ b/WebCore/bindings/scripts/test/TestObj.idl @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary formstrArg, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIEstrArg, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// This IDL file is for testing the bindings code generator and for tracking +// changes in its ouput. +module test { + interface TestObj { + // Attributes + readonly attribute long readOnlyIntAttr; + readonly attribute DOMString readOnlyStringAttr; + readonly attribute TestObj readOnlyTestObjAttr; + attribute long intAttr; + attribute long long longLongAttr; + attribute unsigned long long unsignedLongLongAttr; + attribute DOMString stringAttr; + attribute TestObj testObjAttr; + + // Methods + void voidMethod(); + void voidMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + long intMethod(); + long intMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + TestObj objMethod(); + TestObj objMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + + void serializedValue(in SerializedScriptValue serializedArg); + + // Exceptions + void methodWithException() raises(DOMException); + attribute long attrWithException raises(DOMException); + attribute long attrWithSetterException getraises(DOMException); + attribute long attrWithGetterException setraises(DOMException); + + // 'Custom' extended attribute + attribute [Custom] long customAttr; + [Custom] void customMethod(); + [Custom] void customMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + + [CustomArgumentHandling] void customArgsAndException(in log intArg) + raises(DOMException); + + void addEventListener(in DOMString type, + in EventListener listener, + in boolean useCapture); + void removeEventListener(in DOMString type, + in EventListener listener, + in boolean useCapture); + + // 'CallWith' extended attribute + [CallWith=DynamicFrame] void withDynamicFrame(); + [CallWith=DynamicFrame] void withDynamicFrameAndArg(in long intArg); + [CallWith=DynamicFrame] void withDynamicFrameAndOptionalArg(in long intArg, in [Optional] long optionalArg); + [NeedsUserGestureCheck, CallWith=DynamicFrame] void withDynamicFrameAndUserGesture(in long intArg); + [NeedsUserGestureCheck, CallWith=DynamicFrame] void withDynamicFrameAndUserGestureASAD(in long intArg, in [Optional] long optionalArg); + [CallWith=ScriptState] void withScriptStateVoid(); + [CallWith=ScriptState] TestObj withScriptStateObj(); + [CallWith=ScriptState] void withScriptStateVoidException() + raises(DOMException); + [CallWith=ScriptState] TestObj withScriptStateObjException() + raises(DOMException); + + // 'Optional' extended attribute + void methodWithOptionalArg(in [Optional] long opt); + void methodWithNonOptionalArgAndOptionalArg(in long nonOpt, in [Optional] long opt); + void methodWithNonOptionalArgAndTwoOptionalArgs(in long nonOpt, in [Optional] long opt1, in long opt2); + + // 'ConvertScriptString' extended attribute + readonly attribute [ConvertScriptString] DOMString scriptStringAttr; + +#ifdef TESTING_V8 + // Overloads + void overloadedMethod(in TestObj objArg, in DOMString strArg); + void overloadedMethod(in TestObj objArg, in [Optional] long intArg); + void overloadedMethod(in DOMString strArg); + void overloadedMethod(in long intArg); +#endif + }; +} diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp new file mode 100644 index 0000000..e72330d --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -0,0 +1,92 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "config.h" +#include "V8TestCallback.h" + +#if ENABLE(DATABASE) + +#include "Frame.h" +#include "ScriptExecutionContext.h" +#include "V8Class1.h" +#include "V8Class2.h" +#include "V8CustomVoidCallback.h" +#include "V8DOMString.h" + +namespace WebCore { + +V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback, Frame* frame) + : m_callback(v8::Persistent<v8::Object>::New(callback)) + , m_frame(frame) + , m_worldContext(UseCurrentWorld) +{ +} + +V8TestCallback::~V8TestCallback() +{ + m_callback.Dispose(); +} + +// Functions + +bool V8TestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param) +{ + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + v8::Handle<v8::Value> argv[] = { + toV8(class1Param) + }; + + RefPtr<Frame> protect(m_frame); + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 1, argv, callbackReturnValue); +} + +bool V8TestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg) +{ + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + v8::Handle<v8::Value> argv[] = { + toV8(class2Param), + toV8(strArg) + }; + + RefPtr<Frame> protect(m_frame); + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 2, argv, callbackReturnValue); +} + +} // namespace WebCore + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.h b/WebCore/bindings/scripts/test/V8/V8TestCallback.h new file mode 100644 index 0000000..f58f3f0 --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.h @@ -0,0 +1,63 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#if ENABLE(DATABASE) + +#ifndef V8TestCallback_h +#define V8TestCallback_h + +#include "TestCallback.h" +#include "WorldContextHandle.h" +#include <v8.h> +#include <wtf/Forward.h> + +namespace WebCore { + +class Frame; + +class V8TestCallback : public TestCallback { +public: + static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value, Frame* frame) + { + ASSERT(value->IsObject()); + return adoptRef(new V8TestCallback(value->ToObject(), frame)); + } + + virtual ~V8TestCallback(); + + // Functions + virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param); + virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param); + virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param); + +private: + V8TestCallback(v8::Local<v8::Object>, Frame*); + + v8::Persistent<v8::Object> m_callback; + RefPtr<Frame> m_frame; + WorldContextHandle m_worldContext; +}; + +} + +#endif // V8TestCallback_h + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp b/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp new file mode 100644 index 0000000..f0bfb86 --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp @@ -0,0 +1,115 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "config.h" +#include "V8TestInterface.h" + +#include "RuntimeEnabledFeatures.h" +#include "V8Binding.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Proxy.h" + +namespace WebCore { + +WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, 0 }; + +namespace TestInterfaceInternal { + +template <typename T> void V8_USE(T) { } + +} // namespace TestInterfaceInternal + +v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestInterface.Contructor"); + return V8Proxy::constructDOMObjectWithScriptExecutionContext<TestInterface>(args, &info); +} +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestInterface", v8::Persistent<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount, + 0, 0, + 0, 0); + desc->SetCallHandler(V8TestInterface::constructorCallback); + + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> V8TestInterface::GetRawTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestInterfaceRawCache = createRawTemplate(); + return V8TestInterfaceRawCache; +} + +v8::Persistent<v8::FunctionTemplate> V8TestInterface::GetTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestInterfaceCache = ConfigureV8TestInterfaceTemplate(GetRawTemplate()); + return V8TestInterfaceCache; +} + +TestInterface* V8TestInterface::toNative(v8::Handle<v8::Object> object) +{ + return reinterpret_cast<TestInterface*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); +} + +bool V8TestInterface::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestInterface::wrap(TestInterface* impl) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; + wrapper = getDOMObjectMap().get(impl); + if (!wrapper.IsEmpty()) + return wrapper; + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + if (wrapper.IsEmpty()) + return wrapper; + + impl->ref(); + getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; +} + +v8::Handle<v8::Value> toV8(PassRefPtr<TestInterface > impl) +{ + return toV8(impl.get()); +} + +v8::Handle<v8::Value> toV8(TestInterface* impl) +{ + if (!impl) + return v8::Null(); + return V8TestInterface::wrap(impl); +} + +void V8TestInterface::derefObject(void* object) +{ + static_cast<TestInterface*>(object)->deref(); +} + +} // namespace WebCore diff --git a/WebCore/bindings/scripts/test/V8/V8TestInterface.h b/WebCore/bindings/scripts/test/V8/V8TestInterface.h new file mode 100644 index 0000000..ce1310e --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestInterface.h @@ -0,0 +1,50 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8TestInterface_h +#define V8TestInterface_h + +#include "StringHash.h" +#include "TestInterface.h" +#include "WrapperTypeInfo.h" +#include <v8.h> +#include <wtf/HashMap.h> + +namespace WebCore { + +class V8TestInterface { + +public: + static bool HasInstance(v8::Handle<v8::Value> value); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestInterface* toNative(v8::Handle<v8::Object>); + static v8::Handle<v8::Object> wrap(TestInterface*); + static void derefObject(void*); + static WrapperTypeInfo info; + static v8::Handle<v8::Value> constructorCallback(const v8::Arguments& args); + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +}; + +v8::Handle<v8::Value> toV8(TestInterface*); +v8::Handle<v8::Value> toV8(PassRefPtr<TestInterface >); +} + +#endif // V8TestInterface_h diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp new file mode 100644 index 0000000..94dcd5e --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -0,0 +1,714 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "config.h" +#include "V8TestObj.h" + +#include "ExceptionCode.h" +#include "RuntimeEnabledFeatures.h" +#include "ScriptCallStack.h" +#include "SerializedScriptValue.h" +#include "V8Binding.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Proxy.h" +#include "V8log.h" +#include <wtf/GetPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> + +namespace WebCore { + +WrapperTypeInfo V8TestObj::info = { V8TestObj::GetTemplate, V8TestObj::derefObject, 0 }; + +namespace TestObjInternal { + +template <typename T> void V8_USE(T) { } + +static v8::Handle<v8::Value> readOnlyIntAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.readOnlyIntAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->readOnlyIntAttr()); +} + +static v8::Handle<v8::Value> readOnlyStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.readOnlyStringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->readOnlyStringAttr()); +} + +static v8::Handle<v8::Value> readOnlyTestObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.readOnlyTestObjAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + RefPtr<TestObj> result = imp->readOnlyTestObjAttr(); + v8::Handle<v8::Value> wrapper = result.get() ? getDOMObjectMap().get(result.get()) : v8::Handle<v8::Value>(); + if (wrapper.IsEmpty()) { + wrapper = toV8(result.get()); + if (!wrapper.IsEmpty()) + V8DOMWrapper::setHiddenReference(info.Holder(), wrapper); + } + return wrapper; +} + +static v8::Handle<v8::Value> intAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.intAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->intAttr()); +} + +static void intAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.intAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setIntAttr(v); + return; +} + +static v8::Handle<v8::Value> longLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longLongAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Number::New(static_cast<double>(imp->longLongAttr())); +} + +static void longLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longLongAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + long long v = toInt64(value); + imp->setLongLongAttr(WTF::getPtr(v)); + return; +} + +static v8::Handle<v8::Value> unsignedLongLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongLongAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Number::New(static_cast<double>(imp->unsignedLongLongAttr())); +} + +static void unsignedLongLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongLongAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + unsigned long long v = toInt64(value); + imp->setUnsignedLongLongAttr(WTF::getPtr(v)); + return; +} + +static v8::Handle<v8::Value> stringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8String(imp->stringAttr()); +} + +static void stringAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.stringAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + V8Parameter<> v = value; + imp->setStringAttr(v); + return; +} + +static v8::Handle<v8::Value> testObjAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.testObjAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return toV8(imp->testObjAttr()); +} + +static void testObjAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.testObjAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + TestObj* v = V8TestObj::HasInstance(value) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(value)) : 0; + imp->setTestObjAttr(WTF::getPtr(v)); + return; +} + +static v8::Handle<v8::Value> attrWithExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->attrWithException()); +} + +static void attrWithExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setAttrWithException(v); + return; +} + +static v8::Handle<v8::Value> attrWithSetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithSetterException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->attrWithSetterException()); +} + +static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithSetterException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setAttrWithSetterException(v); + return; +} + +static v8::Handle<v8::Value> attrWithGetterExceptionAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithGetterException._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Integer::New(imp->attrWithGetterException()); +} + +static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.attrWithGetterException._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + int v = toInt32(value); + imp->setAttrWithGetterException(v); + return; +} + +static v8::Handle<v8::Value> scriptStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.scriptStringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + v8StringOrNull(exec, imp->scriptStringAttr()); +} + +static v8::Handle<v8::Value> voidMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.voidMethod"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + imp->voidMethod(); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> voidMethodWithArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.voidMethodWithArgs"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + V8Parameter<> strArg = args[1]; + TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + imp->voidMethodWithArgs(intArg, strArg, objArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> intMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.intMethod"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + return v8::Integer::New(imp->intMethod()); +} + +static v8::Handle<v8::Value> intMethodWithArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.intMethodWithArgs"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + V8Parameter<> strArg = args[1]; + TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + return v8::Integer::New(imp->intMethodWithArgs(intArg, strArg, objArg)); +} + +static v8::Handle<v8::Value> objMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.objMethod"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + return toV8(imp->objMethod()); +} + +static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.objMethodWithArgs"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + V8Parameter<> strArg = args[1]; + TestObj* objArg = V8TestObj::HasInstance(args[2]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[2])) : 0; + return toV8(imp->objMethodWithArgs(intArg, strArg, objArg)); +} + +static v8::Handle<v8::Value> serializedValueCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.serializedValue"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + bool serializedArgDidThrow = false; + RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], serializedArgDidThrow); + if (serializedArgDidThrow) + return v8::Undefined(); + imp->serializedValue(serializedArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + imp->methodWithException(ec); + if (UNLIKELY(ec)) + goto fail; + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.customArgsAndException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1)); + if (!callStack) + return v8::Undefined(); + log* intArg = V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; + imp->customArgsAndException(intArg, callStack.get(), ec); + if (UNLIKELY(ec)) + goto fail; + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> addEventListenerCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.addEventListener()"); + RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOrCreate); + if (listener) { + V8TestObj::toNative(args.Holder())->addEventListener(v8ValueToAtomicWebCoreString(args[0]), listener, args[2]->BooleanValue()); + createHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex); + } + return v8::Undefined(); +} + +static v8::Handle<v8::Value> removeEventListenerCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.removeEventListener()"); + RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOnly); + if (listener) { + V8TestObj::toNative(args.Holder())->removeEventListener(v8ValueToAtomicWebCoreString(args[0]), listener.get(), args[2]->BooleanValue()); + removeHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex); + } + return v8::Undefined(); +} + +static v8::Handle<v8::Value> withDynamicFrameCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrame"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrame(enteredFrame); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndArg(enteredFrame, intArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + if (args.Length() <= 1) { + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg); + return v8::Handle<v8::Value>(); + } + int optionalArg = toInt32(args[1]); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg, optionalArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndUserGestureCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGesture(enteredFrame, intArg, processingUserGesture()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + if (args.Length() <= 1) { + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, processingUserGesture()); + return v8::Handle<v8::Value>(); + } + int optionalArg = toInt32(args[1]); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, optionalArg, processingUserGesture()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateVoidCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateVoid"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EmptyScriptState state; + imp->withScriptStateVoid(&state); + if (state.hadException()) + return throwError(state.exception()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateObjCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateObj"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EmptyScriptState state; + RefPtr<TestObj> result = imp->withScriptStateObj(&state); + if (state.hadException()) + return throwError(state.exception()); + return toV8(result.release()); +} + +static v8::Handle<v8::Value> withScriptStateVoidExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateVoidException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + EmptyScriptState state; + imp->withScriptStateVoidException(&state, ec); + if (UNLIKELY(ec)) + goto fail; + if (state.hadException()) + return throwError(state.exception()); + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateObjExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateObjException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + EmptyScriptState state; + RefPtr<TestObj> result = imp->withScriptStateObjException(&state, ec); + if (UNLIKELY(ec)) + goto fail; + if (state.hadException()) + return throwError(state.exception()); + return toV8(result.release()); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithOptionalArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithOptionalArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + if (args.Length() <= 0) { + imp->methodWithOptionalArg(); + return v8::Handle<v8::Value>(); + } + int opt = toInt32(args[0]); + imp->methodWithOptionalArg(opt); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithNonOptionalArgAndOptionalArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndOptionalArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int nonOpt = toInt32(args[0]); + if (args.Length() <= 1) { + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); + return v8::Handle<v8::Value>(); + } + int opt = toInt32(args[1]); + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> methodWithNonOptionalArgAndTwoOptionalArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodWithNonOptionalArgAndTwoOptionalArgs"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int nonOpt = toInt32(args[0]); + if (args.Length() <= 1) { + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); + return v8::Handle<v8::Value>(); + } + int opt1 = toInt32(args[1]); + int opt2 = toInt32(args[2]); + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod1"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; + V8Parameter<> strArg = args[1]; + imp->overloadedMethod(objArg, strArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod2Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod2"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + TestObj* objArg = V8TestObj::HasInstance(args[0]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; + if (args.Length() <= 1) { + imp->overloadedMethod(objArg); + return v8::Handle<v8::Value>(); + } + int intArg = toInt32(args[1]); + imp->overloadedMethod(objArg, intArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod3Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod3"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + V8Parameter<> strArg = args[0]; + imp->overloadedMethod(strArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethod4Callback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod4"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + imp->overloadedMethod(intArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.overloadedMethod"); + if ((args.Length() == 2 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0])) && (args[1]->IsNull() || args[1]->IsUndefined() || args[1]->IsString() || args[1]->IsObject()))) + return overloadedMethod1Callback(args); + if ((args.Length() == 1 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0]))) || (args.Length() == 2 && (args[0]->IsNull() || V8TestObj::HasInstance(args[0])))) + return overloadedMethod2Callback(args); + if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsUndefined() || args[0]->IsString() || args[0]->IsObject()))) + return overloadedMethod3Callback(args); + if (args.Length() == 1) + return overloadedMethod4Callback(args); + V8Proxy::setDOMException(SYNTAX_ERR); + return notHandledByInterceptor(); +} + +} // namespace TestObjInternal + +static const BatchedAttribute TestObjAttrs[] = { + // Attribute 'readOnlyIntAttr' (Type: 'readonly attribute' ExtAttr: '') + {"readOnlyIntAttr", TestObjInternal::readOnlyIntAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'readOnlyStringAttr' (Type: 'readonly attribute' ExtAttr: '') + {"readOnlyStringAttr", TestObjInternal::readOnlyStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'readOnlyTestObjAttr' (Type: 'readonly attribute' ExtAttr: '') + {"readOnlyTestObjAttr", TestObjInternal::readOnlyTestObjAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'intAttr' (Type: 'attribute' ExtAttr: '') + {"intAttr", TestObjInternal::intAttrAttrGetter, TestObjInternal::intAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'longLongAttr' (Type: 'attribute' ExtAttr: '') + {"longLongAttr", TestObjInternal::longLongAttrAttrGetter, TestObjInternal::longLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'unsignedLongLongAttr' (Type: 'attribute' ExtAttr: '') + {"unsignedLongLongAttr", TestObjInternal::unsignedLongLongAttrAttrGetter, TestObjInternal::unsignedLongLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'stringAttr' (Type: 'attribute' ExtAttr: '') + {"stringAttr", TestObjInternal::stringAttrAttrGetter, TestObjInternal::stringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'testObjAttr' (Type: 'attribute' ExtAttr: '') + {"testObjAttr", TestObjInternal::testObjAttrAttrGetter, TestObjInternal::testObjAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'attrWithException' (Type: 'attribute' ExtAttr: '') + {"attrWithException", TestObjInternal::attrWithExceptionAttrGetter, TestObjInternal::attrWithExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'attrWithSetterException' (Type: 'attribute' ExtAttr: '') + {"attrWithSetterException", TestObjInternal::attrWithSetterExceptionAttrGetter, TestObjInternal::attrWithSetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'attrWithGetterException' (Type: 'attribute' ExtAttr: '') + {"attrWithGetterException", TestObjInternal::attrWithGetterExceptionAttrGetter, TestObjInternal::attrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'customAttr' (Type: 'attribute' ExtAttr: 'Custom') + {"customAttr", V8TestObj::customAttrAccessorGetter, V8TestObj::customAttrAccessorSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'scriptStringAttr' (Type: 'readonly attribute' ExtAttr: 'ConvertScriptString') + {"scriptStringAttr", TestObjInternal::scriptStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, +}; +static const BatchedCallback TestObjCallbacks[] = { + {"voidMethod", TestObjInternal::voidMethodCallback}, + {"intMethod", TestObjInternal::intMethodCallback}, + {"objMethod", TestObjInternal::objMethodCallback}, + {"serializedValue", TestObjInternal::serializedValueCallback}, + {"methodWithException", TestObjInternal::methodWithExceptionCallback}, + {"customMethod", V8TestObj::customMethodCallback}, + {"customMethodWithArgs", V8TestObj::customMethodWithArgsCallback}, + {"addEventListener", TestObjInternal::addEventListenerCallback}, + {"removeEventListener", TestObjInternal::removeEventListenerCallback}, + {"withDynamicFrame", TestObjInternal::withDynamicFrameCallback}, + {"withDynamicFrameAndArg", TestObjInternal::withDynamicFrameAndArgCallback}, + {"withDynamicFrameAndOptionalArg", TestObjInternal::withDynamicFrameAndOptionalArgCallback}, + {"withDynamicFrameAndUserGesture", TestObjInternal::withDynamicFrameAndUserGestureCallback}, + {"withDynamicFrameAndUserGestureASAD", TestObjInternal::withDynamicFrameAndUserGestureASADCallback}, + {"withScriptStateVoid", TestObjInternal::withScriptStateVoidCallback}, + {"withScriptStateObj", TestObjInternal::withScriptStateObjCallback}, + {"withScriptStateVoidException", TestObjInternal::withScriptStateVoidExceptionCallback}, + {"withScriptStateObjException", TestObjInternal::withScriptStateObjExceptionCallback}, + {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback}, + {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback}, + {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback}, + {"overloadedMethod", TestObjInternal::overloadedMethodCallback}, +}; +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestObj", v8::Persistent<v8::FunctionTemplate>(), V8TestObj::internalFieldCount, + TestObjAttrs, sizeof(TestObjAttrs) / sizeof(*TestObjAttrs), + TestObjCallbacks, sizeof(TestObjCallbacks) / sizeof(*TestObjCallbacks)); + v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate(); + v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate(); + + + // Custom Signature 'voidMethodWithArgs' + const int voidMethodWithArgsArgc = 3; + v8::Handle<v8::FunctionTemplate> voidMethodWithArgsArgv[voidMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> voidMethodWithArgsSignature = v8::Signature::New(desc, voidMethodWithArgsArgc, voidMethodWithArgsArgv); + proto->Set(v8::String::New("voidMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::voidMethodWithArgsCallback, v8::Handle<v8::Value>(), voidMethodWithArgsSignature)); + + // Custom Signature 'intMethodWithArgs' + const int intMethodWithArgsArgc = 3; + v8::Handle<v8::FunctionTemplate> intMethodWithArgsArgv[intMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> intMethodWithArgsSignature = v8::Signature::New(desc, intMethodWithArgsArgc, intMethodWithArgsArgv); + proto->Set(v8::String::New("intMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::intMethodWithArgsCallback, v8::Handle<v8::Value>(), intMethodWithArgsSignature)); + + // Custom Signature 'objMethodWithArgs' + const int objMethodWithArgsArgc = 3; + v8::Handle<v8::FunctionTemplate> objMethodWithArgsArgv[objMethodWithArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> objMethodWithArgsSignature = v8::Signature::New(desc, objMethodWithArgsArgc, objMethodWithArgsArgv); + proto->Set(v8::String::New("objMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::objMethodWithArgsCallback, v8::Handle<v8::Value>(), objMethodWithArgsSignature)); + + // Custom Signature 'customArgsAndException' + const int customArgsAndExceptionArgc = 1; + v8::Handle<v8::FunctionTemplate> customArgsAndExceptionArgv[customArgsAndExceptionArgc] = { V8log::GetRawTemplate() }; + v8::Handle<v8::Signature> customArgsAndExceptionSignature = v8::Signature::New(desc, customArgsAndExceptionArgc, customArgsAndExceptionArgv); + proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature)); + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> V8TestObj::GetRawTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestObjRawCache = createRawTemplate(); + return V8TestObjRawCache; +} + +v8::Persistent<v8::FunctionTemplate> V8TestObj::GetTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestObjCache = ConfigureV8TestObjTemplate(GetRawTemplate()); + return V8TestObjCache; +} + +TestObj* V8TestObj::toNative(v8::Handle<v8::Object> object) +{ + return reinterpret_cast<TestObj*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); +} + +bool V8TestObj::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestObj::wrap(TestObj* impl) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; + wrapper = getDOMObjectMap().get(impl); + if (!wrapper.IsEmpty()) + return wrapper; + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + if (wrapper.IsEmpty()) + return wrapper; + + impl->ref(); + getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; +} + +v8::Handle<v8::Value> toV8(PassRefPtr<TestObj > impl) +{ + return toV8(impl.get()); +} + +v8::Handle<v8::Value> toV8(TestObj* impl) +{ + if (!impl) + return v8::Null(); + return V8TestObj::wrap(impl); +} + +void V8TestObj::derefObject(void* object) +{ + static_cast<TestObj*>(object)->deref(); +} + +} // namespace WebCore diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.h b/WebCore/bindings/scripts/test/V8/V8TestObj.h new file mode 100644 index 0000000..5d6770a --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.h @@ -0,0 +1,53 @@ +/* + This file is part of the WebKit 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 + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef V8TestObj_h +#define V8TestObj_h + +#include "StringHash.h" +#include "TestObj.h" +#include "WrapperTypeInfo.h" +#include <v8.h> +#include <wtf/HashMap.h> + +namespace WebCore { + +class V8TestObj { + +public: + static bool HasInstance(v8::Handle<v8::Value> value); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestObj* toNative(v8::Handle<v8::Object>); + static v8::Handle<v8::Object> wrap(TestObj*); + static void derefObject(void*); + static WrapperTypeInfo info; + static v8::Handle<v8::Value> customMethodCallback(const v8::Arguments&); + static v8::Handle<v8::Value> customMethodWithArgsCallback(const v8::Arguments&); + static v8::Handle<v8::Value> customAttrAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info); + static void customAttrAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info); + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +}; + +v8::Handle<v8::Value> toV8(TestObj*); +v8::Handle<v8::Value> toV8(PassRefPtr<TestObj >); +} + +#endif // V8TestObj_h |