[webkit-help] 回复: how to implement user-defined javascript object?

xiehui007 xiehui007 at 139.com
Wed Jan 11 21:36:57 PST 2012


Thanks for your help, but i want to access Cloud like Clound[0], how to implement ?


2012-01-12 



xiehui007 



发件人: cosmos.qiu 
发送时间: 2012-01-12  11:58:19 
收件人: xiehui007 
抄送: webkit-help 
主题: 回复: [webkit-help] how to implement user-defined javascript object? 
 
Hi,I am not sure whether this is what you want:
1、initialize the global object user defined, for example , the object name is "Cloud".
   You can find examples in function: JSGlobalObject::reset(JSValue prototype),
   Create "Cloud" object just like "Date" or "Array".

2、Create these four files:
   CloudConsructor.cpp, CloudConstructor.h, CloudPrototype.cpp, CloudPrototype.h.

3、generate the hash table for "Cloud",just run:
   perl CloudPrototype.cpp >CloudPrototype.lut.h,  
  the rule is defined in CloudPrototype.cpp as follows:
   
// ------------------------------ CloudPrototype ----------------------------

const ClassInfo CloudPrototype::info = {"Cloud", 0, 0, ExecState::cloudTable};

/* Source for ArrayPrototype.lut.h
@begin cloudTable 16
  toString       cloudProtoFuncToString       DontEnum|Function 0
  toLocaleString cloudProtoFuncToLocaleString DontEnum|Function 0
  concat         cloudProtoFuncConcat         DontEnum|Function 1
  join           cloudProtoFuncJoin           DontEnum|Function 1
  pop            cloudProtoFuncPop            DontEnum|Function 0
  push           cloudProtoFuncPush           DontEnum|Function 1
  reverse        cloudProtoFuncReverse        DontEnum|Function 0
  shift          cloudProtoFuncShift          DontEnum|Function 0
  slice          cloudProtoFuncSlice          DontEnum|Function 2
  sort           cloudProtoFuncSort           DontEnum|Function 1
  splice         cloudProtoFuncSplice         DontEnum|Function 2
  unshift        cloudProtoFuncUnShift        DontEnum|Function 1
  every          cloudProtoFuncEvery          DontEnum|Function 1
  forEach        cloudProtoFuncForEach        DontEnum|Function 1
  some           cloudProtoFuncSome           DontEnum|Function 1
  indexOf        cloudProtoFuncIndexOf        DontEnum|Function 1
  lastIndexOf    cloudProtoFuncLastIndexOf    DontEnum|Function 1
  filter         cloudProtoFuncFilter         DontEnum|Function 1
  reduce         cloudProtoFuncReduce         DontEnum|Function 1
  reduceRight    cloudProtoFuncReduceRight    DontEnum|Function 1
  map            cloudProtoFuncMap            DontEnum|Function 1
@end
*/
how to use CloudPrototype.lut.h please check the "Date" or "Array" implementation.

4、 compile your added files and test your new object "Cloud".

If there is any mistake or missed detail please let me know , thanks!




cosmos.qiu

发件人: xiehui007
发送时间: 2012-01-12 10:49
收件人: webkit-help
主题: [webkit-help] how to implement user-defined javascript object?
I want to implement a user-defined js object,can anyone give me a suggest?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-help/attachments/20120112/68bad203/attachment-0001.html>


More information about the webkit-help mailing list