johnson 1.2.0 → 2.0.0.pre0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +8 -0
- data/Manifest.txt +762 -48
- data/README.rdoc +2 -1
- data/Rakefile +90 -18
- data/ext/spidermonkey/conversions.c +9 -2
- data/ext/spidermonkey/ruby_land_proxy.c +1 -1
- data/ext/spidermonkey/runtime.h +1 -1
- data/ext/tracemonkey/context.cc +125 -0
- data/ext/tracemonkey/context.h +19 -0
- data/ext/tracemonkey/conversions.cc +365 -0
- data/ext/tracemonkey/conversions.h +32 -0
- data/ext/tracemonkey/debugger.cc +234 -0
- data/ext/tracemonkey/debugger.h +10 -0
- data/ext/tracemonkey/extconf.rb +37 -0
- data/ext/tracemonkey/extensions.cc +37 -0
- data/ext/tracemonkey/extensions.h +12 -0
- data/ext/tracemonkey/global.cc +40 -0
- data/ext/tracemonkey/global.h +11 -0
- data/ext/tracemonkey/idhash.cc +16 -0
- data/ext/tracemonkey/idhash.h +8 -0
- data/ext/tracemonkey/immutable_node.cc +1199 -0
- data/ext/tracemonkey/immutable_node.cc.erb +559 -0
- data/ext/tracemonkey/immutable_node.h +22 -0
- data/ext/tracemonkey/jroot.h +215 -0
- data/ext/tracemonkey/js_land_proxy.cc +620 -0
- data/ext/tracemonkey/js_land_proxy.h +20 -0
- data/ext/tracemonkey/ruby_land_proxy.cc +618 -0
- data/ext/tracemonkey/ruby_land_proxy.h +38 -0
- data/ext/tracemonkey/runtime.cc +454 -0
- data/ext/tracemonkey/runtime.h +27 -0
- data/ext/tracemonkey/split_global.cc +392 -0
- data/ext/tracemonkey/split_global.h +11 -0
- data/ext/tracemonkey/tracemonkey.cc +23 -0
- data/ext/tracemonkey/tracemonkey.h +32 -0
- data/lib/johnson.rb +12 -4
- data/lib/johnson/error.rb +5 -0
- data/lib/johnson/js/prelude.js +16 -1
- data/lib/johnson/parser.rb +2 -1
- data/lib/johnson/runtime.rb +87 -26
- data/lib/johnson/spidermonkey/runtime.rb +7 -16
- data/lib/johnson/tracemonkey.rb +13 -0
- data/lib/johnson/tracemonkey/context.rb +10 -0
- data/lib/johnson/tracemonkey/debugger.rb +67 -0
- data/lib/johnson/tracemonkey/immutable_node.rb +282 -0
- data/lib/johnson/tracemonkey/js_land_proxy.rb +64 -0
- data/lib/johnson/tracemonkey/mutable_tree_visitor.rb +242 -0
- data/lib/johnson/tracemonkey/ruby_land_proxy.rb +17 -0
- data/lib/johnson/tracemonkey/runtime.rb +80 -0
- data/test/{johnson_test.rb → generic/johnson_test.rb} +1 -1
- data/test/{parser_test.rb → generic/parser_test.rb} +1 -1
- data/test/helper.rb +23 -4
- data/test/johnson/{browser_test.rb → generic/browser_test.rb} +1 -1
- data/test/johnson/{conversions → generic/conversions}/array_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/boolean_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/callable_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/file_test.rb +1 -1
- data/test/johnson/generic/conversions/helper.rb +1 -0
- data/test/johnson/{conversions → generic/conversions}/nil_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/number_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/regexp_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/string_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/struct_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/symbol_test.rb +1 -1
- data/test/johnson/{conversions → generic/conversions}/thread_test.rb +1 -1
- data/test/johnson/{custom_conversions_test.rb → generic/custom_conversions_test.rb} +1 -1
- data/test/johnson/generic/default_test.rb +12 -0
- data/test/johnson/{error_test.rb → generic/error_test.rb} +1 -1
- data/test/johnson/{extensions_test.rb → generic/extensions_test.rb} +1 -1
- data/test/johnson/generic/helper.rb +1 -0
- data/test/johnson/{nodes → generic/nodes}/array_literal_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/array_node_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/binary_node_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/bracket_access_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/delete_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/do_while_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/dot_accessor_test.rb +1 -1
- data/test/johnson/generic/nodes/export_test.rb +11 -0
- data/test/johnson/{nodes → generic/nodes}/for_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/function_test.rb +1 -1
- data/test/johnson/generic/nodes/helper.rb +1 -0
- data/test/johnson/{nodes → generic/nodes}/if_test.rb +16 -6
- data/test/johnson/generic/nodes/import_test.rb +15 -0
- data/test/johnson/{nodes → generic/nodes}/label_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/let_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/object_literal_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/return_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/semi_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/switch_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/ternary_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/throw_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/try_node_test.rb +36 -6
- data/test/johnson/{nodes → generic/nodes}/typeof_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/unary_node_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/void_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/while_test.rb +1 -1
- data/test/johnson/{nodes → generic/nodes}/with_test.rb +1 -1
- data/test/johnson/{prelude_test.rb → generic/prelude_test.rb} +1 -1
- data/test/johnson/{runtime_test.rb → generic/runtime_test.rb} +3 -6
- data/test/johnson/generic/version_test.rb +13 -0
- data/test/johnson/{visitors → generic/visitors}/dot_visitor_test.rb +1 -1
- data/test/johnson/{visitors → generic/visitors}/enumerating_visitor_test.rb +1 -1
- data/test/johnson/generic/visitors/helper.rb +1 -0
- data/test/johnson/spidermonkey/js_land_proxy_test.rb +1 -5
- data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +11 -7
- data/test/johnson/tracemonkey/context_test.rb +21 -0
- data/test/johnson/tracemonkey/immutable_node_test.rb +34 -0
- data/test/johnson/tracemonkey/js_land_proxy_test.rb +273 -0
- data/test/johnson/tracemonkey/ruby_land_proxy_test.rb +274 -0
- data/test/johnson/tracemonkey/runtime_test.rb +41 -0
- data/test/johnson/tracemonkey/split_global_test.rb +32 -0
- data/vendor/spidermonkey/js.pkg +2 -0
- data/vendor/tracemonkey/Makefile.in +668 -0
- data/vendor/tracemonkey/Makefile.ref +483 -0
- data/vendor/tracemonkey/README.html +54 -0
- data/vendor/tracemonkey/SpiderMonkey.rsp +11 -0
- data/vendor/tracemonkey/Y.js +19 -0
- data/vendor/tracemonkey/aclocal.m4 +9 -0
- data/vendor/tracemonkey/bench.sh +5 -0
- data/vendor/tracemonkey/build/autoconf/acoutput-fast.pl +202 -0
- data/vendor/tracemonkey/build/autoconf/altoptions.m4 +154 -0
- data/vendor/tracemonkey/build/autoconf/config.guess +1537 -0
- data/vendor/tracemonkey/build/autoconf/config.sub +1595 -0
- data/vendor/tracemonkey/build/autoconf/install-sh +119 -0
- data/vendor/tracemonkey/build/autoconf/make-makefile +315 -0
- data/vendor/tracemonkey/build/autoconf/match-dir.sh +101 -0
- data/vendor/tracemonkey/build/autoconf/moznbytetype.m4 +136 -0
- data/vendor/tracemonkey/build/autoconf/nspr.m4 +82 -0
- data/vendor/tracemonkey/build/autoconf/pkg.m4 +59 -0
- data/vendor/tracemonkey/build/autoconf/update-makefile.sh +118 -0
- data/vendor/tracemonkey/build/cygwin-wrapper +75 -0
- data/vendor/tracemonkey/build/hcc +111 -0
- data/vendor/tracemonkey/build/hcpp +155 -0
- data/vendor/tracemonkey/build/unix/mddepend.pl +165 -0
- data/vendor/tracemonkey/build/unix/uniq.pl +63 -0
- data/vendor/tracemonkey/build/win32/pgomerge.py +40 -0
- data/vendor/tracemonkey/builtins.tbl +91 -0
- data/vendor/tracemonkey/call.js +13 -0
- data/vendor/tracemonkey/config.mk +206 -0
- data/vendor/tracemonkey/config/Makefile.in +106 -0
- data/vendor/tracemonkey/config/Moz/Milestone.pm +232 -0
- data/vendor/tracemonkey/config/autoconf.mk.in +362 -0
- data/vendor/tracemonkey/config/check-sync-dirs.py +103 -0
- data/vendor/tracemonkey/config/check-sync-exceptions +7 -0
- data/vendor/tracemonkey/config/config.mk +881 -0
- data/vendor/tracemonkey/config/fastcwd.pl +66 -0
- data/vendor/tracemonkey/config/gcc_hidden.h +2 -0
- data/vendor/tracemonkey/config/insure.mk +53 -0
- data/vendor/tracemonkey/config/make-system-wrappers.pl +59 -0
- data/vendor/tracemonkey/config/milestone.pl +112 -0
- data/vendor/tracemonkey/config/milestone.txt +13 -0
- data/vendor/tracemonkey/config/mkdepend/Makefile.in +84 -0
- data/vendor/tracemonkey/config/mkdepend/cppsetup.c +233 -0
- data/vendor/tracemonkey/config/mkdepend/def.h +184 -0
- data/vendor/tracemonkey/config/mkdepend/ifparser.c +551 -0
- data/vendor/tracemonkey/config/mkdepend/ifparser.h +83 -0
- data/vendor/tracemonkey/config/mkdepend/imakemdep.h +733 -0
- data/vendor/tracemonkey/config/mkdepend/include.c +337 -0
- data/vendor/tracemonkey/config/mkdepend/main.c +860 -0
- data/vendor/tracemonkey/config/mkdepend/mkdepend.man +382 -0
- data/vendor/tracemonkey/config/mkdepend/parse.c +686 -0
- data/vendor/tracemonkey/config/mkdepend/pr.c +124 -0
- data/vendor/tracemonkey/config/nfspwd.pl +50 -0
- data/vendor/tracemonkey/config/nsinstall.c +481 -0
- data/vendor/tracemonkey/config/nsinstall.py +155 -0
- data/vendor/tracemonkey/config/pathsub.c +247 -0
- data/vendor/tracemonkey/config/pathsub.h +74 -0
- data/vendor/tracemonkey/config/preprocessor.pl +671 -0
- data/vendor/tracemonkey/config/revdepth-nt.pl +48 -0
- data/vendor/tracemonkey/config/revdepth.pl +51 -0
- data/vendor/tracemonkey/config/rules.mk +2310 -0
- data/vendor/tracemonkey/config/static-checking-config.mk +21 -0
- data/vendor/tracemonkey/config/static-checking.js +92 -0
- data/vendor/tracemonkey/config/string-format.js +61 -0
- data/vendor/tracemonkey/config/system-headers +1035 -0
- data/vendor/tracemonkey/config/version.mk +85 -0
- data/vendor/tracemonkey/config/version_win.pl +442 -0
- data/vendor/tracemonkey/configure +14183 -0
- data/vendor/tracemonkey/configure.in +5363 -0
- data/vendor/tracemonkey/correct.sh +23 -0
- data/vendor/tracemonkey/correct/check-3d-morph.js +55 -0
- data/vendor/tracemonkey/correct/check-3d-raytrace.js +445 -0
- data/vendor/tracemonkey/correct/check-access-binary-trees.js +52 -0
- data/vendor/tracemonkey/correct/check-access-fannkuch.js +66 -0
- data/vendor/tracemonkey/correct/check-access-nbody.js +171 -0
- data/vendor/tracemonkey/correct/check-access-nsieve.js +40 -0
- data/vendor/tracemonkey/correct/check-bitops-3bit-bits-in-byte.js +35 -0
- data/vendor/tracemonkey/correct/check-bitops-bits-in-byte.js +24 -0
- data/vendor/tracemonkey/correct/check-bitops-bitwise-and.js +29 -0
- data/vendor/tracemonkey/correct/check-bitops-nsieve-bits.js +40 -0
- data/vendor/tracemonkey/correct/check-controlflow-recursive.js +27 -0
- data/vendor/tracemonkey/correct/check-date-format-tofte.js +302 -0
- data/vendor/tracemonkey/correct/check-date-format-xparb.js +421 -0
- data/vendor/tracemonkey/correct/check-mont.js +119 -0
- data/vendor/tracemonkey/dtoa.c +3335 -0
- data/vendor/tracemonkey/editline/Makefile.in +55 -0
- data/vendor/tracemonkey/editline/Makefile.ref +143 -0
- data/vendor/tracemonkey/editline/README +83 -0
- data/vendor/tracemonkey/editline/editline.3 +175 -0
- data/vendor/tracemonkey/editline/editline.c +1371 -0
- data/vendor/tracemonkey/editline/editline.h +135 -0
- data/vendor/tracemonkey/editline/sysunix.c +182 -0
- data/vendor/tracemonkey/editline/unix.h +82 -0
- data/vendor/tracemonkey/if.js +13 -0
- data/vendor/tracemonkey/imacro_asm.js.in +396 -0
- data/vendor/tracemonkey/imacros.c.out +1034 -0
- data/vendor/tracemonkey/imacros.jsasm +770 -0
- data/vendor/tracemonkey/javascript-trace.d +73 -0
- data/vendor/tracemonkey/jitstats.tbl +55 -0
- data/vendor/tracemonkey/js-config.h.in +82 -0
- data/vendor/tracemonkey/js-config.in +111 -0
- data/vendor/tracemonkey/js.mdp +0 -0
- data/vendor/tracemonkey/js.msg +312 -0
- data/vendor/tracemonkey/js3240.rc +79 -0
- data/vendor/tracemonkey/jsOS240.def +654 -0
- data/vendor/tracemonkey/jsapi.cpp +6005 -0
- data/vendor/tracemonkey/jsapi.h +2727 -0
- data/vendor/tracemonkey/jsarena.cpp +450 -0
- data/vendor/tracemonkey/jsarena.h +318 -0
- data/vendor/tracemonkey/jsarray.cpp +3664 -0
- data/vendor/tracemonkey/jsarray.h +238 -0
- data/vendor/tracemonkey/jsatom.cpp +1244 -0
- data/vendor/tracemonkey/jsatom.h +493 -0
- data/vendor/tracemonkey/jsbit.h +249 -0
- data/vendor/tracemonkey/jsbool.cpp +184 -0
- data/vendor/tracemonkey/jsbool.h +88 -0
- data/vendor/tracemonkey/jsbuiltins.cpp +415 -0
- data/vendor/tracemonkey/jsbuiltins.h +456 -0
- data/vendor/tracemonkey/jsclist.h +139 -0
- data/vendor/tracemonkey/jscntxt.cpp +1816 -0
- data/vendor/tracemonkey/jscntxt.h +1541 -0
- data/vendor/tracemonkey/jscompat.h +57 -0
- data/vendor/tracemonkey/jsconfig.mk +181 -0
- data/vendor/tracemonkey/jscpucfg.cpp +194 -0
- data/vendor/tracemonkey/jscpucfg.h +91 -0
- data/vendor/tracemonkey/jsdate.cpp +2465 -0
- data/vendor/tracemonkey/jsdate.h +129 -0
- data/vendor/tracemonkey/jsdbgapi.cpp +2017 -0
- data/vendor/tracemonkey/jsdbgapi.h +500 -0
- data/vendor/tracemonkey/jsdhash.cpp +876 -0
- data/vendor/tracemonkey/jsdhash.h +588 -0
- data/vendor/tracemonkey/jsdtoa.cpp +572 -0
- data/vendor/tracemonkey/jsdtoa.h +131 -0
- data/vendor/tracemonkey/jsdtracef.c +318 -0
- data/vendor/tracemonkey/jsdtracef.h +81 -0
- data/vendor/tracemonkey/jsemit.cpp +7292 -0
- data/vendor/tracemonkey/jsemit.h +802 -0
- data/vendor/tracemonkey/jsexn.cpp +1337 -0
- data/vendor/tracemonkey/jsexn.h +96 -0
- data/vendor/tracemonkey/jsfile.cpp +2747 -0
- data/vendor/tracemonkey/jsfile.h +56 -0
- data/vendor/tracemonkey/jsfile.msg +90 -0
- data/vendor/tracemonkey/jsfun.cpp +3089 -0
- data/vendor/tracemonkey/jsfun.h +366 -0
- data/vendor/tracemonkey/jsgc.cpp +3816 -0
- data/vendor/tracemonkey/jsgc.h +429 -0
- data/vendor/tracemonkey/jshash.cpp +477 -0
- data/vendor/tracemonkey/jshash.h +151 -0
- data/vendor/tracemonkey/jsify.pl +483 -0
- data/vendor/tracemonkey/jsinterp.cpp +7441 -0
- data/vendor/tracemonkey/jsinterp.h +666 -0
- data/vendor/tracemonkey/jsinvoke.cpp +42 -0
- data/vendor/tracemonkey/jsiter.cpp +1040 -0
- data/vendor/tracemonkey/jsiter.h +140 -0
- data/vendor/tracemonkey/jskeyword.tbl +124 -0
- data/vendor/tracemonkey/jskwgen.cpp +460 -0
- data/vendor/tracemonkey/jslibmath.h +69 -0
- data/vendor/tracemonkey/jslock.cpp +1512 -0
- data/vendor/tracemonkey/jslock.h +325 -0
- data/vendor/tracemonkey/jslocko.asm +60 -0
- data/vendor/tracemonkey/jslog2.cpp +111 -0
- data/vendor/tracemonkey/jslong.h +167 -0
- data/vendor/tracemonkey/jsmath.cpp +806 -0
- data/vendor/tracemonkey/jsmath.h +63 -0
- data/vendor/tracemonkey/jsnum.cpp +1374 -0
- data/vendor/tracemonkey/jsnum.h +280 -0
- data/vendor/tracemonkey/jsobj.cpp +6165 -0
- data/vendor/tracemonkey/jsobj.h +870 -0
- data/vendor/tracemonkey/json.cpp +1338 -0
- data/vendor/tracemonkey/json.h +108 -0
- data/vendor/tracemonkey/jsopcode.cpp +5484 -0
- data/vendor/tracemonkey/jsopcode.h +434 -0
- data/vendor/tracemonkey/jsopcode.tbl +591 -0
- data/vendor/tracemonkey/jsoplengen.cpp +121 -0
- data/vendor/tracemonkey/jsotypes.h +202 -0
- data/vendor/tracemonkey/jsparse.cpp +9257 -0
- data/vendor/tracemonkey/jsparse.h +900 -0
- data/vendor/tracemonkey/jsprf.cpp +1262 -0
- data/vendor/tracemonkey/jsprf.h +150 -0
- data/vendor/tracemonkey/jsproto.tbl +117 -0
- data/vendor/tracemonkey/jsprvtd.h +366 -0
- data/vendor/tracemonkey/jspubtd.h +585 -0
- data/vendor/tracemonkey/jsregexp.cpp +5051 -0
- data/vendor/tracemonkey/jsregexp.h +199 -0
- data/vendor/tracemonkey/jsreops.tbl +145 -0
- data/vendor/tracemonkey/jsscan.cpp +2040 -0
- data/vendor/tracemonkey/jsscan.h +467 -0
- data/vendor/tracemonkey/jsscope.cpp +1966 -0
- data/vendor/tracemonkey/jsscope.h +487 -0
- data/vendor/tracemonkey/jsscript.cpp +1932 -0
- data/vendor/tracemonkey/jsscript.h +345 -0
- data/vendor/tracemonkey/jsshell.msg +54 -0
- data/vendor/tracemonkey/jsstack.js +167 -0
- data/vendor/tracemonkey/jsstaticcheck.h +69 -0
- data/vendor/tracemonkey/jsstddef.h +87 -0
- data/vendor/tracemonkey/jsstdint.h +96 -0
- data/vendor/tracemonkey/jsstr.cpp +5277 -0
- data/vendor/tracemonkey/jsstr.h +702 -0
- data/vendor/tracemonkey/jstracer.cpp +10991 -0
- data/vendor/tracemonkey/jstracer.h +794 -0
- data/vendor/tracemonkey/jstypes.h +481 -0
- data/vendor/tracemonkey/jsutil.cpp +361 -0
- data/vendor/tracemonkey/jsutil.h +178 -0
- data/vendor/tracemonkey/jsversion.h +243 -0
- data/vendor/tracemonkey/jswince.asm +44 -0
- data/vendor/tracemonkey/jsxdrapi.cpp +800 -0
- data/vendor/tracemonkey/jsxdrapi.h +220 -0
- data/vendor/tracemonkey/jsxml.cpp +8327 -0
- data/vendor/tracemonkey/jsxml.h +305 -0
- data/vendor/tracemonkey/liveconnect/LiveConnect.dsp +157 -0
- data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsp +120 -0
- data/vendor/tracemonkey/liveconnect/LiveConnectShell.dsw +44 -0
- data/vendor/tracemonkey/liveconnect/Makefile.in +105 -0
- data/vendor/tracemonkey/liveconnect/Makefile.ref +169 -0
- data/vendor/tracemonkey/liveconnect/README.html +712 -0
- data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSException.h +14 -0
- data/vendor/tracemonkey/liveconnect/_jni/netscape_javascript_JSObject.h +155 -0
- data/vendor/tracemonkey/liveconnect/classes/Makefile.in +89 -0
- data/vendor/tracemonkey/liveconnect/classes/Makefile.ref +57 -0
- data/vendor/tracemonkey/liveconnect/classes/netscape/Makefile.ref +47 -0
- data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSException.java +140 -0
- data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSObject.java +183 -0
- data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSProxy.java +58 -0
- data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSRunnable.java +70 -0
- data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/JSUtil.java +59 -0
- data/vendor/tracemonkey/liveconnect/classes/netscape/javascript/Makefile.ref +53 -0
- data/vendor/tracemonkey/liveconnect/config/AIX4.1.mk +45 -0
- data/vendor/tracemonkey/liveconnect/config/AIX4.2.mk +45 -0
- data/vendor/tracemonkey/liveconnect/config/AIX4.3.mk +50 -0
- data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.10.mk +43 -0
- data/vendor/tracemonkey/liveconnect/config/HP-UXB.10.20.mk +43 -0
- data/vendor/tracemonkey/liveconnect/config/HP-UXB.11.00.mk +43 -0
- data/vendor/tracemonkey/liveconnect/config/IRIX6.2.mk +43 -0
- data/vendor/tracemonkey/liveconnect/config/IRIX6.3.mk +43 -0
- data/vendor/tracemonkey/liveconnect/config/IRIX6.5.mk +43 -0
- data/vendor/tracemonkey/liveconnect/config/Linux_All.mk +73 -0
- data/vendor/tracemonkey/liveconnect/config/OSF1V4.0.mk +65 -0
- data/vendor/tracemonkey/liveconnect/config/OSF1V5.0.mk +62 -0
- data/vendor/tracemonkey/liveconnect/config/SunOS5.5.1.mk +55 -0
- data/vendor/tracemonkey/liveconnect/config/SunOS5.6.mk +39 -0
- data/vendor/tracemonkey/liveconnect/config/SunOS5.7.mk +39 -0
- data/vendor/tracemonkey/liveconnect/config/SunOS5.8.mk +39 -0
- data/vendor/tracemonkey/liveconnect/config/WINNT4.0.mk +53 -0
- data/vendor/tracemonkey/liveconnect/jsj.c +886 -0
- data/vendor/tracemonkey/liveconnect/jsj.msg +98 -0
- data/vendor/tracemonkey/liveconnect/jsj_JSObject.c +1377 -0
- data/vendor/tracemonkey/liveconnect/jsj_JavaArray.c +474 -0
- data/vendor/tracemonkey/liveconnect/jsj_JavaClass.c +737 -0
- data/vendor/tracemonkey/liveconnect/jsj_JavaMember.c +191 -0
- data/vendor/tracemonkey/liveconnect/jsj_JavaObject.c +1079 -0
- data/vendor/tracemonkey/liveconnect/jsj_JavaPackage.c +569 -0
- data/vendor/tracemonkey/liveconnect/jsj_array.c +207 -0
- data/vendor/tracemonkey/liveconnect/jsj_class.c +770 -0
- data/vendor/tracemonkey/liveconnect/jsj_convert.c +902 -0
- data/vendor/tracemonkey/liveconnect/jsj_field.c +421 -0
- data/vendor/tracemonkey/liveconnect/jsj_hash.c +488 -0
- data/vendor/tracemonkey/liveconnect/jsj_hash.h +161 -0
- data/vendor/tracemonkey/liveconnect/jsj_method.c +1825 -0
- data/vendor/tracemonkey/liveconnect/jsj_nodl.c +1 -0
- data/vendor/tracemonkey/liveconnect/jsj_private.h +677 -0
- data/vendor/tracemonkey/liveconnect/jsj_simpleapi.c +219 -0
- data/vendor/tracemonkey/liveconnect/jsj_utils.c +513 -0
- data/vendor/tracemonkey/liveconnect/jsjava.h +316 -0
- data/vendor/tracemonkey/liveconnect/netscape_javascript_JSObject.h +155 -0
- data/vendor/tracemonkey/liveconnect/nsCLiveconnect.cpp +785 -0
- data/vendor/tracemonkey/liveconnect/nsCLiveconnect.h +197 -0
- data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.cpp +118 -0
- data/vendor/tracemonkey/liveconnect/nsCLiveconnectFactory.h +76 -0
- data/vendor/tracemonkey/liveconnect/nsILiveconnect.h +197 -0
- data/vendor/tracemonkey/liveconnect/nsISecureLiveconnect.h +94 -0
- data/vendor/tracemonkey/liveconnect/nsISecurityContext.h +136 -0
- data/vendor/tracemonkey/lock_SunOS.s +119 -0
- data/vendor/tracemonkey/mandelbrot-results.js +3 -0
- data/vendor/tracemonkey/math-partial-sums.js +32 -0
- data/vendor/tracemonkey/math-trace-tests.js +507 -0
- data/vendor/tracemonkey/md5.js +289 -0
- data/vendor/tracemonkey/nanojit/Assembler.cpp +1984 -0
- data/vendor/tracemonkey/nanojit/Assembler.h +375 -0
- data/vendor/tracemonkey/nanojit/Fragmento.cpp +651 -0
- data/vendor/tracemonkey/nanojit/Fragmento.h +237 -0
- data/vendor/tracemonkey/nanojit/LIR.cpp +2314 -0
- data/vendor/tracemonkey/nanojit/LIR.h +879 -0
- data/vendor/tracemonkey/nanojit/LIRopcode.tbl +252 -0
- data/vendor/tracemonkey/nanojit/Native.h +127 -0
- data/vendor/tracemonkey/nanojit/NativeARM.cpp +1742 -0
- data/vendor/tracemonkey/nanojit/NativeARM.h +844 -0
- data/vendor/tracemonkey/nanojit/NativeSparc.cpp +1130 -0
- data/vendor/tracemonkey/nanojit/NativeSparc.h +948 -0
- data/vendor/tracemonkey/nanojit/NativeThumb.cpp +1322 -0
- data/vendor/tracemonkey/nanojit/NativeThumb.h +525 -0
- data/vendor/tracemonkey/nanojit/Nativei386.cpp +1748 -0
- data/vendor/tracemonkey/nanojit/Nativei386.h +857 -0
- data/vendor/tracemonkey/nanojit/RegAlloc.cpp +183 -0
- data/vendor/tracemonkey/nanojit/RegAlloc.h +95 -0
- data/vendor/tracemonkey/nanojit/TraceTreeDrawer.cpp +306 -0
- data/vendor/tracemonkey/nanojit/TraceTreeDrawer.h +88 -0
- data/vendor/tracemonkey/nanojit/avmplus.cpp +56 -0
- data/vendor/tracemonkey/nanojit/avmplus.h +1016 -0
- data/vendor/tracemonkey/nanojit/nanojit.h +253 -0
- data/vendor/tracemonkey/perfect.js +39 -0
- data/vendor/tracemonkey/plify_jsdhash.sed +35 -0
- data/vendor/tracemonkey/prmjtime.cpp +869 -0
- data/vendor/tracemonkey/prmjtime.h +103 -0
- data/vendor/tracemonkey/ref-config/AIX4.1.mk +65 -0
- data/vendor/tracemonkey/ref-config/AIX4.2.mk +64 -0
- data/vendor/tracemonkey/ref-config/AIX4.3.mk +65 -0
- data/vendor/tracemonkey/ref-config/Darwin.mk +85 -0
- data/vendor/tracemonkey/ref-config/Darwin1.3.mk +81 -0
- data/vendor/tracemonkey/ref-config/Darwin1.4.mk +41 -0
- data/vendor/tracemonkey/ref-config/Darwin5.2.mk +81 -0
- data/vendor/tracemonkey/ref-config/Darwin5.3.mk +81 -0
- data/vendor/tracemonkey/ref-config/Darwin64.mk +72 -0
- data/vendor/tracemonkey/ref-config/HP-UXB.10.10.mk +77 -0
- data/vendor/tracemonkey/ref-config/HP-UXB.10.20.mk +77 -0
- data/vendor/tracemonkey/ref-config/HP-UXB.11.00.mk +80 -0
- data/vendor/tracemonkey/ref-config/IRIX.mk +87 -0
- data/vendor/tracemonkey/ref-config/IRIX5.3.mk +44 -0
- data/vendor/tracemonkey/ref-config/IRIX6.1.mk +44 -0
- data/vendor/tracemonkey/ref-config/IRIX6.2.mk +44 -0
- data/vendor/tracemonkey/ref-config/IRIX6.3.mk +44 -0
- data/vendor/tracemonkey/ref-config/IRIX6.5.mk +44 -0
- data/vendor/tracemonkey/ref-config/Linux_All.mk +105 -0
- data/vendor/tracemonkey/ref-config/Mac_OS10.0.mk +82 -0
- data/vendor/tracemonkey/ref-config/OSF1V4.0.mk +72 -0
- data/vendor/tracemonkey/ref-config/OSF1V5.0.mk +69 -0
- data/vendor/tracemonkey/ref-config/SunOS4.1.4.mk +101 -0
- data/vendor/tracemonkey/ref-config/SunOS5.10.mk +50 -0
- data/vendor/tracemonkey/ref-config/SunOS5.3.mk +91 -0
- data/vendor/tracemonkey/ref-config/SunOS5.4.mk +92 -0
- data/vendor/tracemonkey/ref-config/SunOS5.5.1.mk +44 -0
- data/vendor/tracemonkey/ref-config/SunOS5.5.mk +87 -0
- data/vendor/tracemonkey/ref-config/SunOS5.6.mk +89 -0
- data/vendor/tracemonkey/ref-config/SunOS5.7.mk +44 -0
- data/vendor/tracemonkey/ref-config/SunOS5.8.mk +44 -0
- data/vendor/tracemonkey/ref-config/SunOS5.9.mk +44 -0
- data/vendor/tracemonkey/ref-config/WINNT4.0.mk +118 -0
- data/vendor/tracemonkey/ref-config/WINNT5.0.mk +118 -0
- data/vendor/tracemonkey/ref-config/WINNT5.1.mk +118 -0
- data/vendor/tracemonkey/ref-config/WINNT5.2.mk +118 -0
- data/vendor/tracemonkey/ref-config/WINNT6.0.mk +118 -0
- data/vendor/tracemonkey/ref-config/dgux.mk +64 -0
- data/vendor/tracemonkey/resource.h +15 -0
- data/vendor/tracemonkey/rules.mk +206 -0
- data/vendor/tracemonkey/shell/Makefile.in +72 -0
- data/vendor/tracemonkey/shell/js.cpp +4719 -0
- data/vendor/tracemonkey/t/3d-cube.js +337 -0
- data/vendor/tracemonkey/t/3d-morph.js +54 -0
- data/vendor/tracemonkey/t/3d-raytrace.js +441 -0
- data/vendor/tracemonkey/t/access-binary-trees.js +50 -0
- data/vendor/tracemonkey/t/access-fannkuch.js +66 -0
- data/vendor/tracemonkey/t/access-nbody.js +169 -0
- data/vendor/tracemonkey/t/access-nsieve.js +38 -0
- data/vendor/tracemonkey/t/bitops-3bit-bits-in-byte.js +32 -0
- data/vendor/tracemonkey/t/bitops-bits-in-byte.js +21 -0
- data/vendor/tracemonkey/t/bitops-bitwise-and.js +28 -0
- data/vendor/tracemonkey/t/bitops-nsieve-bits.js +32 -0
- data/vendor/tracemonkey/t/controlflow-recursive.js +25 -0
- data/vendor/tracemonkey/t/crypto-aes.js +422 -0
- data/vendor/tracemonkey/t/crypto-md5.js +286 -0
- data/vendor/tracemonkey/t/crypto-sha1.js +224 -0
- data/vendor/tracemonkey/t/date-format-tofte.js +299 -0
- data/vendor/tracemonkey/t/date-format-xparb.js +417 -0
- data/vendor/tracemonkey/t/math-cordic.js +95 -0
- data/vendor/tracemonkey/t/math-partial-sums.js +33 -0
- data/vendor/tracemonkey/t/math-spectral-norm.js +51 -0
- data/vendor/tracemonkey/t/regexp-dna.js +1712 -0
- data/vendor/tracemonkey/t/string-base64.js +135 -0
- data/vendor/tracemonkey/t/string-fasta.js +85 -0
- data/vendor/tracemonkey/t/string-tagcloud.js +265 -0
- data/vendor/tracemonkey/t/string-unpack-code.js +68 -0
- data/vendor/tracemonkey/t/string-validate-input.js +89 -0
- data/vendor/tracemonkey/time.sh +13 -0
- data/vendor/tracemonkey/trace-test.js +5564 -0
- data/vendor/tracemonkey/v8/base.js +187 -0
- data/vendor/tracemonkey/v8/crypto.js +1689 -0
- data/vendor/tracemonkey/v8/deltablue.js +880 -0
- data/vendor/tracemonkey/v8/earley-boyer.js +4682 -0
- data/vendor/tracemonkey/v8/raytrace.js +3418 -0
- data/vendor/tracemonkey/v8/richards.js +539 -0
- data/vendor/tracemonkey/v8/run-crypto.js +44 -0
- data/vendor/tracemonkey/v8/run-deltablue.js +44 -0
- data/vendor/tracemonkey/v8/run-earley-boyer.js +44 -0
- data/vendor/tracemonkey/v8/run-raytrace.js +44 -0
- data/vendor/tracemonkey/v8/run-richards.js +44 -0
- data/vendor/tracemonkey/v8/run.js +49 -0
- data/vendor/tracemonkey/vprof/readme.txt +93 -0
- data/vendor/tracemonkey/vprof/vprof.cpp +360 -0
- data/vendor/tracemonkey/vprof/vprof.h +245 -0
- data/vendor/tracemonkey/xpconnect/Makefile.in +67 -0
- data/vendor/tracemonkey/xpconnect/crashtests/117307-1.html +20 -0
- data/vendor/tracemonkey/xpconnect/crashtests/193710.html +11 -0
- data/vendor/tracemonkey/xpconnect/crashtests/290162-1.html +5 -0
- data/vendor/tracemonkey/xpconnect/crashtests/326615-1.html +16 -0
- data/vendor/tracemonkey/xpconnect/crashtests/328553-1.html +13 -0
- data/vendor/tracemonkey/xpconnect/crashtests/346258-1.html +12 -0
- data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame1.xhtml +16 -0
- data/vendor/tracemonkey/xpconnect/crashtests/346512-1-frame2.xhtml +15 -0
- data/vendor/tracemonkey/xpconnect/crashtests/346512-1.xhtml +30 -0
- data/vendor/tracemonkey/xpconnect/crashtests/382133-1.html +3 -0
- data/vendor/tracemonkey/xpconnect/crashtests/386680-1.html +22 -0
- data/vendor/tracemonkey/xpconnect/crashtests/394810-1.html +4 -0
- data/vendor/tracemonkey/xpconnect/crashtests/400349-1.html +20 -0
- data/vendor/tracemonkey/xpconnect/crashtests/403356-1.html +13 -0
- data/vendor/tracemonkey/xpconnect/crashtests/418139-1.svg +22 -0
- data/vendor/tracemonkey/xpconnect/crashtests/420513-1.html +11 -0
- data/vendor/tracemonkey/xpconnect/crashtests/453935-1.html +37 -0
- data/vendor/tracemonkey/xpconnect/crashtests/462926.html +12 -0
- data/vendor/tracemonkey/xpconnect/crashtests/468552-1.html +18 -0
- data/vendor/tracemonkey/xpconnect/crashtests/471366-1.html +12 -0
- data/vendor/tracemonkey/xpconnect/crashtests/475185-1.html +13 -0
- data/vendor/tracemonkey/xpconnect/crashtests/475291-1.html +14 -0
- data/vendor/tracemonkey/xpconnect/crashtests/503286-1.html +23 -0
- data/vendor/tracemonkey/xpconnect/crashtests/crashtests.list +21 -0
- data/vendor/tracemonkey/xpconnect/idl/Makefile.in +78 -0
- data/vendor/tracemonkey/xpconnect/idl/XPCIDispatch.idl +51 -0
- data/vendor/tracemonkey/xpconnect/idl/mozIJSSubScriptLoader.idl +64 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIActiveXSecurityPolicy.idl +67 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIDispatchSupport.idl +119 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIJSContextStack.idl +85 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIJSRuntimeService.idl +51 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIScriptError.idl +102 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIScriptableInterfaces.idl +67 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptNotify.idl +66 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIXPCScriptable.idl +183 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIXPCSecurityManager.idl +114 -0
- data/vendor/tracemonkey/xpconnect/idl/nsIXPConnect.idl +819 -0
- data/vendor/tracemonkey/xpconnect/idl/xpcIJSModuleLoader.idl +95 -0
- data/vendor/tracemonkey/xpconnect/idl/xpcIJSWeakReference.idl +49 -0
- data/vendor/tracemonkey/xpconnect/idl/xpccomponents.idl +254 -0
- data/vendor/tracemonkey/xpconnect/idl/xpcexception.idl +66 -0
- data/vendor/tracemonkey/xpconnect/idl/xpcjsid.idl +83 -0
- data/vendor/tracemonkey/xpconnect/loader/ISO8601DateUtils.jsm +176 -0
- data/vendor/tracemonkey/xpconnect/loader/Makefile.in +63 -0
- data/vendor/tracemonkey/xpconnect/loader/XPCOMUtils.jsm +267 -0
- data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.cpp +1717 -0
- data/vendor/tracemonkey/xpconnect/loader/mozJSComponentLoader.h +172 -0
- data/vendor/tracemonkey/xpconnect/loader/mozJSLoaderConstructors.h +101 -0
- data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.cpp +360 -0
- data/vendor/tracemonkey/xpconnect/loader/mozJSSubScriptLoader.h +66 -0
- data/vendor/tracemonkey/xpconnect/public/Makefile.in +54 -0
- data/vendor/tracemonkey/xpconnect/public/nsAXPCNativeCallContext.h +89 -0
- data/vendor/tracemonkey/xpconnect/public/nsAutoJSValHolder.h +168 -0
- data/vendor/tracemonkey/xpconnect/public/xpc_map_end.h +327 -0
- data/vendor/tracemonkey/xpconnect/sample/Makefile.in +71 -0
- data/vendor/tracemonkey/xpconnect/sample/README +39 -0
- data/vendor/tracemonkey/xpconnect/sample/xpcsample1.cpp +337 -0
- data/vendor/tracemonkey/xpconnect/sample/xpcsample1.idl +82 -0
- data/vendor/tracemonkey/xpconnect/sample/xpcsample1.js +21 -0
- data/vendor/tracemonkey/xpconnect/shell/Makefile.in +106 -0
- data/vendor/tracemonkey/xpconnect/shell/jsshell.msg +50 -0
- data/vendor/tracemonkey/xpconnect/shell/xpcshell.cpp +1817 -0
- data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.h +43 -0
- data/vendor/tracemonkey/xpconnect/shell/xpcshellMacUtils.mm +54 -0
- data/vendor/tracemonkey/xpconnect/src/Makefile.in +228 -0
- data/vendor/tracemonkey/xpconnect/src/README +3 -0
- data/vendor/tracemonkey/xpconnect/src/XPCCrossOriginWrapper.cpp +1186 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispConvert.cpp +593 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispInlines.h +667 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispInterface.cpp +383 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispObject.cpp +516 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispParamPropJSClass.cpp +223 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispParams.cpp +103 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispPrivate.h +1401 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispTearOff.cpp +547 -0
- data/vendor/tracemonkey/xpconnect/src/XPCDispTypeInfo.cpp +471 -0
- data/vendor/tracemonkey/xpconnect/src/XPCIDispatchClassInfo.cpp +139 -0
- data/vendor/tracemonkey/xpconnect/src/XPCIDispatchExtension.cpp +362 -0
- data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.cpp +1350 -0
- data/vendor/tracemonkey/xpconnect/src/XPCNativeWrapper.h +88 -0
- data/vendor/tracemonkey/xpconnect/src/XPCSafeJSObjectWrapper.cpp +1148 -0
- data/vendor/tracemonkey/xpconnect/src/XPCSystemOnlyWrapper.cpp +718 -0
- data/vendor/tracemonkey/xpconnect/src/XPCWrapper.cpp +850 -0
- data/vendor/tracemonkey/xpconnect/src/XPCWrapper.h +394 -0
- data/vendor/tracemonkey/xpconnect/src/dom_quickstubs.qsconf +568 -0
- data/vendor/tracemonkey/xpconnect/src/nsDispatchSupport.cpp +348 -0
- data/vendor/tracemonkey/xpconnect/src/nsScriptError.cpp +201 -0
- data/vendor/tracemonkey/xpconnect/src/nsXPConnect.cpp +2609 -0
- data/vendor/tracemonkey/xpconnect/src/qsgen.py +1487 -0
- data/vendor/tracemonkey/xpconnect/src/xpc.msg +217 -0
- data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.cpp +148 -0
- data/vendor/tracemonkey/xpconnect/src/xpcJSWeakReference.h +56 -0
- data/vendor/tracemonkey/xpconnect/src/xpccallcontext.cpp +579 -0
- data/vendor/tracemonkey/xpconnect/src/xpccomponents.cpp +4144 -0
- data/vendor/tracemonkey/xpconnect/src/xpccontext.cpp +115 -0
- data/vendor/tracemonkey/xpconnect/src/xpcconvert.cpp +2298 -0
- data/vendor/tracemonkey/xpconnect/src/xpcdebug.cpp +481 -0
- data/vendor/tracemonkey/xpconnect/src/xpcexception.cpp +502 -0
- data/vendor/tracemonkey/xpconnect/src/xpcforwards.h +114 -0
- data/vendor/tracemonkey/xpconnect/src/xpcinlines.h +772 -0
- data/vendor/tracemonkey/xpconnect/src/xpcjsid.cpp +1025 -0
- data/vendor/tracemonkey/xpconnect/src/xpcjsruntime.cpp +1342 -0
- data/vendor/tracemonkey/xpconnect/src/xpclog.cpp +128 -0
- data/vendor/tracemonkey/xpconnect/src/xpclog.h +101 -0
- data/vendor/tracemonkey/xpconnect/src/xpcmaps.cpp +761 -0
- data/vendor/tracemonkey/xpconnect/src/xpcmaps.h +713 -0
- data/vendor/tracemonkey/xpconnect/src/xpcmodule.cpp +136 -0
- data/vendor/tracemonkey/xpconnect/src/xpcprivate.h +4138 -0
- data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.cpp +1128 -0
- data/vendor/tracemonkey/xpconnect/src/xpcquickstubs.h +480 -0
- data/vendor/tracemonkey/xpconnect/src/xpcruntimesvc.cpp +179 -0
- data/vendor/tracemonkey/xpconnect/src/xpcstack.cpp +342 -0
- data/vendor/tracemonkey/xpconnect/src/xpcstring.cpp +139 -0
- data/vendor/tracemonkey/xpconnect/src/xpcthreadcontext.cpp +599 -0
- data/vendor/tracemonkey/xpconnect/src/xpcthrower.cpp +399 -0
- data/vendor/tracemonkey/xpconnect/src/xpcvariant.cpp +850 -0
- data/vendor/tracemonkey/xpconnect/src/xpcwrappedjs.cpp +670 -0
- data/vendor/tracemonkey/xpconnect/src/xpcwrappedjsclass.cpp +2015 -0
- data/vendor/tracemonkey/xpconnect/src/xpcwrappednative.cpp +3482 -0
- data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeinfo.cpp +945 -0
- data/vendor/tracemonkey/xpconnect/src/xpcwrappednativejsops.cpp +2003 -0
- data/vendor/tracemonkey/xpconnect/src/xpcwrappednativeproto.cpp +302 -0
- data/vendor/tracemonkey/xpconnect/src/xpcwrappednativescope.cpp +991 -0
- data/vendor/tracemonkey/xpconnect/tests/Makefile.in +75 -0
- data/vendor/tracemonkey/xpconnect/tests/TestXPC.cpp +785 -0
- data/vendor/tracemonkey/xpconnect/tests/chrome/Makefile.in +51 -0
- data/vendor/tracemonkey/xpconnect/tests/chrome/test_bug500931.xul +43 -0
- data/vendor/tracemonkey/xpconnect/tests/components/Makefile.in +85 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_array.cpp +388 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_attributes.cpp +305 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_calljs.cpp +135 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_child.cpp +225 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_const.cpp +76 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_domstring.cpp +118 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_echo.cpp +616 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_in.cpp +204 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_inout.cpp +171 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_module.cpp +77 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_multiple.cpp +554 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_noisy.cpp +154 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_out.cpp +335 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_overloaded.cpp +250 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_private.h +192 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_string.cpp +185 -0
- data/vendor/tracemonkey/xpconnect/tests/components/xpctest_variant.cpp +355 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.cpp +12 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/StdAfx.h +28 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCDispUtilities.h +28 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.cpp +86 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.def +9 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsp +318 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.dsw +29 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.idl +454 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/XPCIDispatchTest.rc +145 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.cpp +44 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.h +56 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispSimple.rgs +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.cpp +221 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.h +53 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestArrays.rgs +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.cpp +699 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.h +138 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestMethods.rgs +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.cpp +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.h +41 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestNoIDispatch.rgs +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.cpp +256 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.h +88 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestProperties.rgs +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.cpp +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.h +43 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOff.rgs +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.cpp +29 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.h +45 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestScriptOn.rgs +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.cpp +177 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.h +50 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/nsXPCDispTestWrappedJS.rgs +23 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/COM/resource.h +36 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Arrays/XPCIDispatchArrayTests.js +54 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Attributes/XPCIDispatchAttributeTests.js +150 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCIDispatchInstantiations.js +122 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/General/XPCStress.js +58 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/Methods/XPCIDispatchMethodTests.js +376 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedCOM/shell.js +377 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/General/XPCIDispatchTestWrappedJS.js +76 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/WrappedJS/shell.js +377 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/exectests.cmd +1 -0
- data/vendor/tracemonkey/xpconnect/tests/idispatch/Tests/jsDriver.pl +1288 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/Makefile.in +61 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest.idl +312 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest2.idl +51 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_attributes.idl +67 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_calljs.idl +59 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_const.idl +61 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_domstring.idl +59 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_in.idl +88 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_inout.idl +86 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_multiple.idl +77 -0
- data/vendor/tracemonkey/xpconnect/tests/idl/xpctest_out.idl +142 -0
- data/vendor/tracemonkey/xpconnect/tests/js/checkid.js +82 -0
- data/vendor/tracemonkey/xpconnect/tests/js/evaluate.js +311 -0
- data/vendor/tracemonkey/xpconnect/tests/js/exceptions-2.js +153 -0
- data/vendor/tracemonkey/xpconnect/tests/js/exceptions-3.js +194 -0
- data/vendor/tracemonkey/xpconnect/tests/js/exceptions-4.js +297 -0
- data/vendor/tracemonkey/xpconnect/tests/js/exceptions-5.js +343 -0
- data/vendor/tracemonkey/xpconnect/tests/js/exceptions.js +230 -0
- data/vendor/tracemonkey/xpconnect/tests/js/javascript.js +96 -0
- data/vendor/tracemonkey/xpconnect/tests/js/multiple-2.js +151 -0
- data/vendor/tracemonkey/xpconnect/tests/js/multiple-3.js +148 -0
- data/vendor/tracemonkey/xpconnect/tests/js/multiple-4.js +152 -0
- data/vendor/tracemonkey/xpconnect/tests/js/multiple.js +137 -0
- data/vendor/tracemonkey/xpconnect/tests/js/notscriptable.js +104 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/simpletest.js +36 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/speed.js +60 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/testxpc.js +464 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/threads.js +74 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/try.js +27 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_array.js +308 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_callcontext.js +68 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_echo.js +636 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_and_sort.js +28 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_constants.js +15 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_enum_create.js +200 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_exceptions.js +167 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_ids.js +135 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_observer.js +36 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_overloaded.js +14 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_primitives.js +141 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_propertybag.js +36 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant.js +339 -0
- data/vendor/tracemonkey/xpconnect/tests/js/old/xpctest_variant_array.js +30 -0
- data/vendor/tracemonkey/xpconnect/tests/js/readonlyattributes.js +74 -0
- data/vendor/tracemonkey/xpconnect/tests/js/readwriteattributes.js +101 -0
- data/vendor/tracemonkey/xpconnect/tests/js/scriptable.js +120 -0
- data/vendor/tracemonkey/xpconnect/tests/js/testin.js +203 -0
- data/vendor/tracemonkey/xpconnect/tests/js/xpcfun.js +234 -0
- data/vendor/tracemonkey/xpconnect/tests/js/xpctest_primitives.js +200 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/Makefile.in +66 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/bug500931_helper.html +7 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/inner.html +7 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug361111.xul +29 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug384632.html +32 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug390488.html +65 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug393269.html +46 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug396851.html +43 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug428021.html +41 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug446584.html +49 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug448587.html +31 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug462428.html +42 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug478438.html +66 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484107.html +100 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug484459.html +36 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_bug500691.html +28 -0
- data/vendor/tracemonkey/xpconnect/tests/mochitest/test_wrappers.html +116 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/bogus_element_type.jsm +1 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/bogus_exports_type.jsm +1 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/bug451678_subscript.js +2 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/component_import.js +144 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importA.jsm +44 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/recursive_importB.jsm +45 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/syntax_error.jsm +1 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/test_bogus_files.js +88 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/test_bug408412.js +51 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/test_bug451678.js +52 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/test_bug_442086.js +68 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/test_import.js +127 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/test_js_weak_references.js +63 -0
- data/vendor/tracemonkey/xpconnect/tests/unit/test_recursive_import.js +62 -0
- data/vendor/tracemonkey/xpconnect/tools/Makefile.in +49 -0
- data/vendor/tracemonkey/xpconnect/tools/idl/Makefile.in +53 -0
- data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsCompiler.idl +60 -0
- data/vendor/tracemonkey/xpconnect/tools/idl/nsIXPCToolsProfiler.idl +57 -0
- data/vendor/tracemonkey/xpconnect/tools/js/CompileJSFiles.js +28 -0
- data/vendor/tracemonkey/xpconnect/tools/js/ListJSFiles.js +18 -0
- data/vendor/tracemonkey/xpconnect/tools/src/Makefile.in +76 -0
- data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsCompiler.cpp +161 -0
- data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsModule.cpp +65 -0
- data/vendor/tracemonkey/xpconnect/tools/src/nsXPCToolsProfiler.cpp +370 -0
- data/vendor/tracemonkey/xpconnect/tools/src/xpctools_private.h +236 -0
- metadata +782 -107
- data/test/johnson/nodes/export_test.rb +0 -9
- data/test/johnson/nodes/import_test.rb +0 -13
- data/test/johnson/version_test.rb +0 -13
@@ -0,0 +1,2015 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2
|
+
*
|
3
|
+
* ***** BEGIN LICENSE BLOCK *****
|
4
|
+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
5
|
+
*
|
6
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
7
|
+
* 1.1 (the "License"); you may not use this file except in compliance with
|
8
|
+
* the License. You may obtain a copy of the License at
|
9
|
+
* http://www.mozilla.org/MPL/
|
10
|
+
*
|
11
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
12
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
13
|
+
* for the specific language governing rights and limitations under the
|
14
|
+
* License.
|
15
|
+
*
|
16
|
+
* The Original Code is Mozilla Communicator client code, released
|
17
|
+
* March 31, 1998.
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is
|
20
|
+
* Netscape Communications Corporation.
|
21
|
+
* Portions created by the Initial Developer are Copyright (C) 1999
|
22
|
+
* the Initial Developer. All Rights Reserved.
|
23
|
+
*
|
24
|
+
* Contributor(s):
|
25
|
+
* John Bandhauer <jband@netscape.com> (original author)
|
26
|
+
* Pierre Phaneuf <pp@ludusdesign.com>
|
27
|
+
*
|
28
|
+
* Alternatively, the contents of this file may be used under the terms of
|
29
|
+
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
30
|
+
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
31
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
32
|
+
* of those above. If you wish to allow use of your version of this file only
|
33
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
34
|
+
* use your version of this file under the terms of the MPL, indicate your
|
35
|
+
* decision by deleting the provisions above and replace them with the notice
|
36
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
37
|
+
* the provisions above, a recipient may use your version of this file under
|
38
|
+
* the terms of any one of the MPL, the GPL or the LGPL.
|
39
|
+
*
|
40
|
+
* ***** END LICENSE BLOCK ***** */
|
41
|
+
|
42
|
+
/* Sharable code and data for wrapper around JSObjects. */
|
43
|
+
|
44
|
+
#include "xpcprivate.h"
|
45
|
+
#include "XPCWrapper.h"
|
46
|
+
#include "nsWrapperCache.h"
|
47
|
+
|
48
|
+
NS_IMPL_THREADSAFE_ISUPPORTS1(nsXPCWrappedJSClass, nsIXPCWrappedJSClass)
|
49
|
+
|
50
|
+
// the value of this variable is never used - we use its address as a sentinel
|
51
|
+
static uint32 zero_methods_descriptor;
|
52
|
+
|
53
|
+
void AutoScriptEvaluate::StartEvaluating(JSErrorReporter errorReporter)
|
54
|
+
{
|
55
|
+
NS_PRECONDITION(!mEvaluated, "AutoScriptEvaluate::Evaluate should only be called once");
|
56
|
+
|
57
|
+
if(!mJSContext)
|
58
|
+
return;
|
59
|
+
mEvaluated = PR_TRUE;
|
60
|
+
if(!mJSContext->errorReporter)
|
61
|
+
{
|
62
|
+
JS_SetErrorReporter(mJSContext, errorReporter);
|
63
|
+
mErrorReporterSet = PR_TRUE;
|
64
|
+
}
|
65
|
+
mContextHasThread = JS_GetContextThread(mJSContext);
|
66
|
+
if (mContextHasThread)
|
67
|
+
JS_BeginRequest(mJSContext);
|
68
|
+
|
69
|
+
// Saving the exception state keeps us from interfering with another script
|
70
|
+
// that may also be running on this context. This occurred first with the
|
71
|
+
// js debugger, as described in
|
72
|
+
// http://bugzilla.mozilla.org/show_bug.cgi?id=88130 but presumably could
|
73
|
+
// show up in any situation where a script calls into a wrapped js component
|
74
|
+
// on the same context, while the context has a nonzero exception state.
|
75
|
+
// Because JS_SaveExceptionState/JS_RestoreExceptionState use malloc
|
76
|
+
// and addroot, we avoid them if possible by returning null (as opposed to
|
77
|
+
// a JSExceptionState with no information) when there is no pending
|
78
|
+
// exception.
|
79
|
+
if(JS_IsExceptionPending(mJSContext))
|
80
|
+
{
|
81
|
+
mState = JS_SaveExceptionState(mJSContext);
|
82
|
+
JS_ClearPendingException(mJSContext);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
AutoScriptEvaluate::~AutoScriptEvaluate()
|
87
|
+
{
|
88
|
+
if(!mJSContext || !mEvaluated)
|
89
|
+
return;
|
90
|
+
if(mState)
|
91
|
+
JS_RestoreExceptionState(mJSContext, mState);
|
92
|
+
else
|
93
|
+
JS_ClearPendingException(mJSContext);
|
94
|
+
|
95
|
+
if(mContextHasThread)
|
96
|
+
JS_EndRequest(mJSContext);
|
97
|
+
|
98
|
+
// If this is a JSContext that has a private context that provides a
|
99
|
+
// nsIXPCScriptNotify interface, then notify the object the script has
|
100
|
+
// been executed.
|
101
|
+
//
|
102
|
+
// Note: We rely on the rule that if any JSContext in our JSRuntime has
|
103
|
+
// private data that points to an nsISupports subclass, it has also set
|
104
|
+
// the JSOPTION_PRIVATE_IS_NSISUPPORTS option.
|
105
|
+
|
106
|
+
if (JS_GetOptions(mJSContext) & JSOPTION_PRIVATE_IS_NSISUPPORTS)
|
107
|
+
{
|
108
|
+
nsCOMPtr<nsIXPCScriptNotify> scriptNotify =
|
109
|
+
do_QueryInterface(static_cast<nsISupports*>
|
110
|
+
(JS_GetContextPrivate(mJSContext)));
|
111
|
+
if(scriptNotify)
|
112
|
+
scriptNotify->ScriptExecuted();
|
113
|
+
}
|
114
|
+
|
115
|
+
if(mErrorReporterSet)
|
116
|
+
JS_SetErrorReporter(mJSContext, NULL);
|
117
|
+
}
|
118
|
+
|
119
|
+
// It turns out that some errors may be not worth reporting. So, this
|
120
|
+
// function is factored out to manage that.
|
121
|
+
JSBool xpc_IsReportableErrorCode(nsresult code)
|
122
|
+
{
|
123
|
+
if (NS_SUCCEEDED(code))
|
124
|
+
return JS_FALSE;
|
125
|
+
|
126
|
+
switch(code)
|
127
|
+
{
|
128
|
+
// Error codes that we don't want to report as errors...
|
129
|
+
// These generally indicate bad interface design AFAIC.
|
130
|
+
case NS_ERROR_FACTORY_REGISTER_AGAIN:
|
131
|
+
case NS_BASE_STREAM_WOULD_BLOCK:
|
132
|
+
return JS_FALSE;
|
133
|
+
}
|
134
|
+
|
135
|
+
return JS_TRUE;
|
136
|
+
}
|
137
|
+
|
138
|
+
// static
|
139
|
+
nsresult
|
140
|
+
nsXPCWrappedJSClass::GetNewOrUsed(XPCCallContext& ccx, REFNSIID aIID,
|
141
|
+
nsXPCWrappedJSClass** resultClazz)
|
142
|
+
{
|
143
|
+
nsXPCWrappedJSClass* clazz = nsnull;
|
144
|
+
XPCJSRuntime* rt = ccx.GetRuntime();
|
145
|
+
|
146
|
+
{ // scoped lock
|
147
|
+
XPCAutoLock lock(rt->GetMapLock());
|
148
|
+
IID2WrappedJSClassMap* map = rt->GetWrappedJSClassMap();
|
149
|
+
clazz = map->Find(aIID);
|
150
|
+
NS_IF_ADDREF(clazz);
|
151
|
+
}
|
152
|
+
|
153
|
+
if(!clazz)
|
154
|
+
{
|
155
|
+
nsCOMPtr<nsIInterfaceInfo> info;
|
156
|
+
ccx.GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
157
|
+
if(info)
|
158
|
+
{
|
159
|
+
PRBool canScript;
|
160
|
+
if(NS_SUCCEEDED(info->IsScriptable(&canScript)) && canScript &&
|
161
|
+
nsXPConnect::IsISupportsDescendant(info))
|
162
|
+
{
|
163
|
+
clazz = new nsXPCWrappedJSClass(ccx, aIID, info);
|
164
|
+
if(clazz && !clazz->mDescriptors)
|
165
|
+
NS_RELEASE(clazz); // sets clazz to nsnull
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
*resultClazz = clazz;
|
170
|
+
return NS_OK;
|
171
|
+
}
|
172
|
+
|
173
|
+
nsXPCWrappedJSClass::nsXPCWrappedJSClass(XPCCallContext& ccx, REFNSIID aIID,
|
174
|
+
nsIInterfaceInfo* aInfo)
|
175
|
+
: mRuntime(ccx.GetRuntime()),
|
176
|
+
mInfo(aInfo),
|
177
|
+
mName(nsnull),
|
178
|
+
mIID(aIID),
|
179
|
+
mDescriptors(nsnull)
|
180
|
+
{
|
181
|
+
NS_ADDREF(mInfo);
|
182
|
+
NS_ADDREF_THIS();
|
183
|
+
|
184
|
+
{ // scoped lock
|
185
|
+
XPCAutoLock lock(mRuntime->GetMapLock());
|
186
|
+
mRuntime->GetWrappedJSClassMap()->Add(this);
|
187
|
+
}
|
188
|
+
|
189
|
+
uint16 methodCount;
|
190
|
+
if(NS_SUCCEEDED(mInfo->GetMethodCount(&methodCount)))
|
191
|
+
{
|
192
|
+
if(methodCount)
|
193
|
+
{
|
194
|
+
int wordCount = (methodCount/32)+1;
|
195
|
+
if(nsnull != (mDescriptors = new uint32[wordCount]))
|
196
|
+
{
|
197
|
+
int i;
|
198
|
+
// init flags to 0;
|
199
|
+
for(i = wordCount-1; i >= 0; i--)
|
200
|
+
mDescriptors[i] = 0;
|
201
|
+
|
202
|
+
for(i = 0; i < methodCount; i++)
|
203
|
+
{
|
204
|
+
const nsXPTMethodInfo* info;
|
205
|
+
if(NS_SUCCEEDED(mInfo->GetMethodInfo(i, &info)))
|
206
|
+
SetReflectable(i, XPCConvert::IsMethodReflectable(*info));
|
207
|
+
else
|
208
|
+
{
|
209
|
+
delete [] mDescriptors;
|
210
|
+
mDescriptors = nsnull;
|
211
|
+
break;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}
|
216
|
+
else
|
217
|
+
{
|
218
|
+
mDescriptors = &zero_methods_descriptor;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
nsXPCWrappedJSClass::~nsXPCWrappedJSClass()
|
224
|
+
{
|
225
|
+
if(mDescriptors && mDescriptors != &zero_methods_descriptor)
|
226
|
+
delete [] mDescriptors;
|
227
|
+
if(mRuntime)
|
228
|
+
{ // scoped lock
|
229
|
+
XPCAutoLock lock(mRuntime->GetMapLock());
|
230
|
+
mRuntime->GetWrappedJSClassMap()->Remove(this);
|
231
|
+
}
|
232
|
+
if(mName)
|
233
|
+
nsMemory::Free(mName);
|
234
|
+
NS_IF_RELEASE(mInfo);
|
235
|
+
}
|
236
|
+
|
237
|
+
JSObject*
|
238
|
+
nsXPCWrappedJSClass::CallQueryInterfaceOnJSObject(XPCCallContext& ccx,
|
239
|
+
JSObject* jsobj,
|
240
|
+
REFNSIID aIID)
|
241
|
+
{
|
242
|
+
JSContext* cx = ccx.GetJSContext();
|
243
|
+
JSObject* id;
|
244
|
+
jsval retval;
|
245
|
+
JSObject* retObj;
|
246
|
+
JSBool success = JS_FALSE;
|
247
|
+
jsid funid;
|
248
|
+
jsval fun;
|
249
|
+
|
250
|
+
// check upfront for the existence of the function property
|
251
|
+
funid = mRuntime->GetStringID(XPCJSRuntime::IDX_QUERY_INTERFACE);
|
252
|
+
if(!JS_GetPropertyById(cx, jsobj, funid, &fun) || JSVAL_IS_PRIMITIVE(fun))
|
253
|
+
return nsnull;
|
254
|
+
|
255
|
+
// protect fun so that we're sure it's alive when we call it
|
256
|
+
AUTO_MARK_JSVAL(ccx, fun);
|
257
|
+
|
258
|
+
// Ensure that we are asking for a scriptable interface.
|
259
|
+
// NB: It's important for security that this check is here rather
|
260
|
+
// than later, since it prevents untrusted objects from implementing
|
261
|
+
// some interfaces in JS and aggregating a trusted object to
|
262
|
+
// implement intentionally (for security) unscriptable interfaces.
|
263
|
+
// We so often ask for nsISupports that we can short-circuit the test...
|
264
|
+
if(!aIID.Equals(NS_GET_IID(nsISupports)))
|
265
|
+
{
|
266
|
+
nsCOMPtr<nsIInterfaceInfo> info;
|
267
|
+
ccx.GetXPConnect()->GetInfoForIID(&aIID, getter_AddRefs(info));
|
268
|
+
if(!info)
|
269
|
+
return nsnull;
|
270
|
+
PRBool canScript;
|
271
|
+
if(NS_FAILED(info->IsScriptable(&canScript)) || !canScript)
|
272
|
+
return nsnull;
|
273
|
+
}
|
274
|
+
|
275
|
+
// OK, it looks like we'll be calling into JS code.
|
276
|
+
|
277
|
+
AutoScriptEvaluate scriptEval(cx);
|
278
|
+
|
279
|
+
// XXX we should install an error reporter that will send reports to
|
280
|
+
// the JS error console service.
|
281
|
+
scriptEval.StartEvaluating();
|
282
|
+
|
283
|
+
id = xpc_NewIDObject(cx, jsobj, aIID);
|
284
|
+
if(id)
|
285
|
+
{
|
286
|
+
// Throwing NS_NOINTERFACE is the prescribed way to fail QI from JS. It
|
287
|
+
// is not an exception that is ever worth reporting, but we don't want
|
288
|
+
// to eat all exceptions either.
|
289
|
+
|
290
|
+
uint32 oldOpts =
|
291
|
+
JS_SetOptions(cx, JS_GetOptions(cx) | JSOPTION_DONT_REPORT_UNCAUGHT);
|
292
|
+
|
293
|
+
jsval args[1] = {OBJECT_TO_JSVAL(id)};
|
294
|
+
success = JS_CallFunctionValue(cx, jsobj, fun, 1, args, &retval);
|
295
|
+
|
296
|
+
JS_SetOptions(cx, oldOpts);
|
297
|
+
|
298
|
+
if(!success)
|
299
|
+
{
|
300
|
+
NS_ASSERTION(JS_IsExceptionPending(cx),
|
301
|
+
"JS failed without setting an exception!");
|
302
|
+
|
303
|
+
jsval jsexception = JSVAL_NULL;
|
304
|
+
AUTO_MARK_JSVAL(ccx, &jsexception);
|
305
|
+
|
306
|
+
if(JS_GetPendingException(cx, &jsexception))
|
307
|
+
{
|
308
|
+
nsresult rv;
|
309
|
+
if(JSVAL_IS_OBJECT(jsexception))
|
310
|
+
{
|
311
|
+
// XPConnect may have constructed an object to represent a
|
312
|
+
// C++ QI failure. See if that is the case.
|
313
|
+
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
|
314
|
+
|
315
|
+
nsXPConnect::GetXPConnect()->
|
316
|
+
GetWrappedNativeOfJSObject(ccx,
|
317
|
+
JSVAL_TO_OBJECT(jsexception),
|
318
|
+
getter_AddRefs(wrapper));
|
319
|
+
|
320
|
+
if(wrapper)
|
321
|
+
{
|
322
|
+
nsCOMPtr<nsIException> exception =
|
323
|
+
do_QueryWrappedNative(wrapper);
|
324
|
+
if(exception &&
|
325
|
+
NS_SUCCEEDED(exception->GetResult(&rv)) &&
|
326
|
+
rv == NS_NOINTERFACE)
|
327
|
+
{
|
328
|
+
JS_ClearPendingException(cx);
|
329
|
+
}
|
330
|
+
}
|
331
|
+
}
|
332
|
+
else if(JSVAL_IS_NUMBER(jsexception))
|
333
|
+
{
|
334
|
+
// JS often throws an nsresult.
|
335
|
+
if(JSVAL_IS_DOUBLE(jsexception))
|
336
|
+
rv = (nsresult)(*JSVAL_TO_DOUBLE(jsexception));
|
337
|
+
else
|
338
|
+
rv = (nsresult)(JSVAL_TO_INT(jsexception));
|
339
|
+
|
340
|
+
if(rv == NS_NOINTERFACE)
|
341
|
+
JS_ClearPendingException(cx);
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
// Don't report if reporting was disabled by someone else.
|
346
|
+
if(!(oldOpts & JSOPTION_DONT_REPORT_UNCAUGHT))
|
347
|
+
JS_ReportPendingException(cx);
|
348
|
+
}
|
349
|
+
}
|
350
|
+
|
351
|
+
if(success)
|
352
|
+
success = JS_ValueToObject(cx, retval, &retObj);
|
353
|
+
|
354
|
+
return success ? retObj : nsnull;
|
355
|
+
}
|
356
|
+
|
357
|
+
/***************************************************************************/
|
358
|
+
|
359
|
+
static JSBool
|
360
|
+
GetNamedPropertyAsVariantRaw(XPCCallContext& ccx,
|
361
|
+
JSObject* aJSObj,
|
362
|
+
jsid aName,
|
363
|
+
nsIVariant** aResult,
|
364
|
+
nsresult* pErr)
|
365
|
+
{
|
366
|
+
nsXPTType type = nsXPTType((uint8)(TD_INTERFACE_TYPE | XPT_TDP_POINTER));
|
367
|
+
jsval val;
|
368
|
+
|
369
|
+
return JS_GetPropertyById(ccx, aJSObj, aName, &val) &&
|
370
|
+
XPCConvert::JSData2Native(ccx, aResult, val, type, JS_FALSE,
|
371
|
+
&NS_GET_IID(nsIVariant), pErr);
|
372
|
+
}
|
373
|
+
|
374
|
+
// static
|
375
|
+
nsresult
|
376
|
+
nsXPCWrappedJSClass::GetNamedPropertyAsVariant(XPCCallContext& ccx,
|
377
|
+
JSObject* aJSObj,
|
378
|
+
jsval aName,
|
379
|
+
nsIVariant** aResult)
|
380
|
+
{
|
381
|
+
JSContext* cx = ccx.GetJSContext();
|
382
|
+
JSBool ok;
|
383
|
+
jsid id;
|
384
|
+
nsresult rv = NS_ERROR_FAILURE;
|
385
|
+
|
386
|
+
AutoScriptEvaluate scriptEval(cx);
|
387
|
+
scriptEval.StartEvaluating();
|
388
|
+
|
389
|
+
ok = JS_ValueToId(cx, aName, &id) &&
|
390
|
+
GetNamedPropertyAsVariantRaw(ccx, aJSObj, id, aResult, &rv);
|
391
|
+
|
392
|
+
return ok ? NS_OK : NS_FAILED(rv) ? rv : NS_ERROR_FAILURE;
|
393
|
+
}
|
394
|
+
|
395
|
+
/***************************************************************************/
|
396
|
+
|
397
|
+
// static
|
398
|
+
nsresult
|
399
|
+
nsXPCWrappedJSClass::BuildPropertyEnumerator(XPCCallContext& ccx,
|
400
|
+
JSObject* aJSObj,
|
401
|
+
nsISimpleEnumerator** aEnumerate)
|
402
|
+
{
|
403
|
+
JSContext* cx = ccx.GetJSContext();
|
404
|
+
nsresult retval = NS_ERROR_FAILURE;
|
405
|
+
JSIdArray* idArray = nsnull;
|
406
|
+
xpcPropertyBagEnumerator* enumerator = nsnull;
|
407
|
+
int i;
|
408
|
+
|
409
|
+
// Saved state must be restored, all exits through 'out'...
|
410
|
+
AutoScriptEvaluate scriptEval(cx);
|
411
|
+
scriptEval.StartEvaluating();
|
412
|
+
|
413
|
+
idArray = JS_Enumerate(cx, aJSObj);
|
414
|
+
if(!idArray)
|
415
|
+
goto out;
|
416
|
+
|
417
|
+
enumerator = new xpcPropertyBagEnumerator(idArray->length);
|
418
|
+
if(!enumerator)
|
419
|
+
goto out;
|
420
|
+
NS_ADDREF(enumerator);
|
421
|
+
|
422
|
+
for(i = 0; i < idArray->length; i++)
|
423
|
+
{
|
424
|
+
nsCOMPtr<nsIVariant> value;
|
425
|
+
jsid idName = idArray->vector[i];
|
426
|
+
nsresult rv;
|
427
|
+
|
428
|
+
if(!GetNamedPropertyAsVariantRaw(ccx, aJSObj, idName,
|
429
|
+
getter_AddRefs(value), &rv))
|
430
|
+
{
|
431
|
+
if(NS_FAILED(rv))
|
432
|
+
retval = rv;
|
433
|
+
goto out;
|
434
|
+
}
|
435
|
+
|
436
|
+
jsval jsvalName;
|
437
|
+
if(!JS_IdToValue(cx, idName, &jsvalName))
|
438
|
+
goto out;
|
439
|
+
|
440
|
+
JSString* name = JS_ValueToString(cx, jsvalName);
|
441
|
+
if(!name)
|
442
|
+
goto out;
|
443
|
+
|
444
|
+
nsCOMPtr<nsIProperty> property =
|
445
|
+
new xpcProperty((const PRUnichar*) JS_GetStringChars(name),
|
446
|
+
(PRUint32) JS_GetStringLength(name),
|
447
|
+
value);
|
448
|
+
if(!property)
|
449
|
+
goto out;
|
450
|
+
|
451
|
+
if(!enumerator->AppendElement(property))
|
452
|
+
goto out;
|
453
|
+
}
|
454
|
+
|
455
|
+
NS_ADDREF(*aEnumerate = enumerator);
|
456
|
+
retval = NS_OK;
|
457
|
+
|
458
|
+
out:
|
459
|
+
NS_IF_RELEASE(enumerator);
|
460
|
+
if(idArray)
|
461
|
+
JS_DestroyIdArray(cx, idArray);
|
462
|
+
|
463
|
+
return retval;
|
464
|
+
}
|
465
|
+
|
466
|
+
/***************************************************************************/
|
467
|
+
|
468
|
+
NS_IMPL_ISUPPORTS1(xpcProperty, nsIProperty)
|
469
|
+
|
470
|
+
xpcProperty::xpcProperty(const PRUnichar* aName, PRUint32 aNameLen,
|
471
|
+
nsIVariant* aValue)
|
472
|
+
: mName(aName, aNameLen), mValue(aValue)
|
473
|
+
{
|
474
|
+
}
|
475
|
+
|
476
|
+
/* readonly attribute AString name; */
|
477
|
+
NS_IMETHODIMP xpcProperty::GetName(nsAString & aName)
|
478
|
+
{
|
479
|
+
aName.Assign(mName);
|
480
|
+
return NS_OK;
|
481
|
+
}
|
482
|
+
|
483
|
+
/* readonly attribute nsIVariant value; */
|
484
|
+
NS_IMETHODIMP xpcProperty::GetValue(nsIVariant * *aValue)
|
485
|
+
{
|
486
|
+
NS_ADDREF(*aValue = mValue);
|
487
|
+
return NS_OK;
|
488
|
+
}
|
489
|
+
|
490
|
+
/***************************************************************************/
|
491
|
+
|
492
|
+
NS_IMPL_ISUPPORTS1(xpcPropertyBagEnumerator, nsISimpleEnumerator)
|
493
|
+
|
494
|
+
xpcPropertyBagEnumerator::xpcPropertyBagEnumerator(PRUint32 count)
|
495
|
+
: mIndex(0), mCount(0)
|
496
|
+
{
|
497
|
+
mArray.SizeTo(count);
|
498
|
+
}
|
499
|
+
|
500
|
+
JSBool xpcPropertyBagEnumerator::AppendElement(nsISupports* element)
|
501
|
+
{
|
502
|
+
if(!mArray.AppendElement(element))
|
503
|
+
return JS_FALSE;
|
504
|
+
mCount++;
|
505
|
+
return JS_TRUE;
|
506
|
+
}
|
507
|
+
|
508
|
+
/* boolean hasMoreElements (); */
|
509
|
+
NS_IMETHODIMP xpcPropertyBagEnumerator::HasMoreElements(PRBool *_retval)
|
510
|
+
{
|
511
|
+
*_retval = mIndex < mCount;
|
512
|
+
return NS_OK;
|
513
|
+
}
|
514
|
+
|
515
|
+
/* nsISupports getNext (); */
|
516
|
+
NS_IMETHODIMP xpcPropertyBagEnumerator::GetNext(nsISupports **_retval)
|
517
|
+
{
|
518
|
+
if(!(mIndex < mCount))
|
519
|
+
{
|
520
|
+
NS_ERROR("Bad nsISimpleEnumerator caller!");
|
521
|
+
return NS_ERROR_FAILURE;
|
522
|
+
}
|
523
|
+
|
524
|
+
*_retval = mArray.ElementAt(mIndex++);
|
525
|
+
return *_retval ? NS_OK : NS_ERROR_FAILURE;
|
526
|
+
}
|
527
|
+
|
528
|
+
/***************************************************************************/
|
529
|
+
// This 'WrappedJSIdentity' class and singleton allow us to figure out if
|
530
|
+
// any given nsISupports* is implemented by a WrappedJS object. This is done
|
531
|
+
// using a QueryInterface call on the interface pointer with our ID. If
|
532
|
+
// that call returns NS_OK and the pointer is to our singleton, then the
|
533
|
+
// interface must be implemented by a WrappedJS object. NOTE: the
|
534
|
+
// 'WrappedJSIdentity' object is not a real XPCOM object and should not be
|
535
|
+
// used for anything else (hence it is declared in this implementation file).
|
536
|
+
|
537
|
+
// {5C5C3BB0-A9BA-11d2-BA64-00805F8A5DD7}
|
538
|
+
#define NS_IXPCONNECT_WRAPPED_JS_IDENTITY_CLASS_IID \
|
539
|
+
{ 0x5c5c3bb0, 0xa9ba, 0x11d2, \
|
540
|
+
{ 0xba, 0x64, 0x0, 0x80, 0x5f, 0x8a, 0x5d, 0xd7 } }
|
541
|
+
|
542
|
+
class WrappedJSIdentity
|
543
|
+
{
|
544
|
+
// no instance methods...
|
545
|
+
public:
|
546
|
+
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IXPCONNECT_WRAPPED_JS_IDENTITY_CLASS_IID)
|
547
|
+
|
548
|
+
static void* GetSingleton()
|
549
|
+
{
|
550
|
+
static WrappedJSIdentity* singleton = nsnull;
|
551
|
+
if(!singleton)
|
552
|
+
singleton = new WrappedJSIdentity();
|
553
|
+
return (void*) singleton;
|
554
|
+
}
|
555
|
+
};
|
556
|
+
|
557
|
+
NS_DEFINE_STATIC_IID_ACCESSOR(WrappedJSIdentity,
|
558
|
+
NS_IXPCONNECT_WRAPPED_JS_IDENTITY_CLASS_IID)
|
559
|
+
|
560
|
+
/***************************************************************************/
|
561
|
+
|
562
|
+
// static
|
563
|
+
JSBool
|
564
|
+
nsXPCWrappedJSClass::IsWrappedJS(nsISupports* aPtr)
|
565
|
+
{
|
566
|
+
void* result;
|
567
|
+
NS_PRECONDITION(aPtr, "null pointer");
|
568
|
+
return aPtr &&
|
569
|
+
NS_OK == aPtr->QueryInterface(NS_GET_IID(WrappedJSIdentity), &result) &&
|
570
|
+
result == WrappedJSIdentity::GetSingleton();
|
571
|
+
}
|
572
|
+
|
573
|
+
static JSContext *
|
574
|
+
GetContextFromObject(JSObject *obj)
|
575
|
+
{
|
576
|
+
// Don't stomp over a running context.
|
577
|
+
XPCJSContextStack* stack =
|
578
|
+
XPCPerThreadData::GetData(nsnull)->GetJSContextStack();
|
579
|
+
JSContext* topJSContext;
|
580
|
+
|
581
|
+
if(stack && NS_SUCCEEDED(stack->Peek(&topJSContext)) && topJSContext)
|
582
|
+
return nsnull;
|
583
|
+
|
584
|
+
// In order to get a context, we need a context.
|
585
|
+
XPCCallContext ccx(NATIVE_CALLER);
|
586
|
+
if(!ccx.IsValid())
|
587
|
+
return nsnull;
|
588
|
+
XPCWrappedNativeScope* scope =
|
589
|
+
XPCWrappedNativeScope::FindInJSObjectScope(ccx, obj);
|
590
|
+
XPCContext *xpcc = scope->GetContext();
|
591
|
+
|
592
|
+
if(xpcc)
|
593
|
+
{
|
594
|
+
JSContext *cx = xpcc->GetJSContext();
|
595
|
+
if(cx->thread->id == js_CurrentThreadId())
|
596
|
+
return cx;
|
597
|
+
}
|
598
|
+
|
599
|
+
return nsnull;
|
600
|
+
}
|
601
|
+
|
602
|
+
#ifndef XPCONNECT_STANDALONE
|
603
|
+
class SameOriginCheckedComponent : public nsISecurityCheckedComponent
|
604
|
+
{
|
605
|
+
public:
|
606
|
+
SameOriginCheckedComponent(nsXPCWrappedJS* delegate)
|
607
|
+
: mDelegate(delegate)
|
608
|
+
{}
|
609
|
+
|
610
|
+
NS_DECL_ISUPPORTS
|
611
|
+
NS_DECL_NSISECURITYCHECKEDCOMPONENT
|
612
|
+
|
613
|
+
private:
|
614
|
+
nsRefPtr<nsXPCWrappedJS> mDelegate;
|
615
|
+
};
|
616
|
+
|
617
|
+
NS_IMPL_ADDREF(SameOriginCheckedComponent)
|
618
|
+
NS_IMPL_RELEASE(SameOriginCheckedComponent)
|
619
|
+
|
620
|
+
NS_INTERFACE_MAP_BEGIN(SameOriginCheckedComponent)
|
621
|
+
NS_INTERFACE_MAP_ENTRY(nsISecurityCheckedComponent)
|
622
|
+
NS_INTERFACE_MAP_END_AGGREGATED(mDelegate)
|
623
|
+
|
624
|
+
NS_IMETHODIMP
|
625
|
+
SameOriginCheckedComponent::CanCreateWrapper(const nsIID * iid,
|
626
|
+
char **_retval NS_OUTPARAM)
|
627
|
+
{
|
628
|
+
// XXX This doesn't actually work because nsScriptSecurityManager doesn't
|
629
|
+
// know what to do with "sameOrigin" for canCreateWrapper.
|
630
|
+
*_retval = NS_strdup("sameOrigin");
|
631
|
+
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
632
|
+
}
|
633
|
+
|
634
|
+
NS_IMETHODIMP
|
635
|
+
SameOriginCheckedComponent::CanCallMethod(const nsIID * iid,
|
636
|
+
const PRUnichar *methodName,
|
637
|
+
char **_retval NS_OUTPARAM)
|
638
|
+
{
|
639
|
+
*_retval = NS_strdup("sameOrigin");
|
640
|
+
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
641
|
+
}
|
642
|
+
|
643
|
+
NS_IMETHODIMP
|
644
|
+
SameOriginCheckedComponent::CanGetProperty(const nsIID * iid,
|
645
|
+
const PRUnichar *propertyName,
|
646
|
+
char **_retval NS_OUTPARAM)
|
647
|
+
{
|
648
|
+
*_retval = NS_strdup("sameOrigin");
|
649
|
+
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
650
|
+
}
|
651
|
+
|
652
|
+
NS_IMETHODIMP
|
653
|
+
SameOriginCheckedComponent::CanSetProperty(const nsIID * iid,
|
654
|
+
const PRUnichar *propertyName,
|
655
|
+
char **_retval NS_OUTPARAM)
|
656
|
+
{
|
657
|
+
*_retval = NS_strdup("sameOrigin");
|
658
|
+
return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
659
|
+
}
|
660
|
+
|
661
|
+
#endif
|
662
|
+
|
663
|
+
NS_IMETHODIMP
|
664
|
+
nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
665
|
+
REFNSIID aIID,
|
666
|
+
void** aInstancePtr)
|
667
|
+
{
|
668
|
+
if(aIID.Equals(NS_GET_IID(nsIXPConnectJSObjectHolder)))
|
669
|
+
{
|
670
|
+
NS_ADDREF(self);
|
671
|
+
*aInstancePtr = (void*) static_cast<nsIXPConnectJSObjectHolder*>(self);
|
672
|
+
return NS_OK;
|
673
|
+
}
|
674
|
+
|
675
|
+
// Objects internal to xpconnect are the only objects that even know *how*
|
676
|
+
// to ask for this iid. And none of them bother refcounting the thing.
|
677
|
+
if(aIID.Equals(NS_GET_IID(WrappedJSIdentity)))
|
678
|
+
{
|
679
|
+
// asking to find out if this is a wrapper object
|
680
|
+
*aInstancePtr = WrappedJSIdentity::GetSingleton();
|
681
|
+
return NS_OK;
|
682
|
+
}
|
683
|
+
|
684
|
+
#ifdef XPC_IDISPATCH_SUPPORT
|
685
|
+
// If IDispatch is enabled and we're QI'ing to IDispatch
|
686
|
+
if(nsXPConnect::IsIDispatchEnabled() && aIID.Equals(NSID_IDISPATCH))
|
687
|
+
{
|
688
|
+
return XPCIDispatchExtension::IDispatchQIWrappedJS(self, aInstancePtr);
|
689
|
+
}
|
690
|
+
#endif
|
691
|
+
if(aIID.Equals(NS_GET_IID(nsIPropertyBag)))
|
692
|
+
{
|
693
|
+
// We only want to expose one implementation from our aggregate.
|
694
|
+
nsXPCWrappedJS* root = self->GetRootWrapper();
|
695
|
+
|
696
|
+
if(!root->IsValid())
|
697
|
+
{
|
698
|
+
*aInstancePtr = nsnull;
|
699
|
+
return NS_NOINTERFACE;
|
700
|
+
}
|
701
|
+
|
702
|
+
NS_ADDREF(root);
|
703
|
+
*aInstancePtr = (void*) static_cast<nsIPropertyBag*>(root);
|
704
|
+
return NS_OK;
|
705
|
+
}
|
706
|
+
|
707
|
+
// We can't have a cached wrapper.
|
708
|
+
if(aIID.Equals(NS_GET_IID(nsWrapperCache)))
|
709
|
+
{
|
710
|
+
*aInstancePtr = nsnull;
|
711
|
+
return NS_NOINTERFACE;
|
712
|
+
}
|
713
|
+
|
714
|
+
JSContext *context = GetContextFromObject(self->GetJSObject());
|
715
|
+
XPCCallContext ccx(NATIVE_CALLER, context);
|
716
|
+
if(!ccx.IsValid())
|
717
|
+
{
|
718
|
+
*aInstancePtr = nsnull;
|
719
|
+
return NS_NOINTERFACE;
|
720
|
+
}
|
721
|
+
|
722
|
+
// We support nsISupportsWeakReference iff the root wrapped JSObject
|
723
|
+
// claims to support it in its QueryInterface implementation.
|
724
|
+
if(aIID.Equals(NS_GET_IID(nsISupportsWeakReference)))
|
725
|
+
{
|
726
|
+
// We only want to expose one implementation from our aggregate.
|
727
|
+
nsXPCWrappedJS* root = self->GetRootWrapper();
|
728
|
+
|
729
|
+
// Fail if JSObject doesn't claim support for nsISupportsWeakReference
|
730
|
+
if(!root->IsValid() ||
|
731
|
+
!CallQueryInterfaceOnJSObject(ccx, root->GetJSObject(), aIID))
|
732
|
+
{
|
733
|
+
*aInstancePtr = nsnull;
|
734
|
+
return NS_NOINTERFACE;
|
735
|
+
}
|
736
|
+
|
737
|
+
NS_ADDREF(root);
|
738
|
+
*aInstancePtr = (void*) static_cast<nsISupportsWeakReference*>(root);
|
739
|
+
return NS_OK;
|
740
|
+
}
|
741
|
+
|
742
|
+
nsXPCWrappedJS* sibling;
|
743
|
+
|
744
|
+
// Checks for any existing wrapper explicitly constructed for this iid.
|
745
|
+
// This includes the current 'self' wrapper. This also deals with the
|
746
|
+
// nsISupports case (for which it returns mRoot).
|
747
|
+
if(nsnull != (sibling = self->Find(aIID)))
|
748
|
+
{
|
749
|
+
NS_ADDREF(sibling);
|
750
|
+
*aInstancePtr = sibling->GetXPTCStub();
|
751
|
+
return NS_OK;
|
752
|
+
}
|
753
|
+
|
754
|
+
// Check if asking for an interface from which one of our wrappers inherits.
|
755
|
+
if(nsnull != (sibling = self->FindInherited(aIID)))
|
756
|
+
{
|
757
|
+
NS_ADDREF(sibling);
|
758
|
+
*aInstancePtr = sibling->GetXPTCStub();
|
759
|
+
return NS_OK;
|
760
|
+
}
|
761
|
+
|
762
|
+
// else we do the more expensive stuff...
|
763
|
+
|
764
|
+
#ifndef XPCONNECT_STANDALONE
|
765
|
+
// Before calling out, ensure that we're not about to claim to implement
|
766
|
+
// nsISecurityCheckedComponent for an untrusted object. Doing so causes
|
767
|
+
// problems. See bug 352882.
|
768
|
+
// But if this is a content object, then we might be wrapping it for
|
769
|
+
// content. If our JS object isn't a double-wrapped object (that is, we
|
770
|
+
// don't have XPCWrappedJS(XPCWrappedNative(some C++ object))), then it
|
771
|
+
// definitely will not have classinfo (and therefore won't be a DOM
|
772
|
+
// object). Since content wants to be able to use these objects (directly
|
773
|
+
// or indirectly, see bug 483672), we implement nsISecurityCheckedComponent
|
774
|
+
// for them and tell caps that they are also bound by the same origin
|
775
|
+
// model.
|
776
|
+
|
777
|
+
if(aIID.Equals(NS_GET_IID(nsISecurityCheckedComponent)))
|
778
|
+
{
|
779
|
+
// XXX This code checks to see if the given object has chrome (also
|
780
|
+
// known as system) principals. It really wants to do a
|
781
|
+
// UniversalXPConnect type check.
|
782
|
+
|
783
|
+
*aInstancePtr = nsnull;
|
784
|
+
|
785
|
+
if(!XPCPerThreadData::IsMainThread(ccx.GetJSContext()))
|
786
|
+
return NS_NOINTERFACE;
|
787
|
+
|
788
|
+
nsXPConnect *xpc = nsXPConnect::GetXPConnect();
|
789
|
+
nsCOMPtr<nsIScriptSecurityManager> secMan =
|
790
|
+
do_QueryInterface(xpc->GetDefaultSecurityManager());
|
791
|
+
if(!secMan)
|
792
|
+
return NS_NOINTERFACE;
|
793
|
+
|
794
|
+
JSObject *selfObj = self->GetJSObject();
|
795
|
+
nsCOMPtr<nsIPrincipal> objPrin;
|
796
|
+
nsresult rv = secMan->GetObjectPrincipal(ccx, selfObj,
|
797
|
+
getter_AddRefs(objPrin));
|
798
|
+
if(NS_FAILED(rv))
|
799
|
+
return rv;
|
800
|
+
|
801
|
+
PRBool isSystem;
|
802
|
+
rv = secMan->IsSystemPrincipal(objPrin, &isSystem);
|
803
|
+
if((NS_FAILED(rv) || !isSystem) &&
|
804
|
+
!IS_WRAPPER_CLASS(STOBJ_GET_CLASS(selfObj)))
|
805
|
+
{
|
806
|
+
// A content object.
|
807
|
+
nsRefPtr<SameOriginCheckedComponent> checked =
|
808
|
+
new SameOriginCheckedComponent(self);
|
809
|
+
if(!checked)
|
810
|
+
return NS_ERROR_OUT_OF_MEMORY;
|
811
|
+
*aInstancePtr = checked.forget().get();
|
812
|
+
return NS_OK;
|
813
|
+
}
|
814
|
+
}
|
815
|
+
#endif
|
816
|
+
|
817
|
+
// check if the JSObject claims to implement this interface
|
818
|
+
JSObject* jsobj = CallQueryInterfaceOnJSObject(ccx, self->GetJSObject(),
|
819
|
+
aIID);
|
820
|
+
if(jsobj)
|
821
|
+
{
|
822
|
+
// protect jsobj until it is actually attached
|
823
|
+
AUTO_MARK_JSVAL(ccx, OBJECT_TO_JSVAL(jsobj));
|
824
|
+
|
825
|
+
// We can't use XPConvert::JSObject2NativeInterface() here
|
826
|
+
// since that can find a XPCWrappedNative directly on the
|
827
|
+
// proto chain, and we don't want that here. We need to find
|
828
|
+
// the actual JS object that claimed it supports the interface
|
829
|
+
// we're looking for or we'll potentially bypass security
|
830
|
+
// checks etc by calling directly through to a native found on
|
831
|
+
// the prototype chain.
|
832
|
+
//
|
833
|
+
// Instead, simply do the nsXPCWrappedJS part of
|
834
|
+
// XPConvert::JSObject2NativeInterface() here to make sure we
|
835
|
+
// get a new (or used) nsXPCWrappedJS.
|
836
|
+
nsXPCWrappedJS* wrapper;
|
837
|
+
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(ccx, jsobj, aIID, nsnull,
|
838
|
+
&wrapper);
|
839
|
+
if(NS_SUCCEEDED(rv) && wrapper)
|
840
|
+
{
|
841
|
+
// We need to go through the QueryInterface logic to make
|
842
|
+
// this return the right thing for the various 'special'
|
843
|
+
// interfaces; e.g. nsIPropertyBag.
|
844
|
+
rv = wrapper->QueryInterface(aIID, aInstancePtr);
|
845
|
+
NS_RELEASE(wrapper);
|
846
|
+
return rv;
|
847
|
+
}
|
848
|
+
}
|
849
|
+
|
850
|
+
// else...
|
851
|
+
// no can do
|
852
|
+
*aInstancePtr = nsnull;
|
853
|
+
return NS_NOINTERFACE;
|
854
|
+
}
|
855
|
+
|
856
|
+
JSObject*
|
857
|
+
nsXPCWrappedJSClass::GetRootJSObject(XPCCallContext& ccx, JSObject* aJSObj)
|
858
|
+
{
|
859
|
+
JSObject* result = CallQueryInterfaceOnJSObject(ccx, aJSObj,
|
860
|
+
NS_GET_IID(nsISupports));
|
861
|
+
if(!result)
|
862
|
+
return aJSObj;
|
863
|
+
JSObject* inner = XPCWrapper::Unwrap(ccx, result);
|
864
|
+
if (inner)
|
865
|
+
return inner;
|
866
|
+
return result;
|
867
|
+
}
|
868
|
+
|
869
|
+
void
|
870
|
+
xpcWrappedJSErrorReporter(JSContext *cx, const char *message,
|
871
|
+
JSErrorReport *report)
|
872
|
+
{
|
873
|
+
if(report)
|
874
|
+
{
|
875
|
+
// If it is an exception report, then we can just deal with the
|
876
|
+
// exception later (if not caught in the JS code).
|
877
|
+
if(JSREPORT_IS_EXCEPTION(report->flags))
|
878
|
+
{
|
879
|
+
// XXX We have a problem with error reports from uncaught exceptions.
|
880
|
+
//
|
881
|
+
// http://bugzilla.mozilla.org/show_bug.cgi?id=66453
|
882
|
+
//
|
883
|
+
// The issue is...
|
884
|
+
//
|
885
|
+
// We can't assume that the exception will *stay* uncaught. So, if
|
886
|
+
// we build an nsIXPCException here and the underlying exception
|
887
|
+
// really is caught before our script is done running then we blow
|
888
|
+
// it by returning failure to our caller when the script didn't
|
889
|
+
// really fail. However, This report contains error location info
|
890
|
+
// that is no longer available after the script is done. So, if the
|
891
|
+
// exception really is not caught (and is a non-engine exception)
|
892
|
+
// then we've lost the oportunity to capture the script location
|
893
|
+
// info that we *could* have captured here.
|
894
|
+
//
|
895
|
+
// This is expecially an issue with nested evaluations.
|
896
|
+
//
|
897
|
+
// Perhaps we could capture an expception here and store it as
|
898
|
+
// 'provisional' and then later if there is a pending exception
|
899
|
+
// when the script is done then we could maybe compare that in some
|
900
|
+
// way with the 'provisional' one in which we captured location info.
|
901
|
+
// We would not want to assume that the one discovered here is the
|
902
|
+
// same one that is later detected. This could cause us to lie.
|
903
|
+
//
|
904
|
+
// The thing is. we do not currently store the right stuff to compare
|
905
|
+
// these two nsIXPCExceptions (triggered by the same exception jsval
|
906
|
+
// in the engine). Maybe we should store the jsval and compare that?
|
907
|
+
// Maybe without even rooting it since we will not dereference it.
|
908
|
+
// This is inexact, but maybe the right thing to do?
|
909
|
+
//
|
910
|
+
// if(report->errorNumber == JSMSG_UNCAUGHT_EXCEPTION)) ...
|
911
|
+
//
|
912
|
+
|
913
|
+
return;
|
914
|
+
}
|
915
|
+
|
916
|
+
if(JSREPORT_IS_WARNING(report->flags))
|
917
|
+
{
|
918
|
+
// XXX printf the warning (#ifdef DEBUG only!).
|
919
|
+
// XXX send the warning to the console service.
|
920
|
+
return;
|
921
|
+
}
|
922
|
+
}
|
923
|
+
|
924
|
+
XPCCallContext ccx(NATIVE_CALLER, cx);
|
925
|
+
if(!ccx.IsValid())
|
926
|
+
return;
|
927
|
+
|
928
|
+
nsCOMPtr<nsIException> e;
|
929
|
+
XPCConvert::JSErrorToXPCException(ccx, message, nsnull, nsnull, report,
|
930
|
+
getter_AddRefs(e));
|
931
|
+
if(e)
|
932
|
+
ccx.GetXPCContext()->SetException(e);
|
933
|
+
}
|
934
|
+
|
935
|
+
JSBool
|
936
|
+
nsXPCWrappedJSClass::GetArraySizeFromParam(JSContext* cx,
|
937
|
+
const XPTMethodDescriptor* method,
|
938
|
+
const nsXPTParamInfo& param,
|
939
|
+
uint16 methodIndex,
|
940
|
+
uint8 paramIndex,
|
941
|
+
SizeMode mode,
|
942
|
+
nsXPTCMiniVariant* nativeParams,
|
943
|
+
JSUint32* result)
|
944
|
+
{
|
945
|
+
uint8 argnum;
|
946
|
+
nsresult rv;
|
947
|
+
|
948
|
+
if(mode == GET_SIZE)
|
949
|
+
rv = mInfo->GetSizeIsArgNumberForParam(methodIndex, ¶m, 0, &argnum);
|
950
|
+
else
|
951
|
+
rv = mInfo->GetLengthIsArgNumberForParam(methodIndex, ¶m, 0, &argnum);
|
952
|
+
if(NS_FAILED(rv))
|
953
|
+
return JS_FALSE;
|
954
|
+
|
955
|
+
const nsXPTParamInfo& arg_param = method->params[argnum];
|
956
|
+
const nsXPTType& arg_type = arg_param.GetType();
|
957
|
+
|
958
|
+
// The xpidl compiler ensures this. We reaffirm it for safety.
|
959
|
+
if(arg_type.IsPointer() || arg_type.TagPart() != nsXPTType::T_U32)
|
960
|
+
return JS_FALSE;
|
961
|
+
|
962
|
+
if(arg_param.IsOut())
|
963
|
+
*result = *(JSUint32*)nativeParams[argnum].val.p;
|
964
|
+
else
|
965
|
+
*result = nativeParams[argnum].val.u32;
|
966
|
+
|
967
|
+
return JS_TRUE;
|
968
|
+
}
|
969
|
+
|
970
|
+
JSBool
|
971
|
+
nsXPCWrappedJSClass::GetInterfaceTypeFromParam(JSContext* cx,
|
972
|
+
const XPTMethodDescriptor* method,
|
973
|
+
const nsXPTParamInfo& param,
|
974
|
+
uint16 methodIndex,
|
975
|
+
const nsXPTType& type,
|
976
|
+
nsXPTCMiniVariant* nativeParams,
|
977
|
+
nsID* result)
|
978
|
+
{
|
979
|
+
uint8 type_tag = type.TagPart();
|
980
|
+
|
981
|
+
if(type_tag == nsXPTType::T_INTERFACE)
|
982
|
+
{
|
983
|
+
if(NS_SUCCEEDED(GetInterfaceInfo()->
|
984
|
+
GetIIDForParamNoAlloc(methodIndex, ¶m, result)))
|
985
|
+
{
|
986
|
+
return JS_TRUE;
|
987
|
+
}
|
988
|
+
}
|
989
|
+
else if(type_tag == nsXPTType::T_INTERFACE_IS)
|
990
|
+
{
|
991
|
+
uint8 argnum;
|
992
|
+
nsresult rv;
|
993
|
+
rv = mInfo->GetInterfaceIsArgNumberForParam(methodIndex,
|
994
|
+
¶m, &argnum);
|
995
|
+
if(NS_FAILED(rv))
|
996
|
+
return JS_FALSE;
|
997
|
+
|
998
|
+
const nsXPTParamInfo& arg_param = method->params[argnum];
|
999
|
+
const nsXPTType& arg_type = arg_param.GetType();
|
1000
|
+
if(arg_type.IsPointer() &&
|
1001
|
+
arg_type.TagPart() == nsXPTType::T_IID)
|
1002
|
+
{
|
1003
|
+
if(arg_param.IsOut())
|
1004
|
+
{
|
1005
|
+
nsID** p = (nsID**) nativeParams[argnum].val.p;
|
1006
|
+
if(!p || !*p)
|
1007
|
+
return JS_FALSE;
|
1008
|
+
*result = **p;
|
1009
|
+
}
|
1010
|
+
else
|
1011
|
+
{
|
1012
|
+
nsID* p = (nsID*) nativeParams[argnum].val.p;
|
1013
|
+
if(!p)
|
1014
|
+
return JS_FALSE;
|
1015
|
+
*result = *p;
|
1016
|
+
}
|
1017
|
+
return JS_TRUE;
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
return JS_FALSE;
|
1021
|
+
}
|
1022
|
+
|
1023
|
+
void
|
1024
|
+
nsXPCWrappedJSClass::CleanupPointerArray(const nsXPTType& datum_type,
|
1025
|
+
JSUint32 array_count,
|
1026
|
+
void** arrayp)
|
1027
|
+
{
|
1028
|
+
if(datum_type.IsInterfacePointer())
|
1029
|
+
{
|
1030
|
+
nsISupports** pp = (nsISupports**) arrayp;
|
1031
|
+
for(JSUint32 k = 0; k < array_count; k++)
|
1032
|
+
{
|
1033
|
+
nsISupports* p = pp[k];
|
1034
|
+
NS_IF_RELEASE(p);
|
1035
|
+
}
|
1036
|
+
}
|
1037
|
+
else
|
1038
|
+
{
|
1039
|
+
void** pp = (void**) arrayp;
|
1040
|
+
for(JSUint32 k = 0; k < array_count; k++)
|
1041
|
+
{
|
1042
|
+
void* p = pp[k];
|
1043
|
+
if(p) nsMemory::Free(p);
|
1044
|
+
}
|
1045
|
+
}
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
void
|
1049
|
+
nsXPCWrappedJSClass::CleanupPointerTypeObject(const nsXPTType& type,
|
1050
|
+
void** pp)
|
1051
|
+
{
|
1052
|
+
NS_ASSERTION(pp,"null pointer");
|
1053
|
+
if(type.IsInterfacePointer())
|
1054
|
+
{
|
1055
|
+
nsISupports* p = *((nsISupports**)pp);
|
1056
|
+
if(p) p->Release();
|
1057
|
+
}
|
1058
|
+
else
|
1059
|
+
{
|
1060
|
+
void* p = *((void**)pp);
|
1061
|
+
if(p) nsMemory::Free(p);
|
1062
|
+
}
|
1063
|
+
}
|
1064
|
+
|
1065
|
+
class AutoClearPendingException
|
1066
|
+
{
|
1067
|
+
public:
|
1068
|
+
AutoClearPendingException(JSContext *cx) : mCx(cx) { }
|
1069
|
+
~AutoClearPendingException() { JS_ClearPendingException(mCx); }
|
1070
|
+
private:
|
1071
|
+
JSContext* mCx;
|
1072
|
+
};
|
1073
|
+
|
1074
|
+
nsresult
|
1075
|
+
nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
1076
|
+
const char * aPropertyName,
|
1077
|
+
const char * anInterfaceName,
|
1078
|
+
PRBool aForceReport)
|
1079
|
+
{
|
1080
|
+
XPCContext * xpcc = ccx.GetXPCContext();
|
1081
|
+
JSContext * cx = ccx.GetJSContext();
|
1082
|
+
nsCOMPtr<nsIException> xpc_exception;
|
1083
|
+
/* this one would be set by our error reporter */
|
1084
|
+
|
1085
|
+
xpcc->GetException(getter_AddRefs(xpc_exception));
|
1086
|
+
if(xpc_exception)
|
1087
|
+
xpcc->SetException(nsnull);
|
1088
|
+
|
1089
|
+
// get this right away in case we do something below to cause JS code
|
1090
|
+
// to run on this JSContext
|
1091
|
+
nsresult pending_result = xpcc->GetPendingResult();
|
1092
|
+
|
1093
|
+
jsval js_exception;
|
1094
|
+
JSBool is_js_exception = JS_GetPendingException(cx, &js_exception);
|
1095
|
+
|
1096
|
+
/* JS might throw an expection whether the reporter was called or not */
|
1097
|
+
if(is_js_exception)
|
1098
|
+
{
|
1099
|
+
if(!xpc_exception)
|
1100
|
+
XPCConvert::JSValToXPCException(ccx, js_exception, anInterfaceName,
|
1101
|
+
aPropertyName,
|
1102
|
+
getter_AddRefs(xpc_exception));
|
1103
|
+
|
1104
|
+
/* cleanup and set failed even if we can't build an exception */
|
1105
|
+
if(!xpc_exception)
|
1106
|
+
{
|
1107
|
+
ccx.GetThreadData()->SetException(nsnull); // XXX necessary?
|
1108
|
+
}
|
1109
|
+
}
|
1110
|
+
|
1111
|
+
AutoClearPendingException acpe(cx);
|
1112
|
+
|
1113
|
+
if(xpc_exception)
|
1114
|
+
{
|
1115
|
+
nsresult e_result;
|
1116
|
+
if(NS_SUCCEEDED(xpc_exception->GetResult(&e_result)))
|
1117
|
+
{
|
1118
|
+
// Figure out whether or not we should report this exception.
|
1119
|
+
PRBool reportable = xpc_IsReportableErrorCode(e_result);
|
1120
|
+
if(reportable)
|
1121
|
+
{
|
1122
|
+
// Always want to report forced exceptions and XPConnect's own
|
1123
|
+
// errors.
|
1124
|
+
reportable = aForceReport ||
|
1125
|
+
NS_ERROR_GET_MODULE(e_result) == NS_ERROR_MODULE_XPCONNECT;
|
1126
|
+
|
1127
|
+
// See if an environment variable was set or someone has told us
|
1128
|
+
// that a user pref was set indicating that we should report all
|
1129
|
+
// exceptions.
|
1130
|
+
if(!reportable)
|
1131
|
+
reportable = nsXPConnect::ReportAllJSExceptions();
|
1132
|
+
|
1133
|
+
// Finally, check to see if this is the last JS frame on the
|
1134
|
+
// stack. If so then we always want to report it.
|
1135
|
+
if(!reportable)
|
1136
|
+
{
|
1137
|
+
PRBool onlyNativeStackFrames = PR_TRUE;
|
1138
|
+
JSStackFrame * fp = nsnull;
|
1139
|
+
while((fp = JS_FrameIterator(cx, &fp)))
|
1140
|
+
{
|
1141
|
+
if(!JS_IsNativeFrame(cx, fp))
|
1142
|
+
{
|
1143
|
+
onlyNativeStackFrames = PR_FALSE;
|
1144
|
+
break;
|
1145
|
+
}
|
1146
|
+
}
|
1147
|
+
reportable = onlyNativeStackFrames;
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
// Ugly special case for GetInterface. It's "special" in the
|
1151
|
+
// same way as QueryInterface in that a failure is not
|
1152
|
+
// exceptional and shouldn't be reported. We have to do this
|
1153
|
+
// check here instead of in xpcwrappedjs (like we do for QI) to
|
1154
|
+
// avoid adding extra code to all xpcwrappedjs objects.
|
1155
|
+
if(reportable && e_result == NS_ERROR_NO_INTERFACE &&
|
1156
|
+
!strcmp(anInterfaceName, "nsIInterfaceRequestor") &&
|
1157
|
+
!strcmp(aPropertyName, "getInterface"))
|
1158
|
+
{
|
1159
|
+
reportable = PR_FALSE;
|
1160
|
+
}
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
// Try to use the error reporter set on the context to handle this
|
1164
|
+
// error if it came from a JS exception.
|
1165
|
+
if(reportable && is_js_exception &&
|
1166
|
+
cx->errorReporter != xpcWrappedJSErrorReporter)
|
1167
|
+
{
|
1168
|
+
reportable = !JS_ReportPendingException(cx);
|
1169
|
+
}
|
1170
|
+
|
1171
|
+
if(reportable)
|
1172
|
+
{
|
1173
|
+
#ifdef DEBUG
|
1174
|
+
static const char line[] =
|
1175
|
+
"************************************************************\n";
|
1176
|
+
static const char preamble[] =
|
1177
|
+
"* Call to xpconnect wrapped JSObject produced this error: *\n";
|
1178
|
+
static const char cant_get_text[] =
|
1179
|
+
"FAILED TO GET TEXT FROM EXCEPTION\n";
|
1180
|
+
|
1181
|
+
fputs(line, stdout);
|
1182
|
+
fputs(preamble, stdout);
|
1183
|
+
char* text;
|
1184
|
+
if(NS_SUCCEEDED(xpc_exception->ToString(&text)) && text)
|
1185
|
+
{
|
1186
|
+
fputs(text, stdout);
|
1187
|
+
fputs("\n", stdout);
|
1188
|
+
nsMemory::Free(text);
|
1189
|
+
}
|
1190
|
+
else
|
1191
|
+
fputs(cant_get_text, stdout);
|
1192
|
+
fputs(line, stdout);
|
1193
|
+
#endif
|
1194
|
+
|
1195
|
+
// Log the exception to the JS Console, so that users can do
|
1196
|
+
// something with it.
|
1197
|
+
nsCOMPtr<nsIConsoleService> consoleService
|
1198
|
+
(do_GetService(XPC_CONSOLE_CONTRACTID));
|
1199
|
+
if(nsnull != consoleService)
|
1200
|
+
{
|
1201
|
+
nsresult rv;
|
1202
|
+
nsCOMPtr<nsIScriptError> scriptError;
|
1203
|
+
nsCOMPtr<nsISupports> errorData;
|
1204
|
+
rv = xpc_exception->GetData(getter_AddRefs(errorData));
|
1205
|
+
if(NS_SUCCEEDED(rv))
|
1206
|
+
scriptError = do_QueryInterface(errorData);
|
1207
|
+
|
1208
|
+
if(nsnull == scriptError)
|
1209
|
+
{
|
1210
|
+
// No luck getting one from the exception, so
|
1211
|
+
// try to cook one up.
|
1212
|
+
scriptError = do_CreateInstance(XPC_SCRIPT_ERROR_CONTRACTID);
|
1213
|
+
if(nsnull != scriptError)
|
1214
|
+
{
|
1215
|
+
char* exn_string;
|
1216
|
+
rv = xpc_exception->ToString(&exn_string);
|
1217
|
+
if(NS_SUCCEEDED(rv))
|
1218
|
+
{
|
1219
|
+
// use toString on the exception as the message
|
1220
|
+
nsAutoString newMessage;
|
1221
|
+
newMessage.AssignWithConversion(exn_string);
|
1222
|
+
nsMemory::Free((void *) exn_string);
|
1223
|
+
|
1224
|
+
// try to get filename, lineno from the first
|
1225
|
+
// stack frame location.
|
1226
|
+
PRInt32 lineNumber = 0;
|
1227
|
+
nsXPIDLCString sourceName;
|
1228
|
+
|
1229
|
+
nsCOMPtr<nsIStackFrame> location;
|
1230
|
+
xpc_exception->
|
1231
|
+
GetLocation(getter_AddRefs(location));
|
1232
|
+
if(location)
|
1233
|
+
{
|
1234
|
+
// Get line number w/o checking; 0 is ok.
|
1235
|
+
location->GetLineNumber(&lineNumber);
|
1236
|
+
|
1237
|
+
// get a filename.
|
1238
|
+
rv = location->GetFilename(getter_Copies(sourceName));
|
1239
|
+
}
|
1240
|
+
|
1241
|
+
rv = scriptError->Init(newMessage.get(),
|
1242
|
+
NS_ConvertASCIItoUTF16(sourceName).get(),
|
1243
|
+
nsnull,
|
1244
|
+
lineNumber, 0, 0,
|
1245
|
+
"XPConnect JavaScript");
|
1246
|
+
if(NS_FAILED(rv))
|
1247
|
+
scriptError = nsnull;
|
1248
|
+
}
|
1249
|
+
}
|
1250
|
+
}
|
1251
|
+
if(nsnull != scriptError)
|
1252
|
+
consoleService->LogMessage(scriptError);
|
1253
|
+
}
|
1254
|
+
}
|
1255
|
+
// Whether or not it passes the 'reportable' test, it might
|
1256
|
+
// still be an error and we have to do the right thing here...
|
1257
|
+
if(NS_FAILED(e_result))
|
1258
|
+
{
|
1259
|
+
ccx.GetThreadData()->SetException(xpc_exception);
|
1260
|
+
return e_result;
|
1261
|
+
}
|
1262
|
+
}
|
1263
|
+
}
|
1264
|
+
else
|
1265
|
+
{
|
1266
|
+
// see if JS code signaled failure result without throwing exception
|
1267
|
+
if(NS_FAILED(pending_result))
|
1268
|
+
{
|
1269
|
+
return pending_result;
|
1270
|
+
}
|
1271
|
+
}
|
1272
|
+
return NS_ERROR_FAILURE;
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
NS_IMETHODIMP
|
1276
|
+
nsXPCWrappedJSClass::CallMethod(nsXPCWrappedJS* wrapper, uint16 methodIndex,
|
1277
|
+
const XPTMethodDescriptor* info,
|
1278
|
+
nsXPTCMiniVariant* nativeParams)
|
1279
|
+
{
|
1280
|
+
jsval* stackbase = nsnull;
|
1281
|
+
jsval* sp = nsnull;
|
1282
|
+
uint8 i;
|
1283
|
+
uint8 argc=0;
|
1284
|
+
uint8 stack_size;
|
1285
|
+
jsval result;
|
1286
|
+
uint8 paramCount=0;
|
1287
|
+
nsresult retval = NS_ERROR_FAILURE;
|
1288
|
+
nsresult pending_result = NS_OK;
|
1289
|
+
JSBool success;
|
1290
|
+
JSBool readyToDoTheCall = JS_FALSE;
|
1291
|
+
nsID param_iid;
|
1292
|
+
uint8 outConversionFailedIndex;
|
1293
|
+
JSObject* obj;
|
1294
|
+
const char* name = info->name;
|
1295
|
+
jsval fval;
|
1296
|
+
void* mark;
|
1297
|
+
JSBool foundDependentParam;
|
1298
|
+
XPCContext* xpcc;
|
1299
|
+
JSContext* cx;
|
1300
|
+
JSObject* thisObj;
|
1301
|
+
|
1302
|
+
// Make sure not to set the callee on ccx until after we've gone through
|
1303
|
+
// the whole nsIXPCFunctionThisTranslator bit. That code uses ccx to
|
1304
|
+
// convert natives to JSObjects, but we do NOT plan to pass those JSObjects
|
1305
|
+
// to our real callee.
|
1306
|
+
JSContext *context = GetContextFromObject(wrapper->GetJSObject());
|
1307
|
+
XPCCallContext ccx(NATIVE_CALLER, context);
|
1308
|
+
if(ccx.IsValid())
|
1309
|
+
{
|
1310
|
+
xpcc = ccx.GetXPCContext();
|
1311
|
+
cx = ccx.GetJSContext();
|
1312
|
+
}
|
1313
|
+
else
|
1314
|
+
{
|
1315
|
+
xpcc = nsnull;
|
1316
|
+
cx = nsnull;
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
AutoScriptEvaluate scriptEval(cx);
|
1320
|
+
#ifdef DEBUG_stats_jband
|
1321
|
+
PRIntervalTime startTime = PR_IntervalNow();
|
1322
|
+
PRIntervalTime endTime = 0;
|
1323
|
+
static int totalTime = 0;
|
1324
|
+
|
1325
|
+
|
1326
|
+
static int count = 0;
|
1327
|
+
static const int interval = 10;
|
1328
|
+
if(0 == (++count % interval))
|
1329
|
+
printf("<<<<<<<< %d calls on nsXPCWrappedJSs made. (%d)\n", count, PR_IntervalToMilliseconds(totalTime));
|
1330
|
+
#endif
|
1331
|
+
|
1332
|
+
obj = thisObj = wrapper->GetJSObject();
|
1333
|
+
|
1334
|
+
// XXX ASSUMES that retval is last arg. The xpidl compiler ensures this.
|
1335
|
+
paramCount = info->num_args;
|
1336
|
+
argc = paramCount -
|
1337
|
+
(paramCount && XPT_PD_IS_RETVAL(info->params[paramCount-1].flags) ? 1 : 0);
|
1338
|
+
|
1339
|
+
if(!cx || !xpcc || !IsReflectable(methodIndex))
|
1340
|
+
goto pre_call_clean_up;
|
1341
|
+
|
1342
|
+
scriptEval.StartEvaluating(xpcWrappedJSErrorReporter);
|
1343
|
+
|
1344
|
+
xpcc->SetPendingResult(pending_result);
|
1345
|
+
xpcc->SetException(nsnull);
|
1346
|
+
ccx.GetThreadData()->SetException(nsnull);
|
1347
|
+
|
1348
|
+
// We use js_AllocStack, js_Invoke, and js_FreeStack so that the gcthings
|
1349
|
+
// we use as args will be rooted by the engine as we do conversions and
|
1350
|
+
// prepare to do the function call. This adds a fair amount of complexity,
|
1351
|
+
// but is a good optimization compared to calling JS_AddRoot for each item.
|
1352
|
+
|
1353
|
+
js_LeaveTrace(cx);
|
1354
|
+
|
1355
|
+
// setup stack
|
1356
|
+
|
1357
|
+
// if this isn't a function call then we don't need to push extra stuff
|
1358
|
+
if(XPT_MD_IS_GETTER(info->flags) || XPT_MD_IS_SETTER(info->flags))
|
1359
|
+
{
|
1360
|
+
stack_size = argc;
|
1361
|
+
}
|
1362
|
+
else
|
1363
|
+
{
|
1364
|
+
// allocate extra space for function and 'this'
|
1365
|
+
stack_size = argc + 2;
|
1366
|
+
|
1367
|
+
// We get fval before allocating the stack to avoid gc badness that can
|
1368
|
+
// happen if the GetProperty call leaves our request and the gc runs
|
1369
|
+
// while the stack we allocate contains garbage.
|
1370
|
+
|
1371
|
+
// If the interface is marked as a [function] then we will assume that
|
1372
|
+
// our JSObject is a function and not an object with a named method.
|
1373
|
+
|
1374
|
+
PRBool isFunction;
|
1375
|
+
if(NS_FAILED(mInfo->IsFunction(&isFunction)))
|
1376
|
+
goto pre_call_clean_up;
|
1377
|
+
|
1378
|
+
// In the xpidl [function] case we are making sure now that the
|
1379
|
+
// JSObject is callable. If it is *not* callable then we silently
|
1380
|
+
// fallback to looking up the named property...
|
1381
|
+
// (because jst says he thinks this fallback is 'The Right Thing'.)
|
1382
|
+
//
|
1383
|
+
// In the normal (non-function) case we just lookup the property by
|
1384
|
+
// name and as long as the object has such a named property we go ahead
|
1385
|
+
// and try to make the call. If it turns out the named property is not
|
1386
|
+
// a callable object then the JS engine will throw an error and we'll
|
1387
|
+
// pass this along to the caller as an exception/result code.
|
1388
|
+
|
1389
|
+
if(isFunction &&
|
1390
|
+
JS_TypeOfValue(ccx, OBJECT_TO_JSVAL(obj)) == JSTYPE_FUNCTION)
|
1391
|
+
{
|
1392
|
+
fval = OBJECT_TO_JSVAL(obj);
|
1393
|
+
|
1394
|
+
// We may need to translate the 'this' for the function object.
|
1395
|
+
|
1396
|
+
if(paramCount)
|
1397
|
+
{
|
1398
|
+
const nsXPTParamInfo& firstParam = info->params[0];
|
1399
|
+
if(firstParam.IsIn())
|
1400
|
+
{
|
1401
|
+
const nsXPTType& firstType = firstParam.GetType();
|
1402
|
+
if(firstType.IsPointer() && firstType.IsInterfacePointer())
|
1403
|
+
{
|
1404
|
+
nsIXPCFunctionThisTranslator* translator;
|
1405
|
+
|
1406
|
+
IID2ThisTranslatorMap* map =
|
1407
|
+
mRuntime->GetThisTranslatorMap();
|
1408
|
+
|
1409
|
+
{
|
1410
|
+
XPCAutoLock lock(mRuntime->GetMapLock()); // scoped lock
|
1411
|
+
translator = map->Find(mIID);
|
1412
|
+
}
|
1413
|
+
|
1414
|
+
if(translator)
|
1415
|
+
{
|
1416
|
+
PRBool hideFirstParamFromJS = PR_FALSE;
|
1417
|
+
nsIID* newWrapperIID = nsnull;
|
1418
|
+
nsCOMPtr<nsISupports> newThis;
|
1419
|
+
|
1420
|
+
if(NS_FAILED(translator->
|
1421
|
+
TranslateThis((nsISupports*)nativeParams[0].val.p,
|
1422
|
+
mInfo, methodIndex,
|
1423
|
+
&hideFirstParamFromJS,
|
1424
|
+
&newWrapperIID,
|
1425
|
+
getter_AddRefs(newThis))))
|
1426
|
+
{
|
1427
|
+
goto pre_call_clean_up;
|
1428
|
+
}
|
1429
|
+
if(hideFirstParamFromJS)
|
1430
|
+
{
|
1431
|
+
NS_ERROR("HideFirstParamFromJS not supported");
|
1432
|
+
goto pre_call_clean_up;
|
1433
|
+
}
|
1434
|
+
if(newThis)
|
1435
|
+
{
|
1436
|
+
jsval v;
|
1437
|
+
JSBool ok =
|
1438
|
+
XPCConvert::NativeInterface2JSObject(ccx,
|
1439
|
+
&v, nsnull, newThis, newWrapperIID,
|
1440
|
+
nsnull, nsnull, obj, PR_FALSE, PR_FALSE,
|
1441
|
+
nsnull);
|
1442
|
+
if(newWrapperIID)
|
1443
|
+
nsMemory::Free(newWrapperIID);
|
1444
|
+
if(!ok)
|
1445
|
+
{
|
1446
|
+
goto pre_call_clean_up;
|
1447
|
+
}
|
1448
|
+
thisObj = JSVAL_TO_OBJECT(v);
|
1449
|
+
}
|
1450
|
+
}
|
1451
|
+
}
|
1452
|
+
}
|
1453
|
+
}
|
1454
|
+
}
|
1455
|
+
else if(!JS_GetMethod(cx, obj, name, &thisObj, &fval))
|
1456
|
+
{
|
1457
|
+
// XXX We really want to factor out the error reporting better and
|
1458
|
+
// specifically report the failure to find a function with this name.
|
1459
|
+
// This is what we do below if the property is found but is not a
|
1460
|
+
// function. We just need to factor better so we can get to that
|
1461
|
+
// reporting path from here.
|
1462
|
+
goto pre_call_clean_up;
|
1463
|
+
}
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
// if stack_size is zero then we won't be needing a stack
|
1467
|
+
if(stack_size && !(stackbase = sp = js_AllocStack(cx, stack_size, &mark)))
|
1468
|
+
{
|
1469
|
+
retval = NS_ERROR_OUT_OF_MEMORY;
|
1470
|
+
goto pre_call_clean_up;
|
1471
|
+
}
|
1472
|
+
|
1473
|
+
NS_ASSERTION(XPT_MD_IS_GETTER(info->flags) || sp,
|
1474
|
+
"Only a getter needs no stack.");
|
1475
|
+
|
1476
|
+
// this is a function call, so push function and 'this'
|
1477
|
+
if(stack_size != argc)
|
1478
|
+
{
|
1479
|
+
*sp++ = fval;
|
1480
|
+
*sp++ = OBJECT_TO_JSVAL(thisObj);
|
1481
|
+
}
|
1482
|
+
|
1483
|
+
// make certain we leave no garbage in the stack
|
1484
|
+
for(i = 0; i < argc; i++)
|
1485
|
+
{
|
1486
|
+
sp[i] = JSVAL_VOID;
|
1487
|
+
}
|
1488
|
+
|
1489
|
+
// build the args
|
1490
|
+
for(i = 0; i < argc; i++)
|
1491
|
+
{
|
1492
|
+
const nsXPTParamInfo& param = info->params[i];
|
1493
|
+
const nsXPTType& type = param.GetType();
|
1494
|
+
nsXPTType datum_type;
|
1495
|
+
JSUint32 array_count;
|
1496
|
+
PRBool isArray = type.IsArray();
|
1497
|
+
jsval val = JSVAL_NULL;
|
1498
|
+
AUTO_MARK_JSVAL(ccx, &val);
|
1499
|
+
PRBool isSizedString = isArray ?
|
1500
|
+
JS_FALSE :
|
1501
|
+
type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
|
1502
|
+
type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS;
|
1503
|
+
|
1504
|
+
|
1505
|
+
// verify that null was not passed for 'out' param
|
1506
|
+
if(param.IsOut() && !nativeParams[i].val.p)
|
1507
|
+
{
|
1508
|
+
retval = NS_ERROR_INVALID_ARG;
|
1509
|
+
goto pre_call_clean_up;
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
if(isArray)
|
1513
|
+
{
|
1514
|
+
if(NS_FAILED(mInfo->GetTypeForParam(methodIndex, ¶m, 1,
|
1515
|
+
&datum_type)))
|
1516
|
+
goto pre_call_clean_up;
|
1517
|
+
}
|
1518
|
+
else
|
1519
|
+
datum_type = type;
|
1520
|
+
|
1521
|
+
if(param.IsIn())
|
1522
|
+
{
|
1523
|
+
nsXPTCMiniVariant* pv;
|
1524
|
+
|
1525
|
+
if(param.IsOut())
|
1526
|
+
pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
|
1527
|
+
else
|
1528
|
+
pv = &nativeParams[i];
|
1529
|
+
|
1530
|
+
if(datum_type.IsInterfacePointer() &&
|
1531
|
+
!GetInterfaceTypeFromParam(cx, info, param, methodIndex,
|
1532
|
+
datum_type, nativeParams,
|
1533
|
+
¶m_iid))
|
1534
|
+
goto pre_call_clean_up;
|
1535
|
+
|
1536
|
+
if(isArray || isSizedString)
|
1537
|
+
{
|
1538
|
+
if(!GetArraySizeFromParam(cx, info, param, methodIndex,
|
1539
|
+
i, GET_LENGTH, nativeParams,
|
1540
|
+
&array_count))
|
1541
|
+
goto pre_call_clean_up;
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
// Figure out what our callee is
|
1545
|
+
if(XPT_MD_IS_GETTER(info->flags) || XPT_MD_IS_SETTER(info->flags))
|
1546
|
+
{
|
1547
|
+
// Pull the getter or setter off of |obj|
|
1548
|
+
uintN attrs;
|
1549
|
+
JSBool found;
|
1550
|
+
JSPropertyOp getter;
|
1551
|
+
JSPropertyOp setter;
|
1552
|
+
JSBool ok =
|
1553
|
+
JS_GetPropertyAttrsGetterAndSetter(cx, obj, name,
|
1554
|
+
&attrs, &found,
|
1555
|
+
&getter, &setter);
|
1556
|
+
if(ok)
|
1557
|
+
{
|
1558
|
+
if(XPT_MD_IS_GETTER(info->flags) && (attrs & JSPROP_GETTER))
|
1559
|
+
{
|
1560
|
+
// JSPROP_GETTER means the getter is actually a
|
1561
|
+
// function object.
|
1562
|
+
ccx.SetCallee(JS_FUNC_TO_DATA_PTR(JSObject*, getter));
|
1563
|
+
}
|
1564
|
+
else if(XPT_MD_IS_SETTER(info->flags) && (attrs & JSPROP_SETTER))
|
1565
|
+
{
|
1566
|
+
// JSPROP_SETTER means the setter is actually a
|
1567
|
+
// function object.
|
1568
|
+
ccx.SetCallee(JS_FUNC_TO_DATA_PTR(JSObject*, setter));
|
1569
|
+
}
|
1570
|
+
}
|
1571
|
+
}
|
1572
|
+
else if(JSVAL_IS_OBJECT(fval))
|
1573
|
+
{
|
1574
|
+
ccx.SetCallee(JSVAL_TO_OBJECT(fval));
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
if(isArray)
|
1578
|
+
{
|
1579
|
+
|
1580
|
+
if(!XPCConvert::NativeArray2JS(ccx, &val, (const void**)&pv->val,
|
1581
|
+
datum_type, ¶m_iid,
|
1582
|
+
array_count, obj, nsnull))
|
1583
|
+
goto pre_call_clean_up;
|
1584
|
+
}
|
1585
|
+
else if(isSizedString)
|
1586
|
+
{
|
1587
|
+
if(!XPCConvert::NativeStringWithSize2JS(ccx, &val,
|
1588
|
+
(const void*)&pv->val,
|
1589
|
+
datum_type,
|
1590
|
+
array_count, nsnull))
|
1591
|
+
goto pre_call_clean_up;
|
1592
|
+
}
|
1593
|
+
else
|
1594
|
+
{
|
1595
|
+
if(!XPCConvert::NativeData2JS(ccx, &val, &pv->val, type,
|
1596
|
+
¶m_iid, obj, nsnull))
|
1597
|
+
goto pre_call_clean_up;
|
1598
|
+
}
|
1599
|
+
}
|
1600
|
+
|
1601
|
+
if(param.IsOut())
|
1602
|
+
{
|
1603
|
+
// create an 'out' object
|
1604
|
+
JSObject* out_obj = NewOutObject(cx, obj);
|
1605
|
+
if(!out_obj)
|
1606
|
+
{
|
1607
|
+
retval = NS_ERROR_OUT_OF_MEMORY;
|
1608
|
+
goto pre_call_clean_up;
|
1609
|
+
}
|
1610
|
+
|
1611
|
+
if(param.IsIn())
|
1612
|
+
{
|
1613
|
+
if(!JS_SetPropertyById(cx, out_obj,
|
1614
|
+
mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
|
1615
|
+
&val))
|
1616
|
+
{
|
1617
|
+
goto pre_call_clean_up;
|
1618
|
+
}
|
1619
|
+
}
|
1620
|
+
*sp++ = OBJECT_TO_JSVAL(out_obj);
|
1621
|
+
}
|
1622
|
+
else
|
1623
|
+
*sp++ = val;
|
1624
|
+
}
|
1625
|
+
|
1626
|
+
|
1627
|
+
|
1628
|
+
readyToDoTheCall = JS_TRUE;
|
1629
|
+
|
1630
|
+
pre_call_clean_up:
|
1631
|
+
// clean up any 'out' params handed in
|
1632
|
+
for(i = 0; i < paramCount; i++)
|
1633
|
+
{
|
1634
|
+
const nsXPTParamInfo& param = info->params[i];
|
1635
|
+
if(!param.IsOut())
|
1636
|
+
continue;
|
1637
|
+
|
1638
|
+
const nsXPTType& type = param.GetType();
|
1639
|
+
if(!type.IsPointer())
|
1640
|
+
continue;
|
1641
|
+
void* p;
|
1642
|
+
if(!(p = nativeParams[i].val.p))
|
1643
|
+
continue;
|
1644
|
+
|
1645
|
+
if(param.IsIn())
|
1646
|
+
{
|
1647
|
+
if(type.IsArray())
|
1648
|
+
{
|
1649
|
+
void** pp;
|
1650
|
+
if(nsnull != (pp = *((void***)p)))
|
1651
|
+
{
|
1652
|
+
|
1653
|
+
// we need to get the array length and iterate the items
|
1654
|
+
JSUint32 array_count;
|
1655
|
+
nsXPTType datum_type;
|
1656
|
+
|
1657
|
+
if(NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, ¶m,
|
1658
|
+
1, &datum_type)) &&
|
1659
|
+
datum_type.IsPointer() &&
|
1660
|
+
GetArraySizeFromParam(cx, info, param, methodIndex,
|
1661
|
+
i, GET_LENGTH, nativeParams,
|
1662
|
+
&array_count) && array_count)
|
1663
|
+
{
|
1664
|
+
CleanupPointerArray(datum_type, array_count, pp);
|
1665
|
+
}
|
1666
|
+
// always release the array if it is inout
|
1667
|
+
nsMemory::Free(pp);
|
1668
|
+
}
|
1669
|
+
}
|
1670
|
+
else
|
1671
|
+
CleanupPointerTypeObject(type, (void**)p);
|
1672
|
+
}
|
1673
|
+
*((void**)p) = nsnull;
|
1674
|
+
}
|
1675
|
+
|
1676
|
+
// Make sure "this" doesn't get deleted during this call.
|
1677
|
+
nsCOMPtr<nsIXPCWrappedJSClass> kungFuDeathGrip(this);
|
1678
|
+
|
1679
|
+
result = JSVAL_NULL;
|
1680
|
+
AUTO_MARK_JSVAL(ccx, &result);
|
1681
|
+
|
1682
|
+
if(!readyToDoTheCall)
|
1683
|
+
goto done;
|
1684
|
+
|
1685
|
+
// do the deed - note exceptions
|
1686
|
+
|
1687
|
+
JS_ClearPendingException(cx);
|
1688
|
+
|
1689
|
+
if(XPT_MD_IS_GETTER(info->flags))
|
1690
|
+
success = JS_GetProperty(cx, obj, name, &result);
|
1691
|
+
else if(XPT_MD_IS_SETTER(info->flags))
|
1692
|
+
success = JS_SetProperty(cx, obj, name, sp-1);
|
1693
|
+
else
|
1694
|
+
{
|
1695
|
+
if(!JSVAL_IS_PRIMITIVE(fval))
|
1696
|
+
{
|
1697
|
+
success = js_Invoke(cx, argc, stackbase, 0);
|
1698
|
+
result = *stackbase;
|
1699
|
+
}
|
1700
|
+
else
|
1701
|
+
{
|
1702
|
+
// The property was not an object so can't be a function.
|
1703
|
+
// Let's build and 'throw' an exception.
|
1704
|
+
|
1705
|
+
static const nsresult code =
|
1706
|
+
NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED;
|
1707
|
+
static const char format[] = "%s \"%s\"";
|
1708
|
+
const char * msg;
|
1709
|
+
char* sz = nsnull;
|
1710
|
+
|
1711
|
+
if(nsXPCException::NameAndFormatForNSResult(code, nsnull, &msg) && msg)
|
1712
|
+
sz = JS_smprintf(format, msg, name);
|
1713
|
+
|
1714
|
+
nsCOMPtr<nsIException> e;
|
1715
|
+
|
1716
|
+
XPCConvert::ConstructException(code, sz, GetInterfaceName(), name,
|
1717
|
+
nsnull, getter_AddRefs(e), nsnull, nsnull);
|
1718
|
+
xpcc->SetException(e);
|
1719
|
+
if(sz)
|
1720
|
+
JS_smprintf_free(sz);
|
1721
|
+
success = JS_FALSE;
|
1722
|
+
}
|
1723
|
+
}
|
1724
|
+
|
1725
|
+
if (!success)
|
1726
|
+
{
|
1727
|
+
PRBool forceReport;
|
1728
|
+
if(NS_FAILED(mInfo->IsFunction(&forceReport)))
|
1729
|
+
forceReport = PR_FALSE;
|
1730
|
+
|
1731
|
+
// May also want to check if we're moving from content->chrome and force
|
1732
|
+
// a report in that case.
|
1733
|
+
|
1734
|
+
retval = CheckForException(ccx, name, GetInterfaceName(), forceReport);
|
1735
|
+
goto done;
|
1736
|
+
}
|
1737
|
+
|
1738
|
+
ccx.GetThreadData()->SetException(nsnull); // XXX necessary?
|
1739
|
+
|
1740
|
+
#define HANDLE_OUT_CONVERSION_FAILURE \
|
1741
|
+
{outConversionFailedIndex = i; break;}
|
1742
|
+
|
1743
|
+
// convert out args and result
|
1744
|
+
// NOTE: this is the total number of native params, not just the args
|
1745
|
+
// Convert independent params only.
|
1746
|
+
// When we later convert the dependent params (if any) we will know that
|
1747
|
+
// the params upon which they depend will have already been converted -
|
1748
|
+
// regardless of ordering.
|
1749
|
+
|
1750
|
+
outConversionFailedIndex = paramCount;
|
1751
|
+
foundDependentParam = JS_FALSE;
|
1752
|
+
for(i = 0; i < paramCount; i++)
|
1753
|
+
{
|
1754
|
+
const nsXPTParamInfo& param = info->params[i];
|
1755
|
+
if(!param.IsOut() && !param.IsDipper())
|
1756
|
+
continue;
|
1757
|
+
|
1758
|
+
const nsXPTType& type = param.GetType();
|
1759
|
+
if(type.IsDependent())
|
1760
|
+
{
|
1761
|
+
foundDependentParam = JS_TRUE;
|
1762
|
+
continue;
|
1763
|
+
}
|
1764
|
+
|
1765
|
+
jsval val;
|
1766
|
+
uint8 type_tag = type.TagPart();
|
1767
|
+
JSBool useAllocator = JS_FALSE;
|
1768
|
+
nsXPTCMiniVariant* pv;
|
1769
|
+
|
1770
|
+
if(param.IsDipper())
|
1771
|
+
pv = (nsXPTCMiniVariant*) &nativeParams[i].val.p;
|
1772
|
+
else
|
1773
|
+
pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
|
1774
|
+
|
1775
|
+
if(param.IsRetval())
|
1776
|
+
val = result;
|
1777
|
+
else if(JSVAL_IS_PRIMITIVE(stackbase[i+2]) ||
|
1778
|
+
!JS_GetPropertyById(cx, JSVAL_TO_OBJECT(stackbase[i+2]),
|
1779
|
+
mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
|
1780
|
+
&val))
|
1781
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1782
|
+
|
1783
|
+
// setup allocator and/or iid
|
1784
|
+
|
1785
|
+
if(type_tag == nsXPTType::T_INTERFACE)
|
1786
|
+
{
|
1787
|
+
if(NS_FAILED(GetInterfaceInfo()->
|
1788
|
+
GetIIDForParamNoAlloc(methodIndex, ¶m,
|
1789
|
+
¶m_iid)))
|
1790
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1791
|
+
}
|
1792
|
+
else if(type.IsPointer() && !param.IsShared() && !param.IsDipper())
|
1793
|
+
useAllocator = JS_TRUE;
|
1794
|
+
|
1795
|
+
if(!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
|
1796
|
+
useAllocator, ¶m_iid, nsnull))
|
1797
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1798
|
+
}
|
1799
|
+
|
1800
|
+
// if any params were dependent, then we must iterate again to convert them.
|
1801
|
+
if(foundDependentParam && outConversionFailedIndex == paramCount)
|
1802
|
+
{
|
1803
|
+
for(i = 0; i < paramCount; i++)
|
1804
|
+
{
|
1805
|
+
const nsXPTParamInfo& param = info->params[i];
|
1806
|
+
if(!param.IsOut())
|
1807
|
+
continue;
|
1808
|
+
|
1809
|
+
const nsXPTType& type = param.GetType();
|
1810
|
+
if(!type.IsDependent())
|
1811
|
+
continue;
|
1812
|
+
|
1813
|
+
jsval val;
|
1814
|
+
nsXPTCMiniVariant* pv;
|
1815
|
+
nsXPTType datum_type;
|
1816
|
+
JSBool useAllocator = JS_FALSE;
|
1817
|
+
JSUint32 array_count;
|
1818
|
+
PRBool isArray = type.IsArray();
|
1819
|
+
PRBool isSizedString = isArray ?
|
1820
|
+
JS_FALSE :
|
1821
|
+
type.TagPart() == nsXPTType::T_PSTRING_SIZE_IS ||
|
1822
|
+
type.TagPart() == nsXPTType::T_PWSTRING_SIZE_IS;
|
1823
|
+
|
1824
|
+
pv = (nsXPTCMiniVariant*) nativeParams[i].val.p;
|
1825
|
+
|
1826
|
+
if(param.IsRetval())
|
1827
|
+
val = result;
|
1828
|
+
else if(!JS_GetPropertyById(cx, JSVAL_TO_OBJECT(stackbase[i+2]),
|
1829
|
+
mRuntime->GetStringID(XPCJSRuntime::IDX_VALUE),
|
1830
|
+
&val))
|
1831
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1832
|
+
|
1833
|
+
// setup allocator and/or iid
|
1834
|
+
|
1835
|
+
if(isArray)
|
1836
|
+
{
|
1837
|
+
if(NS_FAILED(mInfo->GetTypeForParam(methodIndex, ¶m, 1,
|
1838
|
+
&datum_type)))
|
1839
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1840
|
+
}
|
1841
|
+
else
|
1842
|
+
datum_type = type;
|
1843
|
+
|
1844
|
+
if(datum_type.IsInterfacePointer())
|
1845
|
+
{
|
1846
|
+
if(!GetInterfaceTypeFromParam(cx, info, param, methodIndex,
|
1847
|
+
datum_type, nativeParams,
|
1848
|
+
¶m_iid))
|
1849
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1850
|
+
}
|
1851
|
+
else if(type.IsPointer() && !param.IsShared())
|
1852
|
+
useAllocator = JS_TRUE;
|
1853
|
+
|
1854
|
+
if(isArray || isSizedString)
|
1855
|
+
{
|
1856
|
+
if(!GetArraySizeFromParam(cx, info, param, methodIndex,
|
1857
|
+
i, GET_LENGTH, nativeParams,
|
1858
|
+
&array_count))
|
1859
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1860
|
+
}
|
1861
|
+
|
1862
|
+
if(isArray)
|
1863
|
+
{
|
1864
|
+
if(array_count &&
|
1865
|
+
!XPCConvert::JSArray2Native(ccx, (void**)&pv->val, val,
|
1866
|
+
array_count, array_count,
|
1867
|
+
datum_type,
|
1868
|
+
useAllocator, ¶m_iid,
|
1869
|
+
nsnull))
|
1870
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1871
|
+
}
|
1872
|
+
else if(isSizedString)
|
1873
|
+
{
|
1874
|
+
if(!XPCConvert::JSStringWithSize2Native(ccx,
|
1875
|
+
(void*)&pv->val, val,
|
1876
|
+
array_count, array_count,
|
1877
|
+
datum_type, useAllocator,
|
1878
|
+
nsnull))
|
1879
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1880
|
+
}
|
1881
|
+
else
|
1882
|
+
{
|
1883
|
+
if(!XPCConvert::JSData2Native(ccx, &pv->val, val, type,
|
1884
|
+
useAllocator, ¶m_iid,
|
1885
|
+
nsnull))
|
1886
|
+
HANDLE_OUT_CONVERSION_FAILURE
|
1887
|
+
}
|
1888
|
+
}
|
1889
|
+
}
|
1890
|
+
|
1891
|
+
if(outConversionFailedIndex != paramCount)
|
1892
|
+
{
|
1893
|
+
// We didn't manage all the result conversions!
|
1894
|
+
// We have to cleanup any junk that *did* get converted.
|
1895
|
+
|
1896
|
+
for(uint8 k = 0; k < i; k++)
|
1897
|
+
{
|
1898
|
+
const nsXPTParamInfo& param = info->params[k];
|
1899
|
+
if(!param.IsOut())
|
1900
|
+
continue;
|
1901
|
+
const nsXPTType& type = param.GetType();
|
1902
|
+
if(!type.IsPointer())
|
1903
|
+
continue;
|
1904
|
+
void* p;
|
1905
|
+
if(!(p = nativeParams[k].val.p))
|
1906
|
+
continue;
|
1907
|
+
|
1908
|
+
if(type.IsArray())
|
1909
|
+
{
|
1910
|
+
void** pp;
|
1911
|
+
if(nsnull != (pp = *((void***)p)))
|
1912
|
+
{
|
1913
|
+
// we need to get the array length and iterate the items
|
1914
|
+
JSUint32 array_count;
|
1915
|
+
nsXPTType datum_type;
|
1916
|
+
|
1917
|
+
if(NS_SUCCEEDED(mInfo->GetTypeForParam(methodIndex, ¶m,
|
1918
|
+
1, &datum_type)) &&
|
1919
|
+
datum_type.IsPointer() &&
|
1920
|
+
GetArraySizeFromParam(cx, info, param, methodIndex,
|
1921
|
+
k, GET_LENGTH, nativeParams,
|
1922
|
+
&array_count) && array_count)
|
1923
|
+
{
|
1924
|
+
CleanupPointerArray(datum_type, array_count, pp);
|
1925
|
+
}
|
1926
|
+
nsMemory::Free(pp);
|
1927
|
+
}
|
1928
|
+
}
|
1929
|
+
else
|
1930
|
+
CleanupPointerTypeObject(type, (void**)p);
|
1931
|
+
*((void**)p) = nsnull;
|
1932
|
+
}
|
1933
|
+
}
|
1934
|
+
else
|
1935
|
+
{
|
1936
|
+
// set to whatever the JS code might have set as the result
|
1937
|
+
retval = pending_result;
|
1938
|
+
}
|
1939
|
+
|
1940
|
+
done:
|
1941
|
+
if(sp)
|
1942
|
+
js_FreeStack(cx, mark);
|
1943
|
+
|
1944
|
+
#ifdef DEBUG_stats_jband
|
1945
|
+
endTime = PR_IntervalNow();
|
1946
|
+
printf("%s::%s %d ( c->js ) \n", GetInterfaceName(), info->GetName(), PR_IntervalToMilliseconds(endTime-startTime));
|
1947
|
+
totalTime += endTime-startTime;
|
1948
|
+
#endif
|
1949
|
+
return retval;
|
1950
|
+
}
|
1951
|
+
|
1952
|
+
const char*
|
1953
|
+
nsXPCWrappedJSClass::GetInterfaceName()
|
1954
|
+
{
|
1955
|
+
if(!mName)
|
1956
|
+
mInfo->GetName(&mName);
|
1957
|
+
return mName;
|
1958
|
+
}
|
1959
|
+
|
1960
|
+
JSObject*
|
1961
|
+
nsXPCWrappedJSClass::NewOutObject(JSContext* cx, JSObject* scope)
|
1962
|
+
{
|
1963
|
+
return JS_NewObject(cx, nsnull, nsnull, JS_GetGlobalForObject(cx, scope));
|
1964
|
+
}
|
1965
|
+
|
1966
|
+
|
1967
|
+
NS_IMETHODIMP
|
1968
|
+
nsXPCWrappedJSClass::DebugDump(PRInt16 depth)
|
1969
|
+
{
|
1970
|
+
#ifdef DEBUG
|
1971
|
+
depth-- ;
|
1972
|
+
XPC_LOG_ALWAYS(("nsXPCWrappedJSClass @ %x with mRefCnt = %d", this, mRefCnt.get()));
|
1973
|
+
XPC_LOG_INDENT();
|
1974
|
+
char* name;
|
1975
|
+
mInfo->GetName(&name);
|
1976
|
+
XPC_LOG_ALWAYS(("interface name is %s", name));
|
1977
|
+
if(name)
|
1978
|
+
nsMemory::Free(name);
|
1979
|
+
char * iid = mIID.ToString();
|
1980
|
+
XPC_LOG_ALWAYS(("IID number is %s", iid ? iid : "invalid"));
|
1981
|
+
if(iid)
|
1982
|
+
PR_Free(iid);
|
1983
|
+
XPC_LOG_ALWAYS(("InterfaceInfo @ %x", mInfo));
|
1984
|
+
uint16 methodCount = 0;
|
1985
|
+
if(depth)
|
1986
|
+
{
|
1987
|
+
uint16 i;
|
1988
|
+
nsCOMPtr<nsIInterfaceInfo> parent;
|
1989
|
+
XPC_LOG_INDENT();
|
1990
|
+
mInfo->GetParent(getter_AddRefs(parent));
|
1991
|
+
XPC_LOG_ALWAYS(("parent @ %x", parent.get()));
|
1992
|
+
mInfo->GetMethodCount(&methodCount);
|
1993
|
+
XPC_LOG_ALWAYS(("MethodCount = %d", methodCount));
|
1994
|
+
mInfo->GetConstantCount(&i);
|
1995
|
+
XPC_LOG_ALWAYS(("ConstantCount = %d", i));
|
1996
|
+
XPC_LOG_OUTDENT();
|
1997
|
+
}
|
1998
|
+
XPC_LOG_ALWAYS(("mRuntime @ %x", mRuntime));
|
1999
|
+
XPC_LOG_ALWAYS(("mDescriptors @ %x count = %d", mDescriptors, methodCount));
|
2000
|
+
if(depth && mDescriptors && methodCount)
|
2001
|
+
{
|
2002
|
+
depth--;
|
2003
|
+
XPC_LOG_INDENT();
|
2004
|
+
for(uint16 i = 0; i < methodCount; i++)
|
2005
|
+
{
|
2006
|
+
XPC_LOG_ALWAYS(("Method %d is %s%s", \
|
2007
|
+
i, IsReflectable(i) ? "":" NOT ","reflectable"));
|
2008
|
+
}
|
2009
|
+
XPC_LOG_OUTDENT();
|
2010
|
+
depth++;
|
2011
|
+
}
|
2012
|
+
XPC_LOG_OUTDENT();
|
2013
|
+
#endif
|
2014
|
+
return NS_OK;
|
2015
|
+
}
|