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

2010-10-28 Thread Anton Muhin
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ć c...@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 PassRefJSLocale
 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.
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-10-28 Thread Nebojša Ćirić
This API is going to be a separate standard related to EcmaScript, say
something like a library - so implementers of EcmaScript core standard
wouldn't be obligated to implement it. Dual track also enables both groups
to move at their pace and not block each other.
We are also trying to reuse much of ICU functionality for Chromium/Safari
implementation, and I am not sure V8/JSC has dependency on ICU at all, while
WebKit/Chromium do.
Also Darin Fisher hinted we should probably do it in bindings/v8, but maybe
he didn't have enough info at the time.

On Wed, Oct 27, 2010 at 6:20 PM, Adam Barth aba...@webkit.org wrote:

 If this is part of ECMAScript, it should be in the JavaScript engine
 proper, not in WebCore.   With respect to missing features of the IDL
 compiler, we add features to the IDL compiler as we need them.
 There's lots of stuff in WebIDL that we haven't needed to implement
 yet.

 Adam


 On Wed, Oct 27, 2010 at 5:35 PM, Nebojša Ćirić c...@chromium.org wrote:
  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 PassRefJSLocale
  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ć
 
  ___
  webkit-dev mailing list
  webkit-dev@lists.webkit.org
  http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
 
 




-- 
Nebojša Ćirić
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-10-28 Thread Nebojša Ćirić
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 ant...@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ć c...@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 PassRefJSLocale
  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ć
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-10-28 Thread Anton Muhin
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ć c...@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 ant...@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ć c...@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
  PassRefJSLocale
  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ć

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


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

2010-10-27 Thread Adam Barth
If this is part of ECMAScript, it should be in the JavaScript engine
proper, not in WebCore.   With respect to missing features of the IDL
compiler, we add features to the IDL compiler as we need them.
There's lots of stuff in WebIDL that we haven't needed to implement
yet.

Adam


On Wed, Oct 27, 2010 at 5:35 PM, Nebojša Ćirić c...@chromium.org wrote:
 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 PassRefJSLocale
 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ć

 ___
 webkit-dev mailing list
 webkit-dev@lists.webkit.org
 http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev