[webkit-dev] Adding new JS bindings, having "slight" problems

Anton Muhin antonm at chromium.org
Thu Oct 28 10:36:23 PDT 2010


Nebojša,

Why not put those function right on Local object?

yours,
anton.

On Thu, Oct 28, 2010 at 9:03 PM, Nebojša Ćirić <cira at chromium.org> wrote:
> Hi Anton,
>  Current API (and examples) are
> here http://wiki.ecmascript.org/doku.php?id=strawman:i18n_api, but in short
> I would like to be able to:
> var availableLocales = Locale.availableLocales(); // Static method, returns
> an array of available Locale-s.
> var loc = new Locale("sr"); // Create Locale object with sr locale info
> var maxLocale = loc.maximizedLocale(); // Try to guess script and region -
> prototype method
> var language = maxLocale.language; // returns sr
> var script = maxLocale.script; // returns Cyrl
> var region = maxLocale.region; // returns RS
> ...
> or
> var loc = new Locale(); // gets default browser locale
> ...
> One would pass Locale object around to properly format dates, numbers, or to
> sort.
> Thanks for looking into this.
> On Thu, Oct 28, 2010 at 4:22 AM, Anton Muhin <antonm at chromium.org> wrote:
>>
>> Good day, Nebojša.
>>
>> Overall I am with Adam, that if it's ECMAScript feature it should go
>> in VM itself (JavaScriptCore or v8).  However, as a prototype hacking
>> bindings might be easier.
>>
>> On Thu, Oct 28, 2010 at 4:35 AM, Nebojša Ćirić <cira at chromium.org> wrote:
>>
>> > 2. What is a proper way to specify a constructor? I've browsed the code
>> > and
>> > it seems nobody uses constructors, or they specify custom ones. I would
>> > like
>> > to be able to do:
>> > var loc = new Locale();
>> > or
>> > var loc = new Locale("en");
>> > Specifying interface [Constructor, Constructor(in DOMString locale)]
>> > JSLocale doesn't work (script errors). This should work according to the
>> > WebIDL spec.
>>
>> What exactly you're trying to achieve here?  Speaking of v8 you might
>> either describe all the properties and methods your instances would
>> have (v8 supports class-like inheritance model) or set your own custom
>> constructor which would do whatever you want with your instance.
>>
>> > 3. I would like some of my functions to be static and some prototypes.
>> > WebIDL says that prototype is default for methods. I've heard we added
>> > support for static methods recently.
>>
>> How do you want your static function look in JS?
>>
>> > 4. How would one decide what parameter goes into static
>> > PassRef<JSLocale>
>> > create() method? Some put Frame* some put ScriptContent and other random
>> > parameters - and this doesn't seem to be idl related.
>>
>> Are you talking of JSC or v8 bindings here?
>>
>> yours,
>> anton.
>
>
>
> --
> Nebojša Ćirić
>


More information about the webkit-dev mailing list