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

Nebojša Ćirić cira at chromium.org
Wed Oct 27 17:35:09 PDT 2010


Hi,
 I am working on JavaScript API that implements basic i18n operations, like
formatting numbers, dates, sorting... We are actually working with
EcmaScript committee on standardizing the API.

 My goal is to have a prototype to showcase for the next meeting (mid
November) and I am making local changes in my chromium checkout (but working
on WebKit part of the code).

 I started with the simplest part, Locale definition and came up with simple
(not complete) idl for it. What I did:

1. Added new top level WebCore/i18n directory (we can debate that later)
2. Added JSLocale.idl, JSLocale.h and JSLocale.cpp files to it
3. Updated WebCore.gypi and WebCore.gyp files so proper project is generated
for XCode.

   module core {

    // Construct with browser locale or with user specified one.

    interface [Constructor] JSLocale {

        readonly attribute DOMString language;

        readonly attribute DOMString script;

        readonly attribute DOMString region;

        readonly attribute DOMString variants;

        void availableLocales(out ObjectArray locales);

        void maximizedLocale(out JSLocale locale);

        void minimizedLocale(out JSLocale locale);

    };

}

Everything (chromium) compiles properly.

 I hit couple problems with this:

*1.* I can't name my new files/interface Locale.{idl, cpp, h} since Mac and
Windows have case insensitive file names, and compiler trips on system
header locale.h. I am using JSLocale for that reason, but I would like to
hear if somebody has a solution for this.

*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.

*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.

*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.


I would like to contribute on improving documentation related to the
bindings, once I actually succeed using them :).


Regards,
  Nebojša Ćirić
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20101027/994cb635/attachment.html>


More information about the webkit-dev mailing list