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,2003 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2
|
+
* vim: set ts=8 sw=4 et tw=78:
|
3
|
+
*
|
4
|
+
* ***** BEGIN LICENSE BLOCK *****
|
5
|
+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
6
|
+
*
|
7
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
8
|
+
* 1.1 (the "License"); you may not use this file except in compliance with
|
9
|
+
* the License. You may obtain a copy of the License at
|
10
|
+
* http://www.mozilla.org/MPL/
|
11
|
+
*
|
12
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
13
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
14
|
+
* for the specific language governing rights and limitations under the
|
15
|
+
* License.
|
16
|
+
*
|
17
|
+
* The Original Code is Mozilla Communicator client code, released
|
18
|
+
* March 31, 1998.
|
19
|
+
*
|
20
|
+
* The Initial Developer of the Original Code is
|
21
|
+
* Netscape Communications Corporation.
|
22
|
+
* Portions created by the Initial Developer are Copyright (C) 1999
|
23
|
+
* the Initial Developer. All Rights Reserved.
|
24
|
+
*
|
25
|
+
* Contributor(s):
|
26
|
+
* John Bandhauer <jband@netscape.com> (original author)
|
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
|
+
/* JavaScript JSClasses and JSOps for our Wrapped Native JS Objects. */
|
43
|
+
|
44
|
+
#include "xpcprivate.h"
|
45
|
+
#include "XPCNativeWrapper.h"
|
46
|
+
#include "XPCWrapper.h"
|
47
|
+
|
48
|
+
/***************************************************************************/
|
49
|
+
|
50
|
+
// All of the exceptions thrown into JS from this file go through here.
|
51
|
+
// That makes this a nice place to set a breakpoint.
|
52
|
+
|
53
|
+
static JSBool Throw(uintN errNum, JSContext* cx)
|
54
|
+
{
|
55
|
+
XPCThrower::Throw(errNum, cx);
|
56
|
+
return JS_FALSE;
|
57
|
+
}
|
58
|
+
|
59
|
+
// Handy macro used in many callback stub below.
|
60
|
+
|
61
|
+
#define THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper) \
|
62
|
+
PR_BEGIN_MACRO \
|
63
|
+
if(!wrapper) \
|
64
|
+
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx); \
|
65
|
+
if(!wrapper->IsValid()) \
|
66
|
+
return Throw(NS_ERROR_XPC_HAS_BEEN_SHUTDOWN, cx); \
|
67
|
+
PR_END_MACRO
|
68
|
+
|
69
|
+
// We rely on the engine only giving us jsval ids that are actually the
|
70
|
+
// self-same jsvals that are in the atom table (that is, if the id represents
|
71
|
+
// a string). So, we assert by converting the jsval to an id and then back
|
72
|
+
// to a jsval and comparing pointers. If the engine ever breaks this promise
|
73
|
+
// then we will scream.
|
74
|
+
#ifdef DEBUG
|
75
|
+
#define CHECK_IDVAL(cx, idval) \
|
76
|
+
PR_BEGIN_MACRO \
|
77
|
+
if(JSVAL_IS_STRING(idval)) \
|
78
|
+
{ \
|
79
|
+
jsid d_id; \
|
80
|
+
jsval d_val; \
|
81
|
+
NS_ASSERTION(JS_ValueToId(cx, idval, &d_id), "JS_ValueToId failed!");\
|
82
|
+
NS_ASSERTION(JS_IdToValue(cx, d_id, &d_val), "JS_IdToValue failed!");\
|
83
|
+
NS_ASSERTION(d_val == idval, "id differs from id in atom table!"); \
|
84
|
+
} \
|
85
|
+
PR_END_MACRO
|
86
|
+
#else
|
87
|
+
#define CHECK_IDVAL(cx, idval) ((void)0)
|
88
|
+
#endif
|
89
|
+
|
90
|
+
/***************************************************************************/
|
91
|
+
|
92
|
+
static JSBool
|
93
|
+
ToStringGuts(XPCCallContext& ccx)
|
94
|
+
{
|
95
|
+
char* sz;
|
96
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
97
|
+
|
98
|
+
if(wrapper)
|
99
|
+
sz = wrapper->ToString(ccx, ccx.GetTearOff());
|
100
|
+
else
|
101
|
+
sz = JS_smprintf("[xpconnect wrapped native prototype]");
|
102
|
+
|
103
|
+
if(!sz)
|
104
|
+
{
|
105
|
+
JS_ReportOutOfMemory(ccx);
|
106
|
+
return JS_FALSE;
|
107
|
+
}
|
108
|
+
|
109
|
+
JSString* str = JS_NewString(ccx, sz, strlen(sz));
|
110
|
+
if(!str)
|
111
|
+
{
|
112
|
+
JS_smprintf_free(sz);
|
113
|
+
// JS_ReportOutOfMemory already reported by failed JS_NewString
|
114
|
+
return JS_FALSE;
|
115
|
+
}
|
116
|
+
|
117
|
+
ccx.SetRetVal(STRING_TO_JSVAL(str));
|
118
|
+
return JS_TRUE;
|
119
|
+
}
|
120
|
+
|
121
|
+
/***************************************************************************/
|
122
|
+
|
123
|
+
static JSBool
|
124
|
+
XPC_WN_Shared_ToString(JSContext *cx, JSObject *obj,
|
125
|
+
uintN argc, jsval *argv, jsval *vp)
|
126
|
+
{
|
127
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
128
|
+
ccx.SetName(ccx.GetRuntime()->GetStringJSVal(XPCJSRuntime::IDX_TO_STRING));
|
129
|
+
ccx.SetArgsAndResultPtr(argc, argv, vp);
|
130
|
+
return ToStringGuts(ccx);
|
131
|
+
}
|
132
|
+
|
133
|
+
static JSBool
|
134
|
+
XPC_WN_Shared_ToSource(JSContext *cx, JSObject *obj,
|
135
|
+
uintN argc, jsval *argv, jsval *vp)
|
136
|
+
{
|
137
|
+
static const char empty[] = "{}";
|
138
|
+
*vp = STRING_TO_JSVAL(JS_NewStringCopyN(cx, empty, sizeof(empty)-1));
|
139
|
+
return JS_TRUE;
|
140
|
+
}
|
141
|
+
|
142
|
+
/***************************************************************************/
|
143
|
+
|
144
|
+
// A "double wrapped object" is a user JSObject that has been wrapped as a
|
145
|
+
// wrappedJS in order to be used by native code and then re-wrapped by a
|
146
|
+
// wrappedNative wrapper to be used by JS code. One might think of it as:
|
147
|
+
// wrappedNative(wrappedJS(underlying_JSObject))
|
148
|
+
// This is done (as opposed to just unwrapping the wrapped JS and automatically
|
149
|
+
// returning the underlying JSObject) so that JS callers will see what looks
|
150
|
+
// Like any other xpcom object - and be limited to use its interfaces.
|
151
|
+
//
|
152
|
+
// See the comment preceeding nsIXPCWrappedJSObjectGetter in nsIXPConnect.idl.
|
153
|
+
|
154
|
+
static JSObject*
|
155
|
+
GetDoubleWrappedJSObject(XPCCallContext& ccx, XPCWrappedNative* wrapper)
|
156
|
+
{
|
157
|
+
JSObject* obj = nsnull;
|
158
|
+
nsCOMPtr<nsIXPConnectWrappedJS>
|
159
|
+
underware = do_QueryInterface(wrapper->GetIdentityObject());
|
160
|
+
if(underware)
|
161
|
+
{
|
162
|
+
JSObject* mainObj = nsnull;
|
163
|
+
if(NS_SUCCEEDED(underware->GetJSObject(&mainObj)) && mainObj)
|
164
|
+
{
|
165
|
+
jsid id = ccx.GetRuntime()->
|
166
|
+
GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
|
167
|
+
|
168
|
+
jsval val;
|
169
|
+
if(JS_GetPropertyById(ccx, mainObj, id, &val) &&
|
170
|
+
!JSVAL_IS_PRIMITIVE(val))
|
171
|
+
{
|
172
|
+
obj = JSVAL_TO_OBJECT(val);
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
return obj;
|
177
|
+
}
|
178
|
+
|
179
|
+
// This is the getter native function we use to handle 'wrappedJSObject' for
|
180
|
+
// double wrapped JSObjects.
|
181
|
+
|
182
|
+
static JSBool
|
183
|
+
XPC_WN_DoubleWrappedGetter(JSContext *cx, JSObject *obj,
|
184
|
+
uintN argc, jsval *argv, jsval *vp)
|
185
|
+
{
|
186
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
187
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
188
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
189
|
+
|
190
|
+
NS_ASSERTION(JS_TypeOfValue(cx, argv[-2]) == JSTYPE_FUNCTION, "bad function");
|
191
|
+
|
192
|
+
JSObject* realObject = GetDoubleWrappedJSObject(ccx, wrapper);
|
193
|
+
if(!realObject)
|
194
|
+
{
|
195
|
+
// This is pretty unexpected at this point. The object originally
|
196
|
+
// responded to this get property call and now gives no object.
|
197
|
+
// XXX Should this throw something at the caller?
|
198
|
+
*vp = JSVAL_NULL;
|
199
|
+
return JS_TRUE;
|
200
|
+
}
|
201
|
+
|
202
|
+
// It is a double wrapped object. Figure out if the caller
|
203
|
+
// is allowed to see it.
|
204
|
+
|
205
|
+
nsIXPCSecurityManager* sm;
|
206
|
+
XPCContext* xpcc = ccx.GetXPCContext();
|
207
|
+
|
208
|
+
sm = xpcc->GetAppropriateSecurityManager(
|
209
|
+
nsIXPCSecurityManager::HOOK_GET_PROPERTY);
|
210
|
+
if(sm)
|
211
|
+
{
|
212
|
+
AutoMarkingNativeInterfacePtr iface(ccx);
|
213
|
+
iface = XPCNativeInterface::
|
214
|
+
GetNewOrUsed(ccx, &NS_GET_IID(nsIXPCWrappedJSObjectGetter));
|
215
|
+
|
216
|
+
if(iface)
|
217
|
+
{
|
218
|
+
jsval idval = ccx.GetRuntime()->
|
219
|
+
GetStringJSVal(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
|
220
|
+
|
221
|
+
ccx.SetCallInfo(iface, iface->GetMemberAt(1), JS_FALSE);
|
222
|
+
if(NS_FAILED(sm->
|
223
|
+
CanAccess(nsIXPCSecurityManager::ACCESS_GET_PROPERTY,
|
224
|
+
&ccx, ccx,
|
225
|
+
ccx.GetFlattenedJSObject(),
|
226
|
+
wrapper->GetIdentityObject(),
|
227
|
+
wrapper->GetClassInfo(), idval,
|
228
|
+
wrapper->GetSecurityInfoAddr())))
|
229
|
+
{
|
230
|
+
// The SecurityManager should have set an exception.
|
231
|
+
return JS_FALSE;
|
232
|
+
}
|
233
|
+
}
|
234
|
+
}
|
235
|
+
*vp = OBJECT_TO_JSVAL(realObject);
|
236
|
+
return JS_TRUE;
|
237
|
+
}
|
238
|
+
|
239
|
+
/***************************************************************************/
|
240
|
+
|
241
|
+
// This is our shared function to define properties on our JSObjects.
|
242
|
+
|
243
|
+
/*
|
244
|
+
* NOTE:
|
245
|
+
* We *never* set the tearoff names (e.g. nsIFoo) as JS_ENUMERATE.
|
246
|
+
* We *never* set toString or toSource as JS_ENUMERATE.
|
247
|
+
*/
|
248
|
+
|
249
|
+
static JSBool
|
250
|
+
DefinePropertyIfFound(XPCCallContext& ccx,
|
251
|
+
JSObject *obj, jsval idval,
|
252
|
+
XPCNativeSet* set,
|
253
|
+
XPCNativeInterface* iface,
|
254
|
+
XPCNativeMember* member,
|
255
|
+
XPCWrappedNativeScope* scope,
|
256
|
+
JSBool reflectToStringAndToSource,
|
257
|
+
XPCWrappedNative* wrapperToReflectInterfaceNames,
|
258
|
+
XPCWrappedNative* wrapperToReflectDoubleWrap,
|
259
|
+
XPCNativeScriptableInfo* scriptableInfo,
|
260
|
+
uintN propFlags,
|
261
|
+
JSBool* resolved)
|
262
|
+
{
|
263
|
+
XPCJSRuntime* rt = ccx.GetRuntime();
|
264
|
+
JSBool found;
|
265
|
+
const char* name;
|
266
|
+
jsid id;
|
267
|
+
|
268
|
+
if(set)
|
269
|
+
{
|
270
|
+
if(iface)
|
271
|
+
found = JS_TRUE;
|
272
|
+
else
|
273
|
+
found = set->FindMember(idval, &member, &iface);
|
274
|
+
}
|
275
|
+
else
|
276
|
+
found = (nsnull != (member = iface->FindMember(idval)));
|
277
|
+
|
278
|
+
if(!found)
|
279
|
+
{
|
280
|
+
HANDLE_POSSIBLE_NAME_CASE_ERROR(ccx, set, iface, idval);
|
281
|
+
|
282
|
+
if(reflectToStringAndToSource)
|
283
|
+
{
|
284
|
+
JSNative call;
|
285
|
+
|
286
|
+
if(idval == rt->GetStringJSVal(XPCJSRuntime::IDX_TO_STRING))
|
287
|
+
{
|
288
|
+
call = XPC_WN_Shared_ToString;
|
289
|
+
name = rt->GetStringName(XPCJSRuntime::IDX_TO_STRING);
|
290
|
+
id = rt->GetStringID(XPCJSRuntime::IDX_TO_STRING);
|
291
|
+
}
|
292
|
+
else if(idval == rt->GetStringJSVal(XPCJSRuntime::IDX_TO_SOURCE))
|
293
|
+
{
|
294
|
+
call = XPC_WN_Shared_ToSource;
|
295
|
+
name = rt->GetStringName(XPCJSRuntime::IDX_TO_SOURCE);
|
296
|
+
id = rt->GetStringID(XPCJSRuntime::IDX_TO_SOURCE);
|
297
|
+
}
|
298
|
+
|
299
|
+
else
|
300
|
+
call = nsnull;
|
301
|
+
|
302
|
+
if(call)
|
303
|
+
{
|
304
|
+
JSFunction* fun = JS_NewFunction(ccx, call, 0, 0, obj, name);
|
305
|
+
if(!fun)
|
306
|
+
{
|
307
|
+
JS_ReportOutOfMemory(ccx);
|
308
|
+
return JS_FALSE;
|
309
|
+
}
|
310
|
+
|
311
|
+
AutoResolveName arn(ccx, idval);
|
312
|
+
if(resolved)
|
313
|
+
*resolved = JS_TRUE;
|
314
|
+
return JS_DefinePropertyById(ccx, obj, id,
|
315
|
+
OBJECT_TO_JSVAL(JS_GetFunctionObject(fun)),
|
316
|
+
nsnull, nsnull,
|
317
|
+
propFlags & ~JSPROP_ENUMERATE);
|
318
|
+
}
|
319
|
+
}
|
320
|
+
// This *might* be a tearoff name that is not yet part of our
|
321
|
+
// set. Let's lookup the name and see if it is the name of an
|
322
|
+
// interface. Then we'll see if the object actually *does* this
|
323
|
+
// interface and add a tearoff as necessary.
|
324
|
+
|
325
|
+
if(wrapperToReflectInterfaceNames)
|
326
|
+
{
|
327
|
+
AutoMarkingNativeInterfacePtr iface2(ccx);
|
328
|
+
XPCWrappedNativeTearOff* to;
|
329
|
+
JSObject* jso;
|
330
|
+
|
331
|
+
if(JSVAL_IS_STRING(idval) &&
|
332
|
+
nsnull != (name = JS_GetStringBytes(JSVAL_TO_STRING(idval))) &&
|
333
|
+
(iface2 = XPCNativeInterface::GetNewOrUsed(ccx, name), iface2) &&
|
334
|
+
nsnull != (to = wrapperToReflectInterfaceNames->
|
335
|
+
FindTearOff(ccx, iface2, JS_TRUE)) &&
|
336
|
+
nsnull != (jso = to->GetJSObject()))
|
337
|
+
|
338
|
+
{
|
339
|
+
AutoResolveName arn(ccx, idval);
|
340
|
+
if(resolved)
|
341
|
+
*resolved = JS_TRUE;
|
342
|
+
return JS_ValueToId(ccx, idval, &id) &&
|
343
|
+
JS_DefinePropertyById(ccx, obj, id, OBJECT_TO_JSVAL(jso),
|
344
|
+
nsnull, nsnull,
|
345
|
+
propFlags & ~JSPROP_ENUMERATE);
|
346
|
+
}
|
347
|
+
}
|
348
|
+
|
349
|
+
// This *might* be a double wrapped JSObject
|
350
|
+
if(wrapperToReflectDoubleWrap &&
|
351
|
+
idval == rt->GetStringJSVal(XPCJSRuntime::IDX_WRAPPED_JSOBJECT) &&
|
352
|
+
GetDoubleWrappedJSObject(ccx, wrapperToReflectDoubleWrap))
|
353
|
+
{
|
354
|
+
// We build and add a getter function.
|
355
|
+
// A security check is done on a per-get basis.
|
356
|
+
|
357
|
+
JSFunction* fun;
|
358
|
+
|
359
|
+
id = rt->GetStringID(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
|
360
|
+
name = rt->GetStringName(XPCJSRuntime::IDX_WRAPPED_JSOBJECT);
|
361
|
+
|
362
|
+
fun = JS_NewFunction(ccx, XPC_WN_DoubleWrappedGetter,
|
363
|
+
0, JSFUN_GETTER, obj, name);
|
364
|
+
|
365
|
+
if(!fun)
|
366
|
+
return JS_FALSE;
|
367
|
+
|
368
|
+
JSObject* funobj = JS_GetFunctionObject(fun);
|
369
|
+
if(!funobj)
|
370
|
+
return JS_FALSE;
|
371
|
+
|
372
|
+
propFlags |= JSPROP_GETTER;
|
373
|
+
propFlags &= ~JSPROP_ENUMERATE;
|
374
|
+
|
375
|
+
AutoResolveName arn(ccx, idval);
|
376
|
+
if(resolved)
|
377
|
+
*resolved = JS_TRUE;
|
378
|
+
return JS_DefinePropertyById(ccx, obj, id, JSVAL_VOID,
|
379
|
+
JS_DATA_TO_FUNC_PTR(JSPropertyOp, funobj),
|
380
|
+
nsnull,
|
381
|
+
propFlags);
|
382
|
+
}
|
383
|
+
|
384
|
+
#ifdef XPC_IDISPATCH_SUPPORT
|
385
|
+
// Check to see if there's an IDispatch tearoff
|
386
|
+
if(wrapperToReflectInterfaceNames &&
|
387
|
+
XPCIDispatchExtension::DefineProperty(ccx, obj,
|
388
|
+
idval, wrapperToReflectInterfaceNames, propFlags, resolved))
|
389
|
+
return JS_TRUE;
|
390
|
+
#endif
|
391
|
+
|
392
|
+
if(resolved)
|
393
|
+
*resolved = JS_FALSE;
|
394
|
+
return JS_TRUE;
|
395
|
+
}
|
396
|
+
|
397
|
+
if(!member)
|
398
|
+
{
|
399
|
+
if(wrapperToReflectInterfaceNames)
|
400
|
+
{
|
401
|
+
XPCWrappedNativeTearOff* to =
|
402
|
+
wrapperToReflectInterfaceNames->FindTearOff(ccx, iface, JS_TRUE);
|
403
|
+
|
404
|
+
if(!to)
|
405
|
+
return JS_FALSE;
|
406
|
+
JSObject* jso = to->GetJSObject();
|
407
|
+
if(!jso)
|
408
|
+
return JS_FALSE;
|
409
|
+
|
410
|
+
AutoResolveName arn(ccx, idval);
|
411
|
+
if(resolved)
|
412
|
+
*resolved = JS_TRUE;
|
413
|
+
return JS_ValueToId(ccx, idval, &id) &&
|
414
|
+
JS_DefinePropertyById(ccx, obj, id, OBJECT_TO_JSVAL(jso),
|
415
|
+
nsnull, nsnull,
|
416
|
+
propFlags & ~JSPROP_ENUMERATE);
|
417
|
+
}
|
418
|
+
if(resolved)
|
419
|
+
*resolved = JS_FALSE;
|
420
|
+
return JS_TRUE;
|
421
|
+
}
|
422
|
+
|
423
|
+
if(member->IsConstant())
|
424
|
+
{
|
425
|
+
jsval val;
|
426
|
+
AutoResolveName arn(ccx, idval);
|
427
|
+
if(resolved)
|
428
|
+
*resolved = JS_TRUE;
|
429
|
+
return member->GetConstantValue(ccx, iface, &val) &&
|
430
|
+
JS_ValueToId(ccx, idval, &id) &&
|
431
|
+
JS_DefinePropertyById(ccx, obj, id, val, nsnull, nsnull,
|
432
|
+
propFlags);
|
433
|
+
}
|
434
|
+
|
435
|
+
if(idval == rt->GetStringJSVal(XPCJSRuntime::IDX_TO_STRING) ||
|
436
|
+
idval == rt->GetStringJSVal(XPCJSRuntime::IDX_TO_SOURCE) ||
|
437
|
+
(scriptableInfo &&
|
438
|
+
scriptableInfo->GetFlags().DontEnumQueryInterface() &&
|
439
|
+
idval == rt->GetStringJSVal(XPCJSRuntime::IDX_QUERY_INTERFACE)))
|
440
|
+
propFlags &= ~JSPROP_ENUMERATE;
|
441
|
+
|
442
|
+
jsval funval;
|
443
|
+
if(!member->NewFunctionObject(ccx, iface, obj, &funval))
|
444
|
+
return JS_FALSE;
|
445
|
+
|
446
|
+
// protect funobj until it is actually attached
|
447
|
+
AUTO_MARK_JSVAL(ccx, funval);
|
448
|
+
|
449
|
+
#ifdef off_DEBUG_jband
|
450
|
+
{
|
451
|
+
static int cloneCount = 0;
|
452
|
+
if(!(++cloneCount%10))
|
453
|
+
printf("<><><> %d cloned functions created\n", cloneCount);
|
454
|
+
}
|
455
|
+
#endif
|
456
|
+
|
457
|
+
if(member->IsMethod())
|
458
|
+
{
|
459
|
+
AutoResolveName arn(ccx, idval);
|
460
|
+
if(resolved)
|
461
|
+
*resolved = JS_TRUE;
|
462
|
+
return JS_ValueToId(ccx, idval, &id) &&
|
463
|
+
JS_DefinePropertyById(ccx, obj, id, funval, nsnull, nsnull,
|
464
|
+
propFlags);
|
465
|
+
}
|
466
|
+
|
467
|
+
// else...
|
468
|
+
|
469
|
+
NS_ASSERTION(member->IsAttribute(), "way broken!");
|
470
|
+
|
471
|
+
propFlags |= JSPROP_GETTER | JSPROP_SHARED;
|
472
|
+
JSObject* funobj = JSVAL_TO_OBJECT(funval);
|
473
|
+
JSPropertyOp getter = JS_DATA_TO_FUNC_PTR(JSPropertyOp, funobj);
|
474
|
+
JSPropertyOp setter;
|
475
|
+
if(member->IsWritableAttribute())
|
476
|
+
{
|
477
|
+
propFlags |= JSPROP_SETTER;
|
478
|
+
propFlags &= ~JSPROP_READONLY;
|
479
|
+
setter = getter;
|
480
|
+
}
|
481
|
+
else
|
482
|
+
{
|
483
|
+
setter = js_GetterOnlyPropertyStub;
|
484
|
+
}
|
485
|
+
|
486
|
+
AutoResolveName arn(ccx, idval);
|
487
|
+
if(resolved)
|
488
|
+
*resolved = JS_TRUE;
|
489
|
+
|
490
|
+
return JS_ValueToId(ccx, idval, &id) &&
|
491
|
+
JS_DefinePropertyById(ccx, obj, id, JSVAL_VOID, getter, setter,
|
492
|
+
propFlags);
|
493
|
+
}
|
494
|
+
|
495
|
+
/***************************************************************************/
|
496
|
+
/***************************************************************************/
|
497
|
+
|
498
|
+
static JSBool
|
499
|
+
XPC_WN_OnlyIWrite_PropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
500
|
+
{
|
501
|
+
CHECK_IDVAL(cx, idval);
|
502
|
+
|
503
|
+
XPCCallContext ccx(JS_CALLER, cx, obj, nsnull, idval);
|
504
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
505
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
506
|
+
|
507
|
+
// Allow only XPConnect to add the property
|
508
|
+
if(ccx.GetResolveName() == idval)
|
509
|
+
return JS_TRUE;
|
510
|
+
|
511
|
+
return Throw(NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN, cx);
|
512
|
+
}
|
513
|
+
|
514
|
+
static JSBool
|
515
|
+
XPC_WN_CannotModifyPropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
516
|
+
{
|
517
|
+
CHECK_IDVAL(cx, idval);
|
518
|
+
return Throw(NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN, cx);
|
519
|
+
}
|
520
|
+
|
521
|
+
static JSBool
|
522
|
+
XPC_WN_Shared_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
523
|
+
{
|
524
|
+
if(type == JSTYPE_OBJECT)
|
525
|
+
{
|
526
|
+
*vp = OBJECT_TO_JSVAL(obj);
|
527
|
+
return JS_TRUE;
|
528
|
+
}
|
529
|
+
|
530
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
531
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
532
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
533
|
+
|
534
|
+
switch (type)
|
535
|
+
{
|
536
|
+
case JSTYPE_FUNCTION:
|
537
|
+
{
|
538
|
+
if(!ccx.GetTearOff())
|
539
|
+
{
|
540
|
+
XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
|
541
|
+
if(si && (si->GetFlags().WantCall() ||
|
542
|
+
si->GetFlags().WantConstruct()))
|
543
|
+
{
|
544
|
+
*vp = OBJECT_TO_JSVAL(obj);
|
545
|
+
return JS_TRUE;
|
546
|
+
}
|
547
|
+
}
|
548
|
+
}
|
549
|
+
return Throw(NS_ERROR_XPC_CANT_CONVERT_WN_TO_FUN, cx);
|
550
|
+
case JSTYPE_NUMBER:
|
551
|
+
*vp = JS_GetNaNValue(cx);
|
552
|
+
return JS_TRUE;
|
553
|
+
case JSTYPE_BOOLEAN:
|
554
|
+
*vp = JSVAL_TRUE;
|
555
|
+
return JS_TRUE;
|
556
|
+
case JSTYPE_VOID:
|
557
|
+
case JSTYPE_STRING:
|
558
|
+
{
|
559
|
+
ccx.SetName(ccx.GetRuntime()->GetStringJSVal(XPCJSRuntime::IDX_TO_STRING));
|
560
|
+
ccx.SetArgsAndResultPtr(0, nsnull, vp);
|
561
|
+
|
562
|
+
XPCNativeMember* member = ccx.GetMember();
|
563
|
+
if(member && member->IsMethod())
|
564
|
+
{
|
565
|
+
if(!XPCWrappedNative::CallMethod(ccx))
|
566
|
+
return JS_FALSE;
|
567
|
+
|
568
|
+
if(JSVAL_IS_PRIMITIVE(*vp))
|
569
|
+
return JS_TRUE;
|
570
|
+
}
|
571
|
+
|
572
|
+
// else...
|
573
|
+
return ToStringGuts(ccx);
|
574
|
+
}
|
575
|
+
default:
|
576
|
+
NS_ERROR("bad type in conversion");
|
577
|
+
return JS_FALSE;
|
578
|
+
}
|
579
|
+
NS_NOTREACHED("huh?");
|
580
|
+
return JS_FALSE;
|
581
|
+
}
|
582
|
+
|
583
|
+
static JSBool
|
584
|
+
XPC_WN_Shared_Enumerate(JSContext *cx, JSObject *obj)
|
585
|
+
{
|
586
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
587
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
588
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
589
|
+
|
590
|
+
// Since we aren't going to enumerate tearoff names and the prototype
|
591
|
+
// handles non-mutated members, we can do this potential short-circuit.
|
592
|
+
if(!wrapper->HasMutatedSet())
|
593
|
+
return JS_TRUE;
|
594
|
+
|
595
|
+
// Since we might be using this in the helper case, we check to
|
596
|
+
// see if this is all avoidable.
|
597
|
+
|
598
|
+
if(wrapper->GetScriptableInfo() &&
|
599
|
+
wrapper->GetScriptableInfo()->GetFlags().DontEnumStaticProps())
|
600
|
+
return JS_TRUE;
|
601
|
+
|
602
|
+
XPCNativeSet* set = wrapper->GetSet();
|
603
|
+
XPCNativeSet* protoSet = wrapper->HasProto() ?
|
604
|
+
wrapper->GetProto()->GetSet() : nsnull;
|
605
|
+
|
606
|
+
PRUint16 interface_count = set->GetInterfaceCount();
|
607
|
+
XPCNativeInterface** interfaceArray = set->GetInterfaceArray();
|
608
|
+
for(PRUint16 i = 0; i < interface_count; i++)
|
609
|
+
{
|
610
|
+
XPCNativeInterface* iface = interfaceArray[i];
|
611
|
+
#ifdef XPC_IDISPATCH_SUPPORT
|
612
|
+
if(iface->GetIID()->Equals(NSID_IDISPATCH))
|
613
|
+
{
|
614
|
+
XPCIDispatchExtension::Enumerate(ccx, obj, wrapper);
|
615
|
+
continue;
|
616
|
+
}
|
617
|
+
#endif
|
618
|
+
PRUint16 member_count = iface->GetMemberCount();
|
619
|
+
for(PRUint16 k = 0; k < member_count; k++)
|
620
|
+
{
|
621
|
+
XPCNativeMember* member = iface->GetMemberAt(k);
|
622
|
+
jsval name = member->GetName();
|
623
|
+
|
624
|
+
// Skip if this member is going to come from the proto.
|
625
|
+
PRUint16 index;
|
626
|
+
if(protoSet &&
|
627
|
+
protoSet->FindMember(name, nsnull, &index) && index == i)
|
628
|
+
continue;
|
629
|
+
if(!xpc_ForcePropertyResolve(cx, obj, name))
|
630
|
+
return JS_FALSE;
|
631
|
+
}
|
632
|
+
}
|
633
|
+
return JS_TRUE;
|
634
|
+
}
|
635
|
+
|
636
|
+
/***************************************************************************/
|
637
|
+
|
638
|
+
static void
|
639
|
+
XPC_WN_NoHelper_Finalize(JSContext *cx, JSObject *obj)
|
640
|
+
{
|
641
|
+
XPCWrappedNative* p = (XPCWrappedNative*) xpc_GetJSPrivate(obj);
|
642
|
+
if(!p)
|
643
|
+
return;
|
644
|
+
p->FlatJSObjectFinalized(cx);
|
645
|
+
}
|
646
|
+
|
647
|
+
static void
|
648
|
+
TraceScopeJSObjects(JSTracer *trc, XPCWrappedNativeScope* scope)
|
649
|
+
{
|
650
|
+
NS_ASSERTION(scope, "bad scope");
|
651
|
+
|
652
|
+
JSObject* obj;
|
653
|
+
|
654
|
+
obj = scope->GetGlobalJSObject();
|
655
|
+
NS_ASSERTION(obj, "bad scope JSObject");
|
656
|
+
JS_CALL_OBJECT_TRACER(trc, obj, "XPCWrappedNativeScope::mGlobalJSObject");
|
657
|
+
|
658
|
+
obj = scope->GetPrototypeJSObject();
|
659
|
+
if(obj)
|
660
|
+
{
|
661
|
+
JS_CALL_OBJECT_TRACER(trc, obj,
|
662
|
+
"XPCWrappedNativeScope::mPrototypeJSObject");
|
663
|
+
}
|
664
|
+
|
665
|
+
obj = scope->GetPrototypeJSFunction();
|
666
|
+
if(obj)
|
667
|
+
{
|
668
|
+
JS_CALL_OBJECT_TRACER(trc, obj,
|
669
|
+
"XPCWrappedNativeScope::mPrototypeJSFunction");
|
670
|
+
}
|
671
|
+
}
|
672
|
+
|
673
|
+
void
|
674
|
+
xpc_TraceForValidWrapper(JSTracer *trc, XPCWrappedNative* wrapper)
|
675
|
+
{
|
676
|
+
// NOTE: It might be nice to also do the wrapper->Mark() call here too
|
677
|
+
// when we are called during the marking phase of JS GC to mark the
|
678
|
+
// wrapper's and wrapper's proto's interface sets.
|
679
|
+
//
|
680
|
+
// We currently do that in the GC callback code. The reason we don't do that
|
681
|
+
// here is because the bits used in that marking do unpleasant things to the
|
682
|
+
// member counts in the interface and interface set objects. Those counts
|
683
|
+
// are used in the DealWithDyingGCThings calls that are part of this JS GC
|
684
|
+
// marking phase. By doing these calls later during our GC callback we
|
685
|
+
// avoid that problem. Arguably this could be changed. But it ain't broke.
|
686
|
+
//
|
687
|
+
// However, we do need to call the wrapper's TraceJS so that
|
688
|
+
// it can be sure that its (potentially shared) JSClass is traced. The
|
689
|
+
// danger is that a live wrapper might not be in a wrapper map and thus
|
690
|
+
// won't be fully marked in the GC callback. This can happen if there is
|
691
|
+
// a security exception during wrapper creation or if during wrapper
|
692
|
+
// creation it is determined that the wrapper is not needed. In those cases
|
693
|
+
// the wrapper can never actually be used from JS code - so resources like
|
694
|
+
// the interface set will never be accessed. But the JS engine will still
|
695
|
+
// need to use the JSClass. So, some marking is required for protection.
|
696
|
+
|
697
|
+
wrapper->TraceJS(trc);
|
698
|
+
|
699
|
+
TraceScopeJSObjects(trc, wrapper->GetScope());
|
700
|
+
}
|
701
|
+
|
702
|
+
static void
|
703
|
+
XPC_WN_Shared_Trace(JSTracer *trc, JSObject *obj)
|
704
|
+
{
|
705
|
+
XPCWrappedNative* wrapper =
|
706
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(trc->context, obj);
|
707
|
+
|
708
|
+
if(wrapper && wrapper->IsValid())
|
709
|
+
xpc_TraceForValidWrapper(trc, wrapper);
|
710
|
+
}
|
711
|
+
|
712
|
+
static JSBool
|
713
|
+
XPC_WN_NoHelper_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
714
|
+
{
|
715
|
+
CHECK_IDVAL(cx, idval);
|
716
|
+
|
717
|
+
XPCCallContext ccx(JS_CALLER, cx, obj, nsnull, idval);
|
718
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
719
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
720
|
+
|
721
|
+
XPCNativeSet* set = ccx.GetSet();
|
722
|
+
if(!set)
|
723
|
+
return JS_TRUE;
|
724
|
+
|
725
|
+
// Don't resolve properties that are on our prototype.
|
726
|
+
if(ccx.GetInterface() && !ccx.GetStaticMemberIsLocal())
|
727
|
+
return JS_TRUE;
|
728
|
+
|
729
|
+
return DefinePropertyIfFound(ccx, obj, idval,
|
730
|
+
set, nsnull, nsnull, wrapper->GetScope(),
|
731
|
+
JS_TRUE, wrapper, wrapper, nsnull,
|
732
|
+
JSPROP_ENUMERATE |
|
733
|
+
JSPROP_READONLY |
|
734
|
+
JSPROP_PERMANENT, nsnull);
|
735
|
+
}
|
736
|
+
|
737
|
+
nsISupports *
|
738
|
+
XPC_GetIdentityObject(JSContext *cx, JSObject *obj)
|
739
|
+
{
|
740
|
+
XPCWrappedNative *wrapper;
|
741
|
+
|
742
|
+
if(XPCNativeWrapper::IsNativeWrapper(obj))
|
743
|
+
// Note: It's okay to use SafeGetWrappedNative here since we only do
|
744
|
+
// identity checking on the returned object.
|
745
|
+
wrapper = XPCNativeWrapper::SafeGetWrappedNative(obj);
|
746
|
+
else
|
747
|
+
wrapper = XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
|
748
|
+
|
749
|
+
if(!wrapper) {
|
750
|
+
JSObject *unsafeObj = XPC_SJOW_GetUnsafeObject(obj);
|
751
|
+
if(unsafeObj)
|
752
|
+
return XPC_GetIdentityObject(cx, unsafeObj);
|
753
|
+
|
754
|
+
return nsnull;
|
755
|
+
}
|
756
|
+
|
757
|
+
return wrapper->GetIdentityObject();
|
758
|
+
}
|
759
|
+
|
760
|
+
static JSBool
|
761
|
+
XPC_WN_Equality(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
762
|
+
{
|
763
|
+
*bp = JS_FALSE;
|
764
|
+
|
765
|
+
XPCWrappedNative *wrapper =
|
766
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
|
767
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
768
|
+
|
769
|
+
XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
|
770
|
+
if(si && si->GetFlags().WantEquality())
|
771
|
+
{
|
772
|
+
nsresult rv = si->GetCallback()->Equality(wrapper, cx, obj, v, bp);
|
773
|
+
if(NS_FAILED(rv))
|
774
|
+
return Throw(rv, cx);
|
775
|
+
|
776
|
+
if(!*bp && !JSVAL_IS_PRIMITIVE(v) &&
|
777
|
+
IsXPCSafeJSObjectWrapperClass(STOBJ_GET_CLASS(JSVAL_TO_OBJECT(v))))
|
778
|
+
{
|
779
|
+
v = OBJECT_TO_JSVAL(XPC_SJOW_GetUnsafeObject(JSVAL_TO_OBJECT(v)));
|
780
|
+
|
781
|
+
rv = si->GetCallback()->Equality(wrapper, cx, obj, v, bp);
|
782
|
+
if(NS_FAILED(rv))
|
783
|
+
return Throw(rv, cx);
|
784
|
+
}
|
785
|
+
}
|
786
|
+
else if(!JSVAL_IS_PRIMITIVE(v))
|
787
|
+
{
|
788
|
+
JSObject *other = JSVAL_TO_OBJECT(v);
|
789
|
+
|
790
|
+
*bp = (obj == other ||
|
791
|
+
XPC_GetIdentityObject(cx, obj) ==
|
792
|
+
XPC_GetIdentityObject(cx, other));
|
793
|
+
}
|
794
|
+
|
795
|
+
return JS_TRUE;
|
796
|
+
}
|
797
|
+
|
798
|
+
static JSObject *
|
799
|
+
XPC_WN_OuterObject(JSContext *cx, JSObject *obj)
|
800
|
+
{
|
801
|
+
XPCWrappedNative *wrapper =
|
802
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
|
803
|
+
if(!wrapper)
|
804
|
+
{
|
805
|
+
Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
806
|
+
|
807
|
+
return nsnull;
|
808
|
+
}
|
809
|
+
|
810
|
+
if(!wrapper->IsValid())
|
811
|
+
{
|
812
|
+
Throw(NS_ERROR_XPC_HAS_BEEN_SHUTDOWN, cx);
|
813
|
+
|
814
|
+
return nsnull;
|
815
|
+
}
|
816
|
+
|
817
|
+
XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
|
818
|
+
if(si && si->GetFlags().WantOuterObject())
|
819
|
+
{
|
820
|
+
JSObject *newThis;
|
821
|
+
nsresult rv =
|
822
|
+
si->GetCallback()->OuterObject(wrapper, cx, obj, &newThis);
|
823
|
+
|
824
|
+
if(NS_FAILED(rv))
|
825
|
+
{
|
826
|
+
Throw(rv, cx);
|
827
|
+
|
828
|
+
return nsnull;
|
829
|
+
}
|
830
|
+
|
831
|
+
obj = newThis;
|
832
|
+
}
|
833
|
+
|
834
|
+
return obj;
|
835
|
+
}
|
836
|
+
|
837
|
+
static JSObject *
|
838
|
+
XPC_WN_InnerObject(JSContext *cx, JSObject *obj)
|
839
|
+
{
|
840
|
+
XPCWrappedNative *wrapper =
|
841
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
|
842
|
+
if(!wrapper)
|
843
|
+
{
|
844
|
+
Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
845
|
+
|
846
|
+
return nsnull;
|
847
|
+
}
|
848
|
+
|
849
|
+
if(!wrapper->IsValid())
|
850
|
+
{
|
851
|
+
Throw(NS_ERROR_XPC_HAS_BEEN_SHUTDOWN, cx);
|
852
|
+
|
853
|
+
return nsnull;
|
854
|
+
}
|
855
|
+
|
856
|
+
XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
|
857
|
+
if(si && si->GetFlags().WantInnerObject())
|
858
|
+
{
|
859
|
+
JSObject *newThis;
|
860
|
+
nsresult rv =
|
861
|
+
si->GetCallback()->InnerObject(wrapper, cx, obj, &newThis);
|
862
|
+
|
863
|
+
if(NS_FAILED(rv))
|
864
|
+
{
|
865
|
+
Throw(rv, cx);
|
866
|
+
|
867
|
+
return nsnull;
|
868
|
+
}
|
869
|
+
|
870
|
+
obj = newThis;
|
871
|
+
}
|
872
|
+
|
873
|
+
return obj;
|
874
|
+
}
|
875
|
+
|
876
|
+
JSExtendedClass XPC_WN_NoHelper_JSClass = {
|
877
|
+
{
|
878
|
+
"XPCWrappedNative_NoHelper", // name;
|
879
|
+
JSCLASS_HAS_PRIVATE |
|
880
|
+
JSCLASS_PRIVATE_IS_NSISUPPORTS |
|
881
|
+
JSCLASS_MARK_IS_TRACE |
|
882
|
+
JSCLASS_IS_EXTENDED, // flags;
|
883
|
+
|
884
|
+
/* Mandatory non-null function pointer members. */
|
885
|
+
XPC_WN_OnlyIWrite_PropertyStub, // addProperty;
|
886
|
+
XPC_WN_CannotModifyPropertyStub,// delProperty;
|
887
|
+
JS_PropertyStub, // getProperty;
|
888
|
+
XPC_WN_OnlyIWrite_PropertyStub, // setProperty;
|
889
|
+
|
890
|
+
XPC_WN_Shared_Enumerate, // enumerate;
|
891
|
+
XPC_WN_NoHelper_Resolve, // resolve;
|
892
|
+
XPC_WN_Shared_Convert, // convert;
|
893
|
+
XPC_WN_NoHelper_Finalize, // finalize;
|
894
|
+
|
895
|
+
/* Optionally non-null members start here. */
|
896
|
+
XPC_WN_GetObjectOpsNoCall, // getObjectOps;
|
897
|
+
nsnull, // checkAccess;
|
898
|
+
nsnull, // call;
|
899
|
+
nsnull, // construct;
|
900
|
+
nsnull, // xdrObject;
|
901
|
+
nsnull, // hasInstance;
|
902
|
+
JS_CLASS_TRACE(XPC_WN_Shared_Trace), // mark/trace;
|
903
|
+
nsnull // spare;
|
904
|
+
},
|
905
|
+
XPC_WN_Equality,
|
906
|
+
XPC_WN_OuterObject,
|
907
|
+
XPC_WN_InnerObject,
|
908
|
+
nsnull,nsnull,nsnull,nsnull,nsnull
|
909
|
+
};
|
910
|
+
|
911
|
+
|
912
|
+
/***************************************************************************/
|
913
|
+
|
914
|
+
static JSBool
|
915
|
+
XPC_WN_MaybeResolvingPropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
916
|
+
{
|
917
|
+
CHECK_IDVAL(cx, idval);
|
918
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
919
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
920
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
921
|
+
|
922
|
+
if(ccx.GetResolvingWrapper() == wrapper)
|
923
|
+
return JS_TRUE;
|
924
|
+
return Throw(NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN, cx);
|
925
|
+
}
|
926
|
+
|
927
|
+
// macro fun!
|
928
|
+
#define PRE_HELPER_STUB \
|
929
|
+
XPCWrappedNative* wrapper = \
|
930
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj); \
|
931
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper); \
|
932
|
+
PRBool retval = JS_TRUE; \
|
933
|
+
nsresult rv = wrapper->GetScriptableCallback()->
|
934
|
+
|
935
|
+
#define POST_HELPER_STUB \
|
936
|
+
if(NS_FAILED(rv)) \
|
937
|
+
return Throw(rv, cx); \
|
938
|
+
return retval;
|
939
|
+
|
940
|
+
static JSBool
|
941
|
+
XPC_WN_Helper_AddProperty(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
942
|
+
{
|
943
|
+
PRE_HELPER_STUB
|
944
|
+
AddProperty(wrapper, cx, obj, idval, vp, &retval);
|
945
|
+
POST_HELPER_STUB
|
946
|
+
}
|
947
|
+
|
948
|
+
static JSBool
|
949
|
+
XPC_WN_Helper_DelProperty(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
950
|
+
{
|
951
|
+
PRE_HELPER_STUB
|
952
|
+
DelProperty(wrapper, cx, obj, idval, vp, &retval);
|
953
|
+
POST_HELPER_STUB
|
954
|
+
}
|
955
|
+
|
956
|
+
static JSBool
|
957
|
+
XPC_WN_Helper_GetProperty(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
958
|
+
{
|
959
|
+
PRE_HELPER_STUB
|
960
|
+
GetProperty(wrapper, cx, obj, idval, vp, &retval);
|
961
|
+
POST_HELPER_STUB
|
962
|
+
}
|
963
|
+
|
964
|
+
static JSBool
|
965
|
+
XPC_WN_Helper_SetProperty(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
966
|
+
{
|
967
|
+
PRE_HELPER_STUB
|
968
|
+
SetProperty(wrapper, cx, obj, idval, vp, &retval);
|
969
|
+
POST_HELPER_STUB
|
970
|
+
}
|
971
|
+
|
972
|
+
static JSBool
|
973
|
+
XPC_WN_Helper_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
974
|
+
{
|
975
|
+
PRE_HELPER_STUB
|
976
|
+
Convert(wrapper, cx, obj, type, vp, &retval);
|
977
|
+
POST_HELPER_STUB
|
978
|
+
}
|
979
|
+
|
980
|
+
static JSBool
|
981
|
+
XPC_WN_Helper_CheckAccess(JSContext *cx, JSObject *obj, jsval idval,
|
982
|
+
JSAccessMode mode, jsval *vp)
|
983
|
+
{
|
984
|
+
CHECK_IDVAL(cx, idval);
|
985
|
+
PRE_HELPER_STUB
|
986
|
+
CheckAccess(wrapper, cx, obj, idval, mode, vp, &retval);
|
987
|
+
POST_HELPER_STUB
|
988
|
+
}
|
989
|
+
|
990
|
+
static JSBool
|
991
|
+
XPC_WN_Helper_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
992
|
+
jsval *rval)
|
993
|
+
{
|
994
|
+
// this is a hack to get the obj of the actual object not the object
|
995
|
+
// that JS thinks is the 'this' (which it passes as 'obj').
|
996
|
+
if(!(obj = (JSObject*)argv[-2]))
|
997
|
+
return JS_FALSE;
|
998
|
+
|
999
|
+
PRE_HELPER_STUB
|
1000
|
+
Call(wrapper, cx, obj, argc, argv, rval, &retval);
|
1001
|
+
POST_HELPER_STUB
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
static JSBool
|
1005
|
+
XPC_WN_Helper_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
1006
|
+
jsval *rval)
|
1007
|
+
{
|
1008
|
+
// this is a hack to get the obj of the actual object not the object
|
1009
|
+
// that JS thinks is the 'this' (which it passes as 'obj').
|
1010
|
+
if(!(obj = (JSObject*)argv[-2]))
|
1011
|
+
return JS_FALSE;
|
1012
|
+
|
1013
|
+
PRE_HELPER_STUB
|
1014
|
+
Construct(wrapper, cx, obj, argc, argv, rval, &retval);
|
1015
|
+
POST_HELPER_STUB
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
static JSBool
|
1019
|
+
XPC_WN_Helper_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
|
1020
|
+
{
|
1021
|
+
PRE_HELPER_STUB
|
1022
|
+
HasInstance(wrapper, cx, obj, v, bp, &retval);
|
1023
|
+
POST_HELPER_STUB
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
static void
|
1027
|
+
XPC_WN_Helper_Finalize(JSContext *cx, JSObject *obj)
|
1028
|
+
{
|
1029
|
+
XPCWrappedNative* wrapper = (XPCWrappedNative*) xpc_GetJSPrivate(obj);
|
1030
|
+
if(!wrapper)
|
1031
|
+
return;
|
1032
|
+
wrapper->GetScriptableCallback()->Finalize(wrapper, cx, obj);
|
1033
|
+
wrapper->FlatJSObjectFinalized(cx);
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
static void
|
1037
|
+
XPC_WN_Helper_Trace(JSTracer *trc, JSObject *obj)
|
1038
|
+
{
|
1039
|
+
XPCWrappedNative* wrapper =
|
1040
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(trc->context, obj);
|
1041
|
+
if(wrapper && wrapper->IsValid())
|
1042
|
+
{
|
1043
|
+
wrapper->GetScriptableCallback()->Trace(wrapper, trc, obj);
|
1044
|
+
xpc_TraceForValidWrapper(trc, wrapper);
|
1045
|
+
}
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
static JSBool
|
1049
|
+
XPC_WN_Helper_NewResolve(JSContext *cx, JSObject *obj, jsval idval, uintN flags,
|
1050
|
+
JSObject **objp)
|
1051
|
+
{
|
1052
|
+
CHECK_IDVAL(cx, idval);
|
1053
|
+
|
1054
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
1055
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
1056
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
1057
|
+
|
1058
|
+
jsval old = ccx.SetResolveName(idval);
|
1059
|
+
|
1060
|
+
nsresult rv = NS_OK;
|
1061
|
+
JSBool retval = JS_TRUE;
|
1062
|
+
JSObject* obj2FromScriptable = nsnull;
|
1063
|
+
|
1064
|
+
XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
|
1065
|
+
if(si && si->GetFlags().WantNewResolve())
|
1066
|
+
{
|
1067
|
+
XPCWrappedNative* oldResolvingWrapper;
|
1068
|
+
JSBool allowPropMods = si->GetFlags().AllowPropModsDuringResolve();
|
1069
|
+
|
1070
|
+
if(allowPropMods)
|
1071
|
+
oldResolvingWrapper = ccx.SetResolvingWrapper(wrapper);
|
1072
|
+
|
1073
|
+
rv = si->GetCallback()->NewResolve(wrapper, cx, obj, idval, flags,
|
1074
|
+
&obj2FromScriptable, &retval);
|
1075
|
+
|
1076
|
+
if(allowPropMods)
|
1077
|
+
(void)ccx.SetResolvingWrapper(oldResolvingWrapper);
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
old = ccx.SetResolveName(old);
|
1081
|
+
NS_ASSERTION(old == idval, "bad nest");
|
1082
|
+
|
1083
|
+
if(NS_FAILED(rv))
|
1084
|
+
{
|
1085
|
+
return Throw(rv, cx);
|
1086
|
+
}
|
1087
|
+
|
1088
|
+
if(obj2FromScriptable)
|
1089
|
+
{
|
1090
|
+
*objp = obj2FromScriptable;
|
1091
|
+
}
|
1092
|
+
else if(wrapper->HasMutatedSet())
|
1093
|
+
{
|
1094
|
+
// We are here if scriptable did not resolve this property and
|
1095
|
+
// it *might* be in the instance set but not the proto set.
|
1096
|
+
|
1097
|
+
XPCNativeSet* set = wrapper->GetSet();
|
1098
|
+
XPCNativeSet* protoSet = wrapper->HasProto() ?
|
1099
|
+
wrapper->GetProto()->GetSet() : nsnull;
|
1100
|
+
XPCNativeMember* member;
|
1101
|
+
XPCNativeInterface* iface;
|
1102
|
+
JSBool IsLocal;
|
1103
|
+
|
1104
|
+
if(set->FindMember(idval, &member, &iface, protoSet, &IsLocal) &&
|
1105
|
+
IsLocal)
|
1106
|
+
{
|
1107
|
+
XPCWrappedNative* oldResolvingWrapper;
|
1108
|
+
|
1109
|
+
XPCNativeScriptableFlags siFlags(0);
|
1110
|
+
if(si)
|
1111
|
+
siFlags = si->GetFlags();
|
1112
|
+
|
1113
|
+
uintN enumFlag =
|
1114
|
+
siFlags.DontEnumStaticProps() ? 0 : JSPROP_ENUMERATE;
|
1115
|
+
|
1116
|
+
XPCWrappedNative* wrapperForInterfaceNames =
|
1117
|
+
siFlags.DontReflectInterfaceNames() ? nsnull : wrapper;
|
1118
|
+
|
1119
|
+
JSBool resolved;
|
1120
|
+
oldResolvingWrapper = ccx.SetResolvingWrapper(wrapper);
|
1121
|
+
retval = DefinePropertyIfFound(ccx, obj, idval,
|
1122
|
+
set, iface, member,
|
1123
|
+
wrapper->GetScope(),
|
1124
|
+
JS_FALSE,
|
1125
|
+
wrapperForInterfaceNames,
|
1126
|
+
nsnull, si,
|
1127
|
+
enumFlag, &resolved);
|
1128
|
+
(void)ccx.SetResolvingWrapper(oldResolvingWrapper);
|
1129
|
+
if(retval && resolved)
|
1130
|
+
*objp = obj;
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
return retval;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
/***************************************************************************/
|
1138
|
+
|
1139
|
+
extern "C" JS_IMPORT_DATA(JSObjectOps) js_ObjectOps;
|
1140
|
+
|
1141
|
+
static JSObjectOps XPC_WN_WithCall_JSOps;
|
1142
|
+
static JSObjectOps XPC_WN_NoCall_JSOps;
|
1143
|
+
|
1144
|
+
/*
|
1145
|
+
Here are the enumerator cases:
|
1146
|
+
|
1147
|
+
set jsclass enumerate to stub (unless noted otherwise)
|
1148
|
+
|
1149
|
+
if( helper wants new enumerate )
|
1150
|
+
if( DONT_ENUM_STATICS )
|
1151
|
+
forward to scriptable enumerate
|
1152
|
+
else
|
1153
|
+
if( set not mutated )
|
1154
|
+
forward to scriptable enumerate
|
1155
|
+
else
|
1156
|
+
call shared enumerate
|
1157
|
+
forward to scriptable enumerate
|
1158
|
+
else if( helper wants old enumerate )
|
1159
|
+
use this JSOp
|
1160
|
+
if( DONT_ENUM_STATICS )
|
1161
|
+
call scriptable enumerate
|
1162
|
+
call stub
|
1163
|
+
else
|
1164
|
+
if( set not mutated )
|
1165
|
+
call scriptable enumerate
|
1166
|
+
call stub
|
1167
|
+
else
|
1168
|
+
call shared enumerate
|
1169
|
+
call scriptable enumerate
|
1170
|
+
call stub
|
1171
|
+
|
1172
|
+
else //... if( helper wants NO enumerate )
|
1173
|
+
if( DONT_ENUM_STATICS )
|
1174
|
+
use enumerate stub - don't use this JSOp thing at all
|
1175
|
+
else
|
1176
|
+
do shared enumerate - don't use this JSOp thing at all
|
1177
|
+
*/
|
1178
|
+
|
1179
|
+
static JSBool
|
1180
|
+
XPC_WN_JSOp_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
|
1181
|
+
jsval *statep, jsid *idp)
|
1182
|
+
{
|
1183
|
+
JSClass *clazz = STOBJ_GET_CLASS(obj);
|
1184
|
+
if(!IS_WRAPPER_CLASS(clazz) || clazz == &XPC_WN_NoHelper_JSClass.base)
|
1185
|
+
{
|
1186
|
+
// obj must be a prototype object or a wrapper w/o a
|
1187
|
+
// helper. Short circuit this call to
|
1188
|
+
// js_ObjectOps.enumerate().
|
1189
|
+
|
1190
|
+
return js_ObjectOps.enumerate(cx, obj, enum_op, statep, idp);
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
1194
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
1195
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
1196
|
+
|
1197
|
+
XPCNativeScriptableInfo* si = wrapper->GetScriptableInfo();
|
1198
|
+
if(!si)
|
1199
|
+
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
1200
|
+
|
1201
|
+
PRBool retval = JS_TRUE;
|
1202
|
+
nsresult rv;
|
1203
|
+
|
1204
|
+
if(si->GetFlags().WantNewEnumerate())
|
1205
|
+
{
|
1206
|
+
if(enum_op == JSENUMERATE_INIT &&
|
1207
|
+
!si->GetFlags().DontEnumStaticProps() &&
|
1208
|
+
wrapper->HasMutatedSet() &&
|
1209
|
+
!XPC_WN_Shared_Enumerate(cx, obj))
|
1210
|
+
{
|
1211
|
+
*statep = JSVAL_NULL;
|
1212
|
+
return JS_FALSE;
|
1213
|
+
}
|
1214
|
+
|
1215
|
+
// XXX Might we really need to wrap this call and *also* call
|
1216
|
+
// js_ObjectOps.enumerate ???
|
1217
|
+
|
1218
|
+
rv = si->GetCallback()->
|
1219
|
+
NewEnumerate(wrapper, cx, obj, enum_op, statep, idp, &retval);
|
1220
|
+
|
1221
|
+
if(enum_op == JSENUMERATE_INIT && (NS_FAILED(rv) || !retval))
|
1222
|
+
*statep = JSVAL_NULL;
|
1223
|
+
|
1224
|
+
if(NS_FAILED(rv))
|
1225
|
+
return Throw(rv, cx);
|
1226
|
+
return retval;
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
if(si->GetFlags().WantEnumerate())
|
1230
|
+
{
|
1231
|
+
if(enum_op == JSENUMERATE_INIT)
|
1232
|
+
{
|
1233
|
+
if(!si->GetFlags().DontEnumStaticProps() &&
|
1234
|
+
wrapper->HasMutatedSet() &&
|
1235
|
+
!XPC_WN_Shared_Enumerate(cx, obj))
|
1236
|
+
{
|
1237
|
+
*statep = JSVAL_NULL;
|
1238
|
+
return JS_FALSE;
|
1239
|
+
}
|
1240
|
+
rv = si->GetCallback()->
|
1241
|
+
Enumerate(wrapper, cx, obj, &retval);
|
1242
|
+
|
1243
|
+
if(NS_FAILED(rv) || !retval)
|
1244
|
+
*statep = JSVAL_NULL;
|
1245
|
+
|
1246
|
+
if(NS_FAILED(rv))
|
1247
|
+
return Throw(rv, cx);
|
1248
|
+
if(!retval)
|
1249
|
+
return JS_FALSE;
|
1250
|
+
// Then fall through and call js_ObjectOps.enumerate...
|
1251
|
+
}
|
1252
|
+
}
|
1253
|
+
|
1254
|
+
// else call js_ObjectOps.enumerate...
|
1255
|
+
|
1256
|
+
return js_ObjectOps.enumerate(cx, obj, enum_op, statep, idp);
|
1257
|
+
}
|
1258
|
+
|
1259
|
+
static void
|
1260
|
+
XPC_WN_JSOp_Clear(JSContext *cx, JSObject *obj)
|
1261
|
+
{
|
1262
|
+
// We're likely to enter this JSOp with a wrapper prototype
|
1263
|
+
// object. In that case we won't find a wrapper, so we'll just
|
1264
|
+
// call into js_ObjectOps.clear(), which is exactly what we want.
|
1265
|
+
|
1266
|
+
// If our scope is cleared, make sure we clear the scope of our
|
1267
|
+
// native wrapper as well.
|
1268
|
+
XPCWrappedNative *wrapper =
|
1269
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, obj);
|
1270
|
+
|
1271
|
+
if(wrapper && wrapper->IsValid())
|
1272
|
+
{
|
1273
|
+
XPCNativeWrapper::ClearWrappedNativeScopes(cx, wrapper);
|
1274
|
+
|
1275
|
+
nsXPConnect* xpc = nsXPConnect::GetXPConnect();
|
1276
|
+
xpc->UpdateXOWs(cx, wrapper, nsIXPConnect::XPC_XOW_CLEARSCOPE);
|
1277
|
+
}
|
1278
|
+
|
1279
|
+
js_ObjectOps.clear(cx, obj);
|
1280
|
+
}
|
1281
|
+
|
1282
|
+
namespace {
|
1283
|
+
|
1284
|
+
NS_STACK_CLASS class AutoPopJSContext
|
1285
|
+
{
|
1286
|
+
public:
|
1287
|
+
AutoPopJSContext(XPCJSContextStack *stack)
|
1288
|
+
: mCx(nsnull), mStack(stack)
|
1289
|
+
{
|
1290
|
+
NS_ASSERTION(stack, "Null stack!");
|
1291
|
+
}
|
1292
|
+
|
1293
|
+
~AutoPopJSContext()
|
1294
|
+
{
|
1295
|
+
if(mCx)
|
1296
|
+
mStack->Pop(nsnull);
|
1297
|
+
}
|
1298
|
+
|
1299
|
+
void PushIfNotTop(JSContext *cx)
|
1300
|
+
{
|
1301
|
+
NS_ASSERTION(cx, "Null context!");
|
1302
|
+
NS_ASSERTION(!mCx, "This class is only meant to be used once!");
|
1303
|
+
|
1304
|
+
JSContext *cxTop = nsnull;
|
1305
|
+
mStack->Peek(&cxTop);
|
1306
|
+
|
1307
|
+
if(cxTop != cx && NS_SUCCEEDED(mStack->Push(cx)))
|
1308
|
+
mCx = cx;
|
1309
|
+
}
|
1310
|
+
|
1311
|
+
private:
|
1312
|
+
JSContext *mCx;
|
1313
|
+
XPCJSContextStack *mStack;
|
1314
|
+
};
|
1315
|
+
|
1316
|
+
} // namespace
|
1317
|
+
|
1318
|
+
static JSObject*
|
1319
|
+
XPC_WN_JSOp_ThisObject(JSContext *cx, JSObject *obj)
|
1320
|
+
{
|
1321
|
+
// None of the wrappers we could potentially hand out are threadsafe so
|
1322
|
+
// just hand out the given object.
|
1323
|
+
if(!XPCPerThreadData::IsMainThread(cx))
|
1324
|
+
return obj;
|
1325
|
+
|
1326
|
+
OBJ_TO_OUTER_OBJECT(cx, obj);
|
1327
|
+
if(!obj)
|
1328
|
+
return nsnull;
|
1329
|
+
|
1330
|
+
JSObject *scope = JS_GetScopeChain(cx);
|
1331
|
+
if(!scope)
|
1332
|
+
{
|
1333
|
+
XPCThrower::Throw(NS_ERROR_FAILURE, cx);
|
1334
|
+
return nsnull;
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
scope = JS_GetGlobalForObject(cx, scope);
|
1338
|
+
|
1339
|
+
XPCPerThreadData *threadData = XPCPerThreadData::GetData(cx);
|
1340
|
+
if(!threadData)
|
1341
|
+
{
|
1342
|
+
XPCThrower::Throw(NS_ERROR_FAILURE, cx);
|
1343
|
+
return nsnull;
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
AutoPopJSContext popper(threadData->GetJSContextStack());
|
1347
|
+
popper.PushIfNotTop(cx);
|
1348
|
+
|
1349
|
+
nsIScriptSecurityManager* secMan = XPCWrapper::GetSecurityManager();
|
1350
|
+
if(!secMan)
|
1351
|
+
{
|
1352
|
+
XPCThrower::Throw(NS_ERROR_FAILURE, cx);
|
1353
|
+
return nsnull;
|
1354
|
+
}
|
1355
|
+
|
1356
|
+
JSStackFrame *fp;
|
1357
|
+
nsIPrincipal *principal = secMan->GetCxSubjectPrincipalAndFrame(cx, &fp);
|
1358
|
+
|
1359
|
+
jsval retval = OBJECT_TO_JSVAL(obj);
|
1360
|
+
JSAutoTempValueRooter atvr(cx, 1, &retval);
|
1361
|
+
|
1362
|
+
if(principal && fp)
|
1363
|
+
{
|
1364
|
+
JSScript* script = JS_GetFrameScript(cx, fp);
|
1365
|
+
|
1366
|
+
PRUint32 flags = script ? JS_GetScriptFilenameFlags(script) : 0;
|
1367
|
+
NS_ASSERTION(flags != JSFILENAME_NULL, "Null filename!");
|
1368
|
+
|
1369
|
+
nsXPConnect *xpc = nsXPConnect::GetXPConnect();
|
1370
|
+
if(!xpc)
|
1371
|
+
{
|
1372
|
+
XPCThrower::Throw(NS_ERROR_FAILURE, cx);
|
1373
|
+
return nsnull;
|
1374
|
+
}
|
1375
|
+
|
1376
|
+
nsresult rv = xpc->GetWrapperForObject(cx, obj, scope, principal, flags,
|
1377
|
+
&retval);
|
1378
|
+
if(NS_FAILED(rv))
|
1379
|
+
{
|
1380
|
+
XPCThrower::Throw(rv, cx);
|
1381
|
+
return nsnull;
|
1382
|
+
}
|
1383
|
+
}
|
1384
|
+
|
1385
|
+
return JSVAL_TO_OBJECT(retval);
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
JSObjectOps *
|
1389
|
+
XPC_WN_GetObjectOpsNoCall(JSContext *cx, JSClass *clazz)
|
1390
|
+
{
|
1391
|
+
return &XPC_WN_NoCall_JSOps;
|
1392
|
+
}
|
1393
|
+
|
1394
|
+
JSObjectOps *
|
1395
|
+
XPC_WN_GetObjectOpsWithCall(JSContext *cx, JSClass *clazz)
|
1396
|
+
{
|
1397
|
+
return &XPC_WN_WithCall_JSOps;
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
JSBool xpc_InitWrappedNativeJSOps()
|
1401
|
+
{
|
1402
|
+
if(!XPC_WN_NoCall_JSOps.lookupProperty)
|
1403
|
+
{
|
1404
|
+
memcpy(&XPC_WN_NoCall_JSOps, &js_ObjectOps, sizeof(JSObjectOps));
|
1405
|
+
XPC_WN_NoCall_JSOps.enumerate = XPC_WN_JSOp_Enumerate;
|
1406
|
+
XPC_WN_NoCall_JSOps.call = nsnull;
|
1407
|
+
XPC_WN_NoCall_JSOps.construct = nsnull;
|
1408
|
+
XPC_WN_NoCall_JSOps.clear = XPC_WN_JSOp_Clear;
|
1409
|
+
XPC_WN_NoCall_JSOps.thisObject = XPC_WN_JSOp_ThisObject;
|
1410
|
+
|
1411
|
+
memcpy(&XPC_WN_WithCall_JSOps, &js_ObjectOps, sizeof(JSObjectOps));
|
1412
|
+
XPC_WN_WithCall_JSOps.enumerate = XPC_WN_JSOp_Enumerate;
|
1413
|
+
XPC_WN_WithCall_JSOps.clear = XPC_WN_JSOp_Clear;
|
1414
|
+
XPC_WN_WithCall_JSOps.thisObject = XPC_WN_JSOp_ThisObject;
|
1415
|
+
}
|
1416
|
+
return JS_TRUE;
|
1417
|
+
}
|
1418
|
+
|
1419
|
+
/***************************************************************************/
|
1420
|
+
|
1421
|
+
// static
|
1422
|
+
XPCNativeScriptableInfo*
|
1423
|
+
XPCNativeScriptableInfo::Construct(XPCCallContext& ccx,
|
1424
|
+
JSBool isGlobal,
|
1425
|
+
const XPCNativeScriptableCreateInfo* sci)
|
1426
|
+
{
|
1427
|
+
NS_ASSERTION(sci, "bad param");
|
1428
|
+
NS_ASSERTION(sci->GetCallback(), "bad param");
|
1429
|
+
|
1430
|
+
XPCNativeScriptableInfo* newObj =
|
1431
|
+
new XPCNativeScriptableInfo(sci->GetCallback());
|
1432
|
+
if(!newObj)
|
1433
|
+
return nsnull;
|
1434
|
+
|
1435
|
+
char* name = nsnull;
|
1436
|
+
if(NS_FAILED(sci->GetCallback()->GetClassName(&name)) || !name)
|
1437
|
+
{
|
1438
|
+
delete newObj;
|
1439
|
+
return nsnull;
|
1440
|
+
}
|
1441
|
+
|
1442
|
+
JSBool success;
|
1443
|
+
|
1444
|
+
XPCJSRuntime* rt = ccx.GetRuntime();
|
1445
|
+
XPCNativeScriptableSharedMap* map = rt->GetNativeScriptableSharedMap();
|
1446
|
+
{ // scoped lock
|
1447
|
+
XPCAutoLock lock(rt->GetMapLock());
|
1448
|
+
success = map->GetNewOrUsed(sci->GetFlags(), name, isGlobal, newObj);
|
1449
|
+
}
|
1450
|
+
|
1451
|
+
if(!success)
|
1452
|
+
{
|
1453
|
+
delete newObj;
|
1454
|
+
return nsnull;
|
1455
|
+
}
|
1456
|
+
|
1457
|
+
return newObj;
|
1458
|
+
}
|
1459
|
+
|
1460
|
+
void
|
1461
|
+
XPCNativeScriptableShared::PopulateJSClass(JSBool isGlobal)
|
1462
|
+
{
|
1463
|
+
NS_ASSERTION(mJSClass.base.name, "bad state!");
|
1464
|
+
|
1465
|
+
mJSClass.base.flags = JSCLASS_HAS_PRIVATE |
|
1466
|
+
JSCLASS_PRIVATE_IS_NSISUPPORTS |
|
1467
|
+
JSCLASS_NEW_RESOLVE |
|
1468
|
+
JSCLASS_MARK_IS_TRACE |
|
1469
|
+
JSCLASS_IS_EXTENDED;
|
1470
|
+
|
1471
|
+
if(isGlobal)
|
1472
|
+
mJSClass.base.flags |= JSCLASS_GLOBAL_FLAGS;
|
1473
|
+
|
1474
|
+
if(mFlags.WantAddProperty())
|
1475
|
+
mJSClass.base.addProperty = XPC_WN_Helper_AddProperty;
|
1476
|
+
else if(mFlags.UseJSStubForAddProperty())
|
1477
|
+
mJSClass.base.addProperty = JS_PropertyStub;
|
1478
|
+
else if(mFlags.AllowPropModsDuringResolve())
|
1479
|
+
mJSClass.base.addProperty = XPC_WN_MaybeResolvingPropertyStub;
|
1480
|
+
else
|
1481
|
+
mJSClass.base.addProperty = XPC_WN_CannotModifyPropertyStub;
|
1482
|
+
|
1483
|
+
if(mFlags.WantDelProperty())
|
1484
|
+
mJSClass.base.delProperty = XPC_WN_Helper_DelProperty;
|
1485
|
+
else if(mFlags.UseJSStubForDelProperty())
|
1486
|
+
mJSClass.base.delProperty = JS_PropertyStub;
|
1487
|
+
else if(mFlags.AllowPropModsDuringResolve())
|
1488
|
+
mJSClass.base.delProperty = XPC_WN_MaybeResolvingPropertyStub;
|
1489
|
+
else
|
1490
|
+
mJSClass.base.delProperty = XPC_WN_CannotModifyPropertyStub;
|
1491
|
+
|
1492
|
+
if(mFlags.WantGetProperty())
|
1493
|
+
mJSClass.base.getProperty = XPC_WN_Helper_GetProperty;
|
1494
|
+
else
|
1495
|
+
mJSClass.base.getProperty = JS_PropertyStub;
|
1496
|
+
|
1497
|
+
if(mFlags.WantSetProperty())
|
1498
|
+
mJSClass.base.setProperty = XPC_WN_Helper_SetProperty;
|
1499
|
+
else if(mFlags.UseJSStubForSetProperty())
|
1500
|
+
mJSClass.base.setProperty = JS_PropertyStub;
|
1501
|
+
else if(mFlags.AllowPropModsDuringResolve())
|
1502
|
+
mJSClass.base.setProperty = XPC_WN_MaybeResolvingPropertyStub;
|
1503
|
+
else
|
1504
|
+
mJSClass.base.setProperty = XPC_WN_CannotModifyPropertyStub;
|
1505
|
+
|
1506
|
+
// We figure out most of the enumerate strategy at call time.
|
1507
|
+
|
1508
|
+
if(mFlags.WantNewEnumerate() || mFlags.WantEnumerate() ||
|
1509
|
+
mFlags.DontEnumStaticProps())
|
1510
|
+
mJSClass.base.enumerate = JS_EnumerateStub;
|
1511
|
+
else
|
1512
|
+
mJSClass.base.enumerate = XPC_WN_Shared_Enumerate;
|
1513
|
+
|
1514
|
+
// We have to figure out resolve strategy at call time
|
1515
|
+
mJSClass.base.resolve = (JSResolveOp) XPC_WN_Helper_NewResolve;
|
1516
|
+
|
1517
|
+
if(mFlags.WantConvert())
|
1518
|
+
mJSClass.base.convert = XPC_WN_Helper_Convert;
|
1519
|
+
else
|
1520
|
+
mJSClass.base.convert = XPC_WN_Shared_Convert;
|
1521
|
+
|
1522
|
+
if(mFlags.WantFinalize())
|
1523
|
+
mJSClass.base.finalize = XPC_WN_Helper_Finalize;
|
1524
|
+
else
|
1525
|
+
mJSClass.base.finalize = XPC_WN_NoHelper_Finalize;
|
1526
|
+
|
1527
|
+
// We let the rest default to nsnull unless the helper wants them...
|
1528
|
+
if(mFlags.WantCheckAccess())
|
1529
|
+
mJSClass.base.checkAccess = XPC_WN_Helper_CheckAccess;
|
1530
|
+
|
1531
|
+
// Note that we *must* set
|
1532
|
+
// mJSClass.base.getObjectOps = XPC_WN_GetObjectOpsNoCall
|
1533
|
+
// or
|
1534
|
+
// mJSClass.base.getObjectOps = XPC_WN_GetObjectOpsWithCall
|
1535
|
+
// (even for the cases were it does not do much) because with these
|
1536
|
+
// dynamically generated JSClasses, the code in
|
1537
|
+
// XPCWrappedNative::GetWrappedNativeOfJSObject() needs to look for
|
1538
|
+
// that this callback pointer in order to identify that a given
|
1539
|
+
// JSObject represents a wrapper.
|
1540
|
+
|
1541
|
+
if(mFlags.WantCall() || mFlags.WantConstruct())
|
1542
|
+
{
|
1543
|
+
mJSClass.base.getObjectOps = XPC_WN_GetObjectOpsWithCall;
|
1544
|
+
if(mFlags.WantCall())
|
1545
|
+
mJSClass.base.call = XPC_WN_Helper_Call;
|
1546
|
+
if(mFlags.WantConstruct())
|
1547
|
+
mJSClass.base.construct = XPC_WN_Helper_Construct;
|
1548
|
+
}
|
1549
|
+
else
|
1550
|
+
{
|
1551
|
+
mJSClass.base.getObjectOps = XPC_WN_GetObjectOpsNoCall;
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
if(mFlags.WantHasInstance())
|
1555
|
+
mJSClass.base.hasInstance = XPC_WN_Helper_HasInstance;
|
1556
|
+
|
1557
|
+
if(mFlags.WantTrace())
|
1558
|
+
mJSClass.base.mark = JS_CLASS_TRACE(XPC_WN_Helper_Trace);
|
1559
|
+
else
|
1560
|
+
mJSClass.base.mark = JS_CLASS_TRACE(XPC_WN_Shared_Trace);
|
1561
|
+
|
1562
|
+
// Equality is a required hook.
|
1563
|
+
mJSClass.equality = XPC_WN_Equality;
|
1564
|
+
|
1565
|
+
if(mFlags.WantOuterObject())
|
1566
|
+
mJSClass.outerObject = XPC_WN_OuterObject;
|
1567
|
+
if(mFlags.WantInnerObject())
|
1568
|
+
mJSClass.innerObject = XPC_WN_InnerObject;
|
1569
|
+
}
|
1570
|
+
|
1571
|
+
/***************************************************************************/
|
1572
|
+
/***************************************************************************/
|
1573
|
+
|
1574
|
+
JSBool
|
1575
|
+
XPC_WN_CallMethod(JSContext *cx, JSObject *obj,
|
1576
|
+
uintN argc, jsval *argv, jsval *vp)
|
1577
|
+
{
|
1578
|
+
NS_ASSERTION(JS_TypeOfValue(cx, argv[-2]) == JSTYPE_FUNCTION, "bad function");
|
1579
|
+
JSObject* funobj = JSVAL_TO_OBJECT(argv[-2]);
|
1580
|
+
XPCCallContext ccx(JS_CALLER, cx, obj, funobj, 0, argc, argv, vp);
|
1581
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
1582
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
1583
|
+
|
1584
|
+
XPCNativeInterface* iface;
|
1585
|
+
XPCNativeMember* member;
|
1586
|
+
|
1587
|
+
if(!XPCNativeMember::GetCallInfo(ccx, funobj, &iface, &member))
|
1588
|
+
return Throw(NS_ERROR_XPC_CANT_GET_METHOD_INFO, cx);
|
1589
|
+
ccx.SetCallInfo(iface, member, JS_FALSE);
|
1590
|
+
return XPCWrappedNative::CallMethod(ccx);
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
JSBool
|
1594
|
+
XPC_WN_GetterSetter(JSContext *cx, JSObject *obj,
|
1595
|
+
uintN argc, jsval *argv, jsval *vp)
|
1596
|
+
{
|
1597
|
+
NS_ASSERTION(JS_TypeOfValue(cx, argv[-2]) == JSTYPE_FUNCTION, "bad function");
|
1598
|
+
JSObject* funobj = JSVAL_TO_OBJECT(argv[-2]);
|
1599
|
+
|
1600
|
+
XPCCallContext ccx(JS_CALLER, cx, obj, funobj);
|
1601
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
1602
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
1603
|
+
|
1604
|
+
XPCNativeInterface* iface;
|
1605
|
+
XPCNativeMember* member;
|
1606
|
+
|
1607
|
+
if(!XPCNativeMember::GetCallInfo(ccx, funobj, &iface, &member))
|
1608
|
+
return Throw(NS_ERROR_XPC_CANT_GET_METHOD_INFO, cx);
|
1609
|
+
|
1610
|
+
ccx.SetArgsAndResultPtr(argc, argv, vp);
|
1611
|
+
if(argc && member->IsWritableAttribute())
|
1612
|
+
{
|
1613
|
+
ccx.SetCallInfo(iface, member, JS_TRUE);
|
1614
|
+
JSBool retval = XPCWrappedNative::SetAttribute(ccx);
|
1615
|
+
if(retval && vp)
|
1616
|
+
*vp = argv[0];
|
1617
|
+
return retval;
|
1618
|
+
}
|
1619
|
+
// else...
|
1620
|
+
|
1621
|
+
ccx.SetCallInfo(iface, member, JS_FALSE);
|
1622
|
+
return XPCWrappedNative::GetAttribute(ccx);
|
1623
|
+
}
|
1624
|
+
|
1625
|
+
/***************************************************************************/
|
1626
|
+
|
1627
|
+
static JSBool
|
1628
|
+
XPC_WN_Shared_Proto_Enumerate(JSContext *cx, JSObject *obj)
|
1629
|
+
{
|
1630
|
+
NS_ASSERTION(
|
1631
|
+
JS_InstanceOf(cx, obj, &XPC_WN_ModsAllowed_WithCall_Proto_JSClass,
|
1632
|
+
nsnull) ||
|
1633
|
+
JS_InstanceOf(cx, obj, &XPC_WN_ModsAllowed_NoCall_Proto_JSClass,
|
1634
|
+
nsnull) ||
|
1635
|
+
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_WithCall_Proto_JSClass, nsnull) ||
|
1636
|
+
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_NoCall_Proto_JSClass, nsnull),
|
1637
|
+
"bad proto");
|
1638
|
+
XPCWrappedNativeProto* self =
|
1639
|
+
(XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
|
1640
|
+
if(!self)
|
1641
|
+
return JS_FALSE;
|
1642
|
+
|
1643
|
+
if(self->GetScriptableInfo() &&
|
1644
|
+
self->GetScriptableInfo()->GetFlags().DontEnumStaticProps())
|
1645
|
+
return JS_TRUE;
|
1646
|
+
|
1647
|
+
XPCNativeSet* set = self->GetSet();
|
1648
|
+
if(!set)
|
1649
|
+
return JS_FALSE;
|
1650
|
+
|
1651
|
+
XPCCallContext ccx(JS_CALLER, cx);
|
1652
|
+
if(!ccx.IsValid())
|
1653
|
+
return JS_FALSE;
|
1654
|
+
|
1655
|
+
PRUint16 interface_count = set->GetInterfaceCount();
|
1656
|
+
XPCNativeInterface** interfaceArray = set->GetInterfaceArray();
|
1657
|
+
for(PRUint16 i = 0; i < interface_count; i++)
|
1658
|
+
{
|
1659
|
+
XPCNativeInterface* iface = interfaceArray[i];
|
1660
|
+
PRUint16 member_count = iface->GetMemberCount();
|
1661
|
+
|
1662
|
+
for(PRUint16 k = 0; k < member_count; k++)
|
1663
|
+
{
|
1664
|
+
if(!xpc_ForcePropertyResolve(cx, obj, iface->GetMemberAt(k)->GetName()))
|
1665
|
+
return JS_FALSE;
|
1666
|
+
}
|
1667
|
+
}
|
1668
|
+
|
1669
|
+
return JS_TRUE;
|
1670
|
+
}
|
1671
|
+
|
1672
|
+
static JSBool
|
1673
|
+
XPC_WN_Shared_Proto_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
|
1674
|
+
{
|
1675
|
+
// XXX ?
|
1676
|
+
return JS_TRUE;
|
1677
|
+
}
|
1678
|
+
|
1679
|
+
static void
|
1680
|
+
XPC_WN_Shared_Proto_Finalize(JSContext *cx, JSObject *obj)
|
1681
|
+
{
|
1682
|
+
// This can be null if xpc shutdown has already happened
|
1683
|
+
XPCWrappedNativeProto* p = (XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
|
1684
|
+
if(p)
|
1685
|
+
p->JSProtoObjectFinalized(cx, obj);
|
1686
|
+
}
|
1687
|
+
|
1688
|
+
static void
|
1689
|
+
XPC_WN_Shared_Proto_Trace(JSTracer *trc, JSObject *obj)
|
1690
|
+
{
|
1691
|
+
// This can be null if xpc shutdown has already happened
|
1692
|
+
XPCWrappedNativeProto* p =
|
1693
|
+
(XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
|
1694
|
+
if(p)
|
1695
|
+
TraceScopeJSObjects(trc, p->GetScope());
|
1696
|
+
}
|
1697
|
+
|
1698
|
+
/*****************************************************/
|
1699
|
+
|
1700
|
+
static JSBool
|
1701
|
+
XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
1702
|
+
{
|
1703
|
+
CHECK_IDVAL(cx, idval);
|
1704
|
+
|
1705
|
+
NS_ASSERTION(
|
1706
|
+
JS_InstanceOf(cx, obj, &XPC_WN_ModsAllowed_WithCall_Proto_JSClass,
|
1707
|
+
nsnull) ||
|
1708
|
+
JS_InstanceOf(cx, obj, &XPC_WN_ModsAllowed_NoCall_Proto_JSClass,
|
1709
|
+
nsnull),
|
1710
|
+
"bad proto");
|
1711
|
+
|
1712
|
+
XPCWrappedNativeProto* self =
|
1713
|
+
(XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
|
1714
|
+
if(!self)
|
1715
|
+
return JS_FALSE;
|
1716
|
+
|
1717
|
+
XPCCallContext ccx(JS_CALLER, cx);
|
1718
|
+
if(!ccx.IsValid())
|
1719
|
+
return JS_FALSE;
|
1720
|
+
|
1721
|
+
XPCNativeScriptableInfo* si = self->GetScriptableInfo();
|
1722
|
+
uintN enumFlag = (si && si->GetFlags().DontEnumStaticProps()) ?
|
1723
|
+
0 : JSPROP_ENUMERATE;
|
1724
|
+
|
1725
|
+
return DefinePropertyIfFound(ccx, obj, idval,
|
1726
|
+
self->GetSet(), nsnull, nsnull,
|
1727
|
+
self->GetScope(),
|
1728
|
+
JS_TRUE, nsnull, nsnull, si,
|
1729
|
+
enumFlag, nsnull);
|
1730
|
+
}
|
1731
|
+
|
1732
|
+
// Give our proto classes object ops that match the respective
|
1733
|
+
// wrappers so that the JS engine can share scope (maps) among
|
1734
|
+
// wrappers. This essentially duplicates the number of JSClasses we
|
1735
|
+
// use for prototype objects (from 2 to 4), but the scope sharing
|
1736
|
+
// benefit is well worth it.
|
1737
|
+
JSObjectOps *
|
1738
|
+
XPC_WN_Proto_GetObjectOps(JSContext *cx, JSClass *clazz)
|
1739
|
+
{
|
1740
|
+
// Protos for wrappers that want calls to their call() hooks get
|
1741
|
+
// jsops with a call hook, others get jsops w/o a call hook.
|
1742
|
+
|
1743
|
+
if(clazz == &XPC_WN_ModsAllowed_WithCall_Proto_JSClass ||
|
1744
|
+
clazz == &XPC_WN_NoMods_WithCall_Proto_JSClass)
|
1745
|
+
return &XPC_WN_WithCall_JSOps;
|
1746
|
+
|
1747
|
+
NS_ASSERTION(clazz == &XPC_WN_ModsAllowed_NoCall_Proto_JSClass ||
|
1748
|
+
clazz == &XPC_WN_NoMods_NoCall_Proto_JSClass ||
|
1749
|
+
clazz == &XPC_WN_NoHelper_Proto_JSClass,
|
1750
|
+
"bad proto");
|
1751
|
+
|
1752
|
+
return &XPC_WN_NoCall_JSOps;
|
1753
|
+
}
|
1754
|
+
|
1755
|
+
JSClass XPC_WN_ModsAllowed_WithCall_Proto_JSClass = {
|
1756
|
+
"XPC_WN_ModsAllowed_WithCall_Proto_JSClass", // name;
|
1757
|
+
JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags;
|
1758
|
+
|
1759
|
+
/* Mandatory non-null function pointer members. */
|
1760
|
+
JS_PropertyStub, // addProperty;
|
1761
|
+
JS_PropertyStub, // delProperty;
|
1762
|
+
JS_PropertyStub, // getProperty;
|
1763
|
+
JS_PropertyStub, // setProperty;
|
1764
|
+
XPC_WN_Shared_Proto_Enumerate, // enumerate;
|
1765
|
+
XPC_WN_ModsAllowed_Proto_Resolve, // resolve;
|
1766
|
+
XPC_WN_Shared_Proto_Convert, // convert;
|
1767
|
+
XPC_WN_Shared_Proto_Finalize, // finalize;
|
1768
|
+
|
1769
|
+
/* Optionally non-null members start here. */
|
1770
|
+
XPC_WN_Proto_GetObjectOps, // getObjectOps;
|
1771
|
+
nsnull, // checkAccess;
|
1772
|
+
nsnull, // call;
|
1773
|
+
nsnull, // construct;
|
1774
|
+
nsnull, // xdrObject;
|
1775
|
+
nsnull, // hasInstance;
|
1776
|
+
JS_CLASS_TRACE(XPC_WN_Shared_Proto_Trace), // mark/trace;
|
1777
|
+
nsnull // spare;
|
1778
|
+
};
|
1779
|
+
|
1780
|
+
JSObjectOps *
|
1781
|
+
XPC_WN_ModsAllowedProto_NoCall_GetObjectOps(JSContext *cx, JSClass *clazz)
|
1782
|
+
{
|
1783
|
+
return &XPC_WN_NoCall_JSOps;
|
1784
|
+
}
|
1785
|
+
|
1786
|
+
JSClass XPC_WN_ModsAllowed_NoCall_Proto_JSClass = {
|
1787
|
+
"XPC_WN_ModsAllowed_NoCall_Proto_JSClass", // name;
|
1788
|
+
JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags;
|
1789
|
+
|
1790
|
+
/* Mandatory non-null function pointer members. */
|
1791
|
+
JS_PropertyStub, // addProperty;
|
1792
|
+
JS_PropertyStub, // delProperty;
|
1793
|
+
JS_PropertyStub, // getProperty;
|
1794
|
+
JS_PropertyStub, // setProperty;
|
1795
|
+
XPC_WN_Shared_Proto_Enumerate, // enumerate;
|
1796
|
+
XPC_WN_ModsAllowed_Proto_Resolve, // resolve;
|
1797
|
+
XPC_WN_Shared_Proto_Convert, // convert;
|
1798
|
+
XPC_WN_Shared_Proto_Finalize, // finalize;
|
1799
|
+
|
1800
|
+
/* Optionally non-null members start here. */
|
1801
|
+
XPC_WN_Proto_GetObjectOps, // getObjectOps;
|
1802
|
+
nsnull, // checkAccess;
|
1803
|
+
nsnull, // call;
|
1804
|
+
nsnull, // construct;
|
1805
|
+
nsnull, // xdrObject;
|
1806
|
+
nsnull, // hasInstance;
|
1807
|
+
JS_CLASS_TRACE(XPC_WN_Shared_Proto_Trace), // mark/trace;
|
1808
|
+
nsnull // spare;
|
1809
|
+
};
|
1810
|
+
|
1811
|
+
/***************************************************************************/
|
1812
|
+
|
1813
|
+
static JSBool
|
1814
|
+
XPC_WN_OnlyIWrite_Proto_PropertyStub(JSContext *cx, JSObject *obj, jsval idval, jsval *vp)
|
1815
|
+
{
|
1816
|
+
CHECK_IDVAL(cx, idval);
|
1817
|
+
|
1818
|
+
NS_ASSERTION(
|
1819
|
+
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_WithCall_Proto_JSClass, nsnull) ||
|
1820
|
+
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_NoCall_Proto_JSClass, nsnull),
|
1821
|
+
"bad proto");
|
1822
|
+
|
1823
|
+
XPCWrappedNativeProto* self =
|
1824
|
+
(XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
|
1825
|
+
if(!self)
|
1826
|
+
return JS_FALSE;
|
1827
|
+
|
1828
|
+
XPCCallContext ccx(JS_CALLER, cx);
|
1829
|
+
if(!ccx.IsValid())
|
1830
|
+
return JS_FALSE;
|
1831
|
+
|
1832
|
+
// Allow XPConnect to add the property only
|
1833
|
+
if(ccx.GetResolveName() == idval)
|
1834
|
+
return JS_TRUE;
|
1835
|
+
|
1836
|
+
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
1837
|
+
}
|
1838
|
+
|
1839
|
+
static JSBool
|
1840
|
+
XPC_WN_NoMods_Proto_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
1841
|
+
{
|
1842
|
+
CHECK_IDVAL(cx, idval);
|
1843
|
+
|
1844
|
+
NS_ASSERTION(
|
1845
|
+
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_WithCall_Proto_JSClass, nsnull) ||
|
1846
|
+
JS_InstanceOf(cx, obj, &XPC_WN_NoMods_NoCall_Proto_JSClass, nsnull),
|
1847
|
+
"bad proto");
|
1848
|
+
|
1849
|
+
XPCWrappedNativeProto* self =
|
1850
|
+
(XPCWrappedNativeProto*) xpc_GetJSPrivate(obj);
|
1851
|
+
if(!self)
|
1852
|
+
return JS_FALSE;
|
1853
|
+
|
1854
|
+
XPCCallContext ccx(JS_CALLER, cx);
|
1855
|
+
if(!ccx.IsValid())
|
1856
|
+
return JS_FALSE;
|
1857
|
+
|
1858
|
+
XPCNativeScriptableInfo* si = self->GetScriptableInfo();
|
1859
|
+
uintN enumFlag = (si && si->GetFlags().DontEnumStaticProps()) ?
|
1860
|
+
0 : JSPROP_ENUMERATE;
|
1861
|
+
|
1862
|
+
return DefinePropertyIfFound(ccx, obj, idval,
|
1863
|
+
self->GetSet(), nsnull, nsnull,
|
1864
|
+
self->GetScope(),
|
1865
|
+
JS_TRUE, nsnull, nsnull, si,
|
1866
|
+
JSPROP_READONLY |
|
1867
|
+
JSPROP_PERMANENT |
|
1868
|
+
enumFlag, nsnull);
|
1869
|
+
}
|
1870
|
+
|
1871
|
+
JSClass XPC_WN_NoMods_WithCall_Proto_JSClass = {
|
1872
|
+
"XPC_WN_NoMods_WithCall_Proto_JSClass", // name;
|
1873
|
+
JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags;
|
1874
|
+
|
1875
|
+
/* Mandatory non-null function pointer members. */
|
1876
|
+
XPC_WN_OnlyIWrite_Proto_PropertyStub, // addProperty;
|
1877
|
+
XPC_WN_CannotModifyPropertyStub, // delProperty;
|
1878
|
+
JS_PropertyStub, // getProperty;
|
1879
|
+
XPC_WN_OnlyIWrite_Proto_PropertyStub, // setProperty;
|
1880
|
+
XPC_WN_Shared_Proto_Enumerate, // enumerate;
|
1881
|
+
XPC_WN_NoMods_Proto_Resolve, // resolve;
|
1882
|
+
XPC_WN_Shared_Proto_Convert, // convert;
|
1883
|
+
XPC_WN_Shared_Proto_Finalize, // finalize;
|
1884
|
+
|
1885
|
+
/* Optionally non-null members start here. */
|
1886
|
+
XPC_WN_Proto_GetObjectOps, // getObjectOps;
|
1887
|
+
nsnull, // checkAccess;
|
1888
|
+
nsnull, // call;
|
1889
|
+
nsnull, // construct;
|
1890
|
+
nsnull, // xdrObject;
|
1891
|
+
nsnull, // hasInstance;
|
1892
|
+
JS_CLASS_TRACE(XPC_WN_Shared_Proto_Trace), // mark/trace;
|
1893
|
+
nsnull // spare;
|
1894
|
+
};
|
1895
|
+
|
1896
|
+
JSClass XPC_WN_NoMods_NoCall_Proto_JSClass = {
|
1897
|
+
"XPC_WN_NoMods_NoCall_Proto_JSClass", // name;
|
1898
|
+
JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags;
|
1899
|
+
|
1900
|
+
/* Mandatory non-null function pointer members. */
|
1901
|
+
XPC_WN_OnlyIWrite_Proto_PropertyStub, // addProperty;
|
1902
|
+
XPC_WN_CannotModifyPropertyStub, // delProperty;
|
1903
|
+
JS_PropertyStub, // getProperty;
|
1904
|
+
XPC_WN_OnlyIWrite_Proto_PropertyStub, // setProperty;
|
1905
|
+
XPC_WN_Shared_Proto_Enumerate, // enumerate;
|
1906
|
+
XPC_WN_NoMods_Proto_Resolve, // resolve;
|
1907
|
+
XPC_WN_Shared_Proto_Convert, // convert;
|
1908
|
+
XPC_WN_Shared_Proto_Finalize, // finalize;
|
1909
|
+
|
1910
|
+
/* Optionally non-null members start here. */
|
1911
|
+
XPC_WN_Proto_GetObjectOps, // getObjectOps;
|
1912
|
+
nsnull, // checkAccess;
|
1913
|
+
nsnull, // call;
|
1914
|
+
nsnull, // construct;
|
1915
|
+
nsnull, // xdrObject;
|
1916
|
+
nsnull, // hasInstance;
|
1917
|
+
JS_CLASS_TRACE(XPC_WN_Shared_Proto_Trace), // mark/trace;
|
1918
|
+
nsnull // spare;
|
1919
|
+
};
|
1920
|
+
|
1921
|
+
/***************************************************************************/
|
1922
|
+
|
1923
|
+
static JSBool
|
1924
|
+
XPC_WN_TearOff_Enumerate(JSContext *cx, JSObject *obj)
|
1925
|
+
{
|
1926
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
1927
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
1928
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
1929
|
+
|
1930
|
+
XPCWrappedNativeTearOff* to = ccx.GetTearOff();
|
1931
|
+
XPCNativeInterface* iface;
|
1932
|
+
|
1933
|
+
if(!to || nsnull == (iface = to->GetInterface()))
|
1934
|
+
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
1935
|
+
|
1936
|
+
PRUint16 member_count = iface->GetMemberCount();
|
1937
|
+
for(PRUint16 k = 0; k < member_count; k++)
|
1938
|
+
{
|
1939
|
+
if(!xpc_ForcePropertyResolve(cx, obj, iface->GetMemberAt(k)->GetName()))
|
1940
|
+
return JS_FALSE;
|
1941
|
+
}
|
1942
|
+
|
1943
|
+
return JS_TRUE;
|
1944
|
+
}
|
1945
|
+
|
1946
|
+
static JSBool
|
1947
|
+
XPC_WN_TearOff_Resolve(JSContext *cx, JSObject *obj, jsval idval)
|
1948
|
+
{
|
1949
|
+
CHECK_IDVAL(cx, idval);
|
1950
|
+
|
1951
|
+
XPCCallContext ccx(JS_CALLER, cx, obj);
|
1952
|
+
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
1953
|
+
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
|
1954
|
+
|
1955
|
+
XPCWrappedNativeTearOff* to = ccx.GetTearOff();
|
1956
|
+
XPCNativeInterface* iface;
|
1957
|
+
|
1958
|
+
if(!to || nsnull == (iface = to->GetInterface()))
|
1959
|
+
return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
|
1960
|
+
|
1961
|
+
return DefinePropertyIfFound(ccx, obj, idval, nsnull, iface, nsnull,
|
1962
|
+
wrapper->GetScope(),
|
1963
|
+
JS_TRUE, nsnull, nsnull, nsnull,
|
1964
|
+
JSPROP_READONLY |
|
1965
|
+
JSPROP_PERMANENT |
|
1966
|
+
JSPROP_ENUMERATE, nsnull);
|
1967
|
+
}
|
1968
|
+
|
1969
|
+
static void
|
1970
|
+
XPC_WN_TearOff_Finalize(JSContext *cx, JSObject *obj)
|
1971
|
+
{
|
1972
|
+
XPCWrappedNativeTearOff* p = (XPCWrappedNativeTearOff*)
|
1973
|
+
xpc_GetJSPrivate(obj);
|
1974
|
+
if(!p)
|
1975
|
+
return;
|
1976
|
+
p->JSObjectFinalized();
|
1977
|
+
}
|
1978
|
+
|
1979
|
+
JSClass XPC_WN_Tearoff_JSClass = {
|
1980
|
+
"WrappedNative_TearOff", // name;
|
1981
|
+
JSCLASS_HAS_PRIVATE | JSCLASS_MARK_IS_TRACE, // flags;
|
1982
|
+
|
1983
|
+
/* Mandatory non-null function pointer members. */
|
1984
|
+
XPC_WN_OnlyIWrite_PropertyStub, // addProperty;
|
1985
|
+
XPC_WN_CannotModifyPropertyStub, // delProperty;
|
1986
|
+
JS_PropertyStub, // getProperty;
|
1987
|
+
XPC_WN_OnlyIWrite_PropertyStub, // setProperty;
|
1988
|
+
XPC_WN_TearOff_Enumerate, // enumerate;
|
1989
|
+
XPC_WN_TearOff_Resolve, // resolve;
|
1990
|
+
XPC_WN_Shared_Convert, // convert;
|
1991
|
+
XPC_WN_TearOff_Finalize, // finalize;
|
1992
|
+
|
1993
|
+
/* Optionally non-null members start here. */
|
1994
|
+
nsnull, // getObjectOps;
|
1995
|
+
nsnull, // checkAccess;
|
1996
|
+
nsnull, // call;
|
1997
|
+
nsnull, // construct;
|
1998
|
+
nsnull, // xdrObject;
|
1999
|
+
nsnull, // hasInstance;
|
2000
|
+
nsnull, // mark/trace;
|
2001
|
+
nsnull // spare;
|
2002
|
+
};
|
2003
|
+
|