add support for Components.Constructor to build constructors for xpcom objects from JS. r=mccabe
git-svn-id: svn://10.0.0.236/trunk@57063 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1093,6 +1093,38 @@ nsXPCComponents::Create(JSContext *cx, JSObject *obj,
|
||||
"this.Exception.toString = function() {\n"
|
||||
" return '\\nfunction Exception() {\\n [JavaScript code]\\n}\\n';\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"this.Constructor = function(progid, iid, fname) {\n"
|
||||
" if(!arguments.length)\n"
|
||||
" throw 'Components.Constructor requires at least one argument';\n"
|
||||
" if(!Components.classes[progid])\n"
|
||||
" throw ''+progid+' is not a registered progid';\n"
|
||||
" if(iid && !Components.interfaces[iid])\n"
|
||||
" throw ''+iid+' is not a valid interface id';\n"
|
||||
" switch(arguments.length) {\n"
|
||||
" case 1:\n"
|
||||
" return function() {\n"
|
||||
" return Components.classes[progid].createInstance();\n"
|
||||
" }\n"
|
||||
" case 2:\n"
|
||||
" return function() {\n"
|
||||
" return Components.classes[progid].createInstance(Components.interfaces[iid]);\n"
|
||||
" }\n"
|
||||
" default:\n"
|
||||
" return function() {\n"
|
||||
" var o = Components.classes[progid].createInstance(Components.interfaces[iid]);\n"
|
||||
" var f = o[fname];\n"
|
||||
" if(!f)\n"
|
||||
" throw ''+fname+' is not a method of '+iid;\n"
|
||||
" f.apply(o,arguments);\n"
|
||||
" return o;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"this.Constructor.toString = function() {\n"
|
||||
" return '\\nfunction Constructor() {\\n [JavaScript code]\\n}\\n';\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
;
|
||||
|
||||
jsval ignored;
|
||||
|
||||
Reference in New Issue
Block a user