[Webkit-unassigned] [Bug 85326] New: WebIDL: overloaded methods prevent number -> string conversion
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue May 1 17:28:07 PDT 2012
https://bugs.webkit.org/show_bug.cgi?id=85326
Summary: WebIDL: overloaded methods prevent number -> string
conversion
Product: WebKit
Version: 528+ (Nightly build)
Platform: Unspecified
OS/Version: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: WebKit Misc.
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: alecflett at chromium.org
CC: abarth at webkit.org, haraken at chromium.org
(From e-mail sent to kentaro@ and abarth@)
Here's the situation:
We have an API that previously took a number as it's 2nd parameter, and we'd like to change it to accept a string, as per the latest IndexedDB spec.
So I changed this:
IDBTransaction transaction(in DOMStringList storeNames, in unsigned short mode)
raises (IDBDatabaseException);
IDBTransaction transaction(in DOMString[] storeNames, in unsigned short mode)
raises (IDBDatabaseException);
IDBTransaction transaction(in DOMString storeName, in unsigned short mode)
raises (IDBDatabaseException);
to this:
IDBTransaction transaction(in DOMStringList storeNames, in DOMString mode)
raises (IDBDatabaseException);
IDBTransaction transaction(in DOMString[] storeNames, in DOMString mode)
raises (IDBDatabaseException);
IDBTransaction transaction(in DOMString storeName, in DOMString mode)
raises (IDBDatabaseException);
Figuring I'd still catch the numeric values, that they'd be converted to strings... i.e. that if someone passed in 0, that I'd get the string "0".
But it looks like the IDL compiler is generating code to pick the right callback that checks arg[1]->IsObject(), and when someone passes in a number, it's not an object so none of the callbacks are called:
if ((args.Length() == 2 && (args[0]->IsNull() || V8DOMStringList::HasInstance(args[0])) && (args[1]->IsNull() || args[1]->IsUndefined() || args[1]->IsString() || args[1]->IsObject())))
return transaction1Callback(args);
if ((args.Length() == 2 && (args[0]->IsNull() || args[0]->IsArray()) && (args[1]->IsNull() || args[1]->IsUndefined() || args[1]->IsString() || args[1]->IsObject())))
return transaction2Callback(args);
if ((args.Length() == 2 && (args[0]->IsNull() || args[0]->IsUndefined() || args[0]->IsString() || args[0]->IsObject()) && (args[1]->IsNull() || args[1]->IsUndefined() || args[1]->IsString() || args[1]->IsObject())))
return transaction3Callback(args);
Oddly, we made a very similar change to a nearby function, (setVersion) changing an unsigned short to a string, but there is no overload... so the generated code calls STRING_TO_V8PARAMETER_EXCEPTION_BLOCK without any checks.
So this means that the conversion from number to string works for non-overloaded functions, but not for overloaded functions.
it seems like for this very specific case, we could simply add IsNumber() as another check in the overload checks, (around line 1288 in CodeGeneratorV8) but I don't know what the repercussions would be.
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list