smparkes-johnson 1.1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +14 -0
- data/CHANGELOG.rdoc +21 -0
- data/Manifest.txt +1077 -0
- data/README.rdoc +51 -0
- data/Rakefile +140 -0
- data/bin/johnson +106 -0
- data/ext/spidermonkey/context.c +116 -0
- data/ext/spidermonkey/context.h +19 -0
- data/ext/spidermonkey/conversions.c +354 -0
- data/ext/spidermonkey/conversions.h +31 -0
- data/ext/spidermonkey/debugger.c +234 -0
- data/ext/spidermonkey/debugger.h +10 -0
- data/ext/spidermonkey/extconf.rb +32 -0
- data/ext/spidermonkey/extensions.c +37 -0
- data/ext/spidermonkey/extensions.h +12 -0
- data/ext/spidermonkey/global.c +40 -0
- data/ext/spidermonkey/global.h +11 -0
- data/ext/spidermonkey/idhash.c +16 -0
- data/ext/spidermonkey/idhash.h +8 -0
- data/ext/spidermonkey/immutable_node.c +1153 -0
- data/ext/spidermonkey/immutable_node.c.erb +523 -0
- data/ext/spidermonkey/immutable_node.h +22 -0
- data/ext/spidermonkey/jroot.h +197 -0
- data/ext/spidermonkey/js_land_proxy.c +610 -0
- data/ext/spidermonkey/js_land_proxy.h +20 -0
- data/ext/spidermonkey/ruby_land_proxy.c +611 -0
- data/ext/spidermonkey/ruby_land_proxy.h +38 -0
- data/ext/spidermonkey/runtime.c +396 -0
- data/ext/spidermonkey/runtime.h +27 -0
- data/ext/spidermonkey/spidermonkey.c +22 -0
- data/ext/spidermonkey/spidermonkey.h +29 -0
- data/ext/tracemonkey/context.cc +125 -0
- data/ext/tracemonkey/context.h +19 -0
- data/ext/tracemonkey/conversions.cc +355 -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 +610 -0
- data/ext/tracemonkey/js_land_proxy.h +20 -0
- data/ext/tracemonkey/ruby_land_proxy.cc +611 -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/cli/options.rb +67 -0
- data/lib/johnson/cli.rb +8 -0
- data/lib/johnson/error.rb +4 -0
- data/lib/johnson/js/cli.js +30 -0
- data/lib/johnson/js/prelude.js +118 -0
- data/lib/johnson/nodes/binary_node.rb +65 -0
- data/lib/johnson/nodes/for.rb +14 -0
- data/lib/johnson/nodes/for_in.rb +12 -0
- data/lib/johnson/nodes/function.rb +13 -0
- data/lib/johnson/nodes/list.rb +28 -0
- data/lib/johnson/nodes/node.rb +68 -0
- data/lib/johnson/nodes/ternary_node.rb +20 -0
- data/lib/johnson/nodes.rb +7 -0
- data/lib/johnson/parser/syntax_error.rb +13 -0
- data/lib/johnson/parser.rb +22 -0
- data/lib/johnson/ruby_land_proxy.rb +81 -0
- data/lib/johnson/runtime.rb +141 -0
- data/lib/johnson/spidermonkey/context.rb +10 -0
- data/lib/johnson/spidermonkey/debugger.rb +67 -0
- data/lib/johnson/spidermonkey/immutable_node.rb +282 -0
- data/lib/johnson/spidermonkey/js_land_proxy.rb +64 -0
- data/lib/johnson/spidermonkey/mutable_tree_visitor.rb +242 -0
- data/lib/johnson/spidermonkey/ruby_land_proxy.rb +17 -0
- data/lib/johnson/spidermonkey/runtime.rb +92 -0
- data/lib/johnson/spidermonkey.rb +12 -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 +98 -0
- data/lib/johnson/tracemonkey.rb +13 -0
- data/lib/johnson/visitable.rb +16 -0
- data/lib/johnson/visitors/dot_visitor.rb +169 -0
- data/lib/johnson/visitors/ecma_visitor.rb +323 -0
- data/lib/johnson/visitors/enumerating_visitor.rb +15 -0
- data/lib/johnson/visitors/sexp_visitor.rb +174 -0
- data/lib/johnson/visitors/visitor.rb +91 -0
- data/lib/johnson/visitors.rb +5 -0
- data/lib/johnson.rb +53 -0
- data/test/generic/johnson_test.rb +16 -0
- data/test/generic/parser_test.rb +276 -0
- data/test/helper.rb +82 -0
- data/test/johnson/generic/browser_test.rb +43 -0
- data/test/johnson/generic/conversions/array_test.rb +70 -0
- data/test/johnson/generic/conversions/boolean_test.rb +17 -0
- data/test/johnson/generic/conversions/callable_test.rb +34 -0
- data/test/johnson/generic/conversions/file_test.rb +15 -0
- data/test/johnson/generic/conversions/helper.rb +1 -0
- data/test/johnson/generic/conversions/nil_test.rb +20 -0
- data/test/johnson/generic/conversions/number_test.rb +34 -0
- data/test/johnson/generic/conversions/regexp_test.rb +24 -0
- data/test/johnson/generic/conversions/string_test.rb +38 -0
- data/test/johnson/generic/conversions/struct_test.rb +15 -0
- data/test/johnson/generic/conversions/symbol_test.rb +19 -0
- data/test/johnson/generic/conversions/thread_test.rb +24 -0
- data/test/johnson/generic/default_test.rb +12 -0
- data/test/johnson/generic/error_test.rb +9 -0
- data/test/johnson/generic/extensions_test.rb +56 -0
- data/test/johnson/generic/helper.rb +1 -0
- data/test/johnson/generic/nodes/array_literal_test.rb +57 -0
- data/test/johnson/generic/nodes/array_node_test.rb +26 -0
- data/test/johnson/generic/nodes/binary_node_test.rb +61 -0
- data/test/johnson/generic/nodes/bracket_access_test.rb +16 -0
- data/test/johnson/generic/nodes/delete_test.rb +11 -0
- data/test/johnson/generic/nodes/do_while_test.rb +12 -0
- data/test/johnson/generic/nodes/dot_accessor_test.rb +15 -0
- data/test/johnson/generic/nodes/export_test.rb +11 -0
- data/test/johnson/generic/nodes/for_test.rb +54 -0
- data/test/johnson/generic/nodes/function_test.rb +71 -0
- data/test/johnson/generic/nodes/helper.rb +1 -0
- data/test/johnson/generic/nodes/if_test.rb +51 -0
- data/test/johnson/generic/nodes/import_test.rb +15 -0
- data/test/johnson/generic/nodes/label_test.rb +19 -0
- data/test/johnson/generic/nodes/let_test.rb +31 -0
- data/test/johnson/generic/nodes/object_literal_test.rb +110 -0
- data/test/johnson/generic/nodes/return_test.rb +16 -0
- data/test/johnson/generic/nodes/semi_test.rb +8 -0
- data/test/johnson/generic/nodes/switch_test.rb +55 -0
- data/test/johnson/generic/nodes/ternary_test.rb +25 -0
- data/test/johnson/generic/nodes/throw_test.rb +9 -0
- data/test/johnson/generic/nodes/try_node_test.rb +89 -0
- data/test/johnson/generic/nodes/typeof_test.rb +11 -0
- data/test/johnson/generic/nodes/unary_node_test.rb +23 -0
- data/test/johnson/generic/nodes/void_test.rb +11 -0
- data/test/johnson/generic/nodes/while_test.rb +26 -0
- data/test/johnson/generic/nodes/with_test.rb +10 -0
- data/test/johnson/generic/prelude_test.rb +79 -0
- data/test/johnson/generic/runtime_test.rb +140 -0
- data/test/johnson/generic/version_test.rb +13 -0
- data/test/johnson/generic/visitors/dot_visitor_test.rb +39 -0
- data/test/johnson/generic/visitors/enumerating_visitor_test.rb +12 -0
- data/test/johnson/generic/visitors/helper.rb +1 -0
- data/test/johnson/spidermonkey/context_test.rb +21 -0
- data/test/johnson/spidermonkey/immutable_node_test.rb +34 -0
- data/test/johnson/spidermonkey/js_land_proxy_test.rb +277 -0
- data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +270 -0
- data/test/johnson/spidermonkey/runtime_test.rb +41 -0
- 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 +277 -0
- data/test/johnson/tracemonkey/ruby_land_proxy_test.rb +270 -0
- data/test/johnson/tracemonkey/runtime_test.rb +41 -0
- data/test/johnson/tracemonkey/split_global_test.rb +32 -0
- data/vendor/spidermonkey/.cvsignore +9 -0
- data/vendor/spidermonkey/Makefile.in +449 -0
- data/vendor/spidermonkey/Makefile.ref +365 -0
- data/vendor/spidermonkey/README.html +820 -0
- data/vendor/spidermonkey/SpiderMonkey.rsp +12 -0
- data/vendor/spidermonkey/Y.js +19 -0
- data/vendor/spidermonkey/build.mk +43 -0
- data/vendor/spidermonkey/config/AIX4.1.mk +65 -0
- data/vendor/spidermonkey/config/AIX4.2.mk +64 -0
- data/vendor/spidermonkey/config/AIX4.3.mk +65 -0
- data/vendor/spidermonkey/config/Darwin.mk +83 -0
- data/vendor/spidermonkey/config/Darwin1.3.mk +81 -0
- data/vendor/spidermonkey/config/Darwin1.4.mk +41 -0
- data/vendor/spidermonkey/config/Darwin5.2.mk +81 -0
- data/vendor/spidermonkey/config/Darwin5.3.mk +81 -0
- data/vendor/spidermonkey/config/HP-UXB.10.10.mk +77 -0
- data/vendor/spidermonkey/config/HP-UXB.10.20.mk +77 -0
- data/vendor/spidermonkey/config/HP-UXB.11.00.mk +80 -0
- data/vendor/spidermonkey/config/IRIX.mk +87 -0
- data/vendor/spidermonkey/config/IRIX5.3.mk +44 -0
- data/vendor/spidermonkey/config/IRIX6.1.mk +44 -0
- data/vendor/spidermonkey/config/IRIX6.2.mk +44 -0
- data/vendor/spidermonkey/config/IRIX6.3.mk +44 -0
- data/vendor/spidermonkey/config/IRIX6.5.mk +44 -0
- data/vendor/spidermonkey/config/Linux_All.mk +103 -0
- data/vendor/spidermonkey/config/Mac_OS10.0.mk +82 -0
- data/vendor/spidermonkey/config/OSF1V4.0.mk +72 -0
- data/vendor/spidermonkey/config/OSF1V5.0.mk +69 -0
- data/vendor/spidermonkey/config/SunOS4.1.4.mk +101 -0
- data/vendor/spidermonkey/config/SunOS5.10.mk +50 -0
- data/vendor/spidermonkey/config/SunOS5.3.mk +91 -0
- data/vendor/spidermonkey/config/SunOS5.4.mk +92 -0
- data/vendor/spidermonkey/config/SunOS5.5.1.mk +44 -0
- data/vendor/spidermonkey/config/SunOS5.5.mk +87 -0
- data/vendor/spidermonkey/config/SunOS5.6.mk +89 -0
- data/vendor/spidermonkey/config/SunOS5.7.mk +44 -0
- data/vendor/spidermonkey/config/SunOS5.8.mk +44 -0
- data/vendor/spidermonkey/config/SunOS5.9.mk +44 -0
- data/vendor/spidermonkey/config/WINNT4.0.mk +117 -0
- data/vendor/spidermonkey/config/WINNT5.0.mk +117 -0
- data/vendor/spidermonkey/config/WINNT5.1.mk +117 -0
- data/vendor/spidermonkey/config/WINNT5.2.mk +117 -0
- data/vendor/spidermonkey/config/WINNT6.0.mk +117 -0
- data/vendor/spidermonkey/config/dgux.mk +64 -0
- data/vendor/spidermonkey/config.mk +192 -0
- data/vendor/spidermonkey/editline/Makefile.ref +144 -0
- data/vendor/spidermonkey/editline/README +83 -0
- data/vendor/spidermonkey/editline/editline.3 +175 -0
- data/vendor/spidermonkey/editline/editline.c +1369 -0
- data/vendor/spidermonkey/editline/editline.h +135 -0
- data/vendor/spidermonkey/editline/sysunix.c +182 -0
- data/vendor/spidermonkey/editline/unix.h +82 -0
- data/vendor/spidermonkey/fdlibm/.cvsignore +7 -0
- data/vendor/spidermonkey/fdlibm/Makefile.in +127 -0
- data/vendor/spidermonkey/fdlibm/Makefile.ref +192 -0
- data/vendor/spidermonkey/fdlibm/e_acos.c +147 -0
- data/vendor/spidermonkey/fdlibm/e_acosh.c +105 -0
- data/vendor/spidermonkey/fdlibm/e_asin.c +156 -0
- data/vendor/spidermonkey/fdlibm/e_atan2.c +165 -0
- data/vendor/spidermonkey/fdlibm/e_atanh.c +110 -0
- data/vendor/spidermonkey/fdlibm/e_cosh.c +133 -0
- data/vendor/spidermonkey/fdlibm/e_exp.c +202 -0
- data/vendor/spidermonkey/fdlibm/e_fmod.c +184 -0
- data/vendor/spidermonkey/fdlibm/e_gamma.c +71 -0
- data/vendor/spidermonkey/fdlibm/e_gamma_r.c +70 -0
- data/vendor/spidermonkey/fdlibm/e_hypot.c +173 -0
- data/vendor/spidermonkey/fdlibm/e_j0.c +524 -0
- data/vendor/spidermonkey/fdlibm/e_j1.c +523 -0
- data/vendor/spidermonkey/fdlibm/e_jn.c +315 -0
- data/vendor/spidermonkey/fdlibm/e_lgamma.c +71 -0
- data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +347 -0
- data/vendor/spidermonkey/fdlibm/e_log.c +184 -0
- data/vendor/spidermonkey/fdlibm/e_log10.c +134 -0
- data/vendor/spidermonkey/fdlibm/e_pow.c +386 -0
- data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +222 -0
- data/vendor/spidermonkey/fdlibm/e_remainder.c +120 -0
- data/vendor/spidermonkey/fdlibm/e_scalb.c +89 -0
- data/vendor/spidermonkey/fdlibm/e_sinh.c +122 -0
- data/vendor/spidermonkey/fdlibm/e_sqrt.c +497 -0
- data/vendor/spidermonkey/fdlibm/fdlibm.h +273 -0
- data/vendor/spidermonkey/fdlibm/fdlibm.mak +1453 -0
- data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
- data/vendor/spidermonkey/fdlibm/k_cos.c +135 -0
- data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +354 -0
- data/vendor/spidermonkey/fdlibm/k_sin.c +114 -0
- data/vendor/spidermonkey/fdlibm/k_standard.c +785 -0
- data/vendor/spidermonkey/fdlibm/k_tan.c +170 -0
- data/vendor/spidermonkey/fdlibm/s_asinh.c +101 -0
- data/vendor/spidermonkey/fdlibm/s_atan.c +175 -0
- data/vendor/spidermonkey/fdlibm/s_cbrt.c +133 -0
- data/vendor/spidermonkey/fdlibm/s_ceil.c +120 -0
- data/vendor/spidermonkey/fdlibm/s_copysign.c +72 -0
- data/vendor/spidermonkey/fdlibm/s_cos.c +118 -0
- data/vendor/spidermonkey/fdlibm/s_erf.c +356 -0
- data/vendor/spidermonkey/fdlibm/s_expm1.c +267 -0
- data/vendor/spidermonkey/fdlibm/s_fabs.c +70 -0
- data/vendor/spidermonkey/fdlibm/s_finite.c +71 -0
- data/vendor/spidermonkey/fdlibm/s_floor.c +121 -0
- data/vendor/spidermonkey/fdlibm/s_frexp.c +99 -0
- data/vendor/spidermonkey/fdlibm/s_ilogb.c +85 -0
- data/vendor/spidermonkey/fdlibm/s_isnan.c +74 -0
- data/vendor/spidermonkey/fdlibm/s_ldexp.c +66 -0
- data/vendor/spidermonkey/fdlibm/s_lib_version.c +73 -0
- data/vendor/spidermonkey/fdlibm/s_log1p.c +211 -0
- data/vendor/spidermonkey/fdlibm/s_logb.c +79 -0
- data/vendor/spidermonkey/fdlibm/s_matherr.c +64 -0
- data/vendor/spidermonkey/fdlibm/s_modf.c +132 -0
- data/vendor/spidermonkey/fdlibm/s_nextafter.c +124 -0
- data/vendor/spidermonkey/fdlibm/s_rint.c +131 -0
- data/vendor/spidermonkey/fdlibm/s_scalbn.c +107 -0
- data/vendor/spidermonkey/fdlibm/s_signgam.c +40 -0
- data/vendor/spidermonkey/fdlibm/s_significand.c +68 -0
- data/vendor/spidermonkey/fdlibm/s_sin.c +118 -0
- data/vendor/spidermonkey/fdlibm/s_tan.c +112 -0
- data/vendor/spidermonkey/fdlibm/s_tanh.c +122 -0
- data/vendor/spidermonkey/fdlibm/w_acos.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_acosh.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_asin.c +80 -0
- data/vendor/spidermonkey/fdlibm/w_atan2.c +79 -0
- data/vendor/spidermonkey/fdlibm/w_atanh.c +81 -0
- data/vendor/spidermonkey/fdlibm/w_cosh.c +77 -0
- data/vendor/spidermonkey/fdlibm/w_exp.c +88 -0
- data/vendor/spidermonkey/fdlibm/w_fmod.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_gamma.c +85 -0
- data/vendor/spidermonkey/fdlibm/w_gamma_r.c +81 -0
- data/vendor/spidermonkey/fdlibm/w_hypot.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_j0.c +105 -0
- data/vendor/spidermonkey/fdlibm/w_j1.c +106 -0
- data/vendor/spidermonkey/fdlibm/w_jn.c +128 -0
- data/vendor/spidermonkey/fdlibm/w_lgamma.c +85 -0
- data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +81 -0
- data/vendor/spidermonkey/fdlibm/w_log.c +78 -0
- data/vendor/spidermonkey/fdlibm/w_log10.c +81 -0
- data/vendor/spidermonkey/fdlibm/w_pow.c +99 -0
- data/vendor/spidermonkey/fdlibm/w_remainder.c +77 -0
- data/vendor/spidermonkey/fdlibm/w_scalb.c +95 -0
- data/vendor/spidermonkey/fdlibm/w_sinh.c +77 -0
- data/vendor/spidermonkey/fdlibm/w_sqrt.c +77 -0
- data/vendor/spidermonkey/javascript-trace.d +73 -0
- data/vendor/spidermonkey/js.c +3951 -0
- data/vendor/spidermonkey/js.mdp +0 -0
- data/vendor/spidermonkey/js.msg +308 -0
- data/vendor/spidermonkey/js.pkg +2 -0
- data/vendor/spidermonkey/js3240.rc +79 -0
- data/vendor/spidermonkey/jsOS240.def +654 -0
- data/vendor/spidermonkey/jsapi.c +5836 -0
- data/vendor/spidermonkey/jsapi.h +2624 -0
- data/vendor/spidermonkey/jsarena.c +450 -0
- data/vendor/spidermonkey/jsarena.h +318 -0
- data/vendor/spidermonkey/jsarray.c +2996 -0
- data/vendor/spidermonkey/jsarray.h +127 -0
- data/vendor/spidermonkey/jsatom.c +1045 -0
- data/vendor/spidermonkey/jsatom.h +442 -0
- data/vendor/spidermonkey/jsbit.h +253 -0
- data/vendor/spidermonkey/jsbool.c +176 -0
- data/vendor/spidermonkey/jsbool.h +73 -0
- data/vendor/spidermonkey/jsclist.h +139 -0
- data/vendor/spidermonkey/jscntxt.c +1348 -0
- data/vendor/spidermonkey/jscntxt.h +1120 -0
- data/vendor/spidermonkey/jscompat.h +57 -0
- data/vendor/spidermonkey/jsconfig.h +248 -0
- data/vendor/spidermonkey/jsconfig.mk +181 -0
- data/vendor/spidermonkey/jscpucfg.c +396 -0
- data/vendor/spidermonkey/jscpucfg.h +212 -0
- data/vendor/spidermonkey/jsdate.c +2390 -0
- data/vendor/spidermonkey/jsdate.h +124 -0
- data/vendor/spidermonkey/jsdbgapi.c +1802 -0
- data/vendor/spidermonkey/jsdbgapi.h +464 -0
- data/vendor/spidermonkey/jsdhash.c +868 -0
- data/vendor/spidermonkey/jsdhash.h +592 -0
- data/vendor/spidermonkey/jsdtoa.c +3167 -0
- data/vendor/spidermonkey/jsdtoa.h +130 -0
- data/vendor/spidermonkey/jsdtracef.c +317 -0
- data/vendor/spidermonkey/jsdtracef.h +77 -0
- data/vendor/spidermonkey/jsemit.c +6909 -0
- data/vendor/spidermonkey/jsemit.h +741 -0
- data/vendor/spidermonkey/jsexn.c +1371 -0
- data/vendor/spidermonkey/jsexn.h +96 -0
- data/vendor/spidermonkey/jsfile.c +2736 -0
- data/vendor/spidermonkey/jsfile.h +56 -0
- data/vendor/spidermonkey/jsfile.msg +90 -0
- data/vendor/spidermonkey/jsfun.c +2634 -0
- data/vendor/spidermonkey/jsfun.h +254 -0
- data/vendor/spidermonkey/jsgc.c +3562 -0
- data/vendor/spidermonkey/jsgc.h +403 -0
- data/vendor/spidermonkey/jshash.c +476 -0
- data/vendor/spidermonkey/jshash.h +151 -0
- data/vendor/spidermonkey/jsify.pl +485 -0
- data/vendor/spidermonkey/jsinterp.c +7007 -0
- data/vendor/spidermonkey/jsinterp.h +525 -0
- data/vendor/spidermonkey/jsinvoke.c +43 -0
- data/vendor/spidermonkey/jsiter.c +1067 -0
- data/vendor/spidermonkey/jsiter.h +122 -0
- data/vendor/spidermonkey/jskeyword.tbl +124 -0
- data/vendor/spidermonkey/jskwgen.c +460 -0
- data/vendor/spidermonkey/jslibmath.h +266 -0
- data/vendor/spidermonkey/jslock.c +1309 -0
- data/vendor/spidermonkey/jslock.h +313 -0
- data/vendor/spidermonkey/jslocko.asm +60 -0
- data/vendor/spidermonkey/jslog2.c +94 -0
- data/vendor/spidermonkey/jslong.c +264 -0
- data/vendor/spidermonkey/jslong.h +412 -0
- data/vendor/spidermonkey/jsmath.c +567 -0
- data/vendor/spidermonkey/jsmath.h +57 -0
- data/vendor/spidermonkey/jsnum.c +1239 -0
- data/vendor/spidermonkey/jsnum.h +283 -0
- data/vendor/spidermonkey/jsobj.c +5282 -0
- data/vendor/spidermonkey/jsobj.h +709 -0
- data/vendor/spidermonkey/jsopcode.c +5245 -0
- data/vendor/spidermonkey/jsopcode.h +394 -0
- data/vendor/spidermonkey/jsopcode.tbl +523 -0
- data/vendor/spidermonkey/jsotypes.h +202 -0
- data/vendor/spidermonkey/jsparse.c +6704 -0
- data/vendor/spidermonkey/jsparse.h +511 -0
- data/vendor/spidermonkey/jsprf.c +1264 -0
- data/vendor/spidermonkey/jsprf.h +150 -0
- data/vendor/spidermonkey/jsproto.tbl +128 -0
- data/vendor/spidermonkey/jsprvtd.h +267 -0
- data/vendor/spidermonkey/jspubtd.h +744 -0
- data/vendor/spidermonkey/jsregexp.c +4364 -0
- data/vendor/spidermonkey/jsregexp.h +183 -0
- data/vendor/spidermonkey/jsreops.tbl +145 -0
- data/vendor/spidermonkey/jsscan.c +2012 -0
- data/vendor/spidermonkey/jsscan.h +387 -0
- data/vendor/spidermonkey/jsscope.c +1957 -0
- data/vendor/spidermonkey/jsscope.h +418 -0
- data/vendor/spidermonkey/jsscript.c +1832 -0
- data/vendor/spidermonkey/jsscript.h +287 -0
- data/vendor/spidermonkey/jsshell.msg +50 -0
- data/vendor/spidermonkey/jsstddef.h +83 -0
- data/vendor/spidermonkey/jsstr.c +5005 -0
- data/vendor/spidermonkey/jsstr.h +641 -0
- data/vendor/spidermonkey/jstypes.h +475 -0
- data/vendor/spidermonkey/jsutil.c +345 -0
- data/vendor/spidermonkey/jsutil.h +157 -0
- data/vendor/spidermonkey/jsxdrapi.c +800 -0
- data/vendor/spidermonkey/jsxdrapi.h +218 -0
- data/vendor/spidermonkey/jsxml.c +8476 -0
- data/vendor/spidermonkey/jsxml.h +349 -0
- data/vendor/spidermonkey/lock_SunOS.s +119 -0
- data/vendor/spidermonkey/perfect.js +39 -0
- data/vendor/spidermonkey/plify_jsdhash.sed +36 -0
- data/vendor/spidermonkey/prmjtime.c +846 -0
- data/vendor/spidermonkey/prmjtime.h +103 -0
- data/vendor/spidermonkey/resource.h +15 -0
- data/vendor/spidermonkey/rules.mk +197 -0
- data/vendor/spidermonkey/win32.order +384 -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/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/config.mk +206 -0
- data/vendor/tracemonkey/configure +14183 -0
- data/vendor/tracemonkey/configure.in +5363 -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/correct.sh +23 -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 +873 -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 +9272 -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 +1164 -0
@@ -0,0 +1,2298 @@
|
|
1
|
+
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2
|
+
*
|
3
|
+
* ***** BEGIN LICENSE BLOCK *****
|
4
|
+
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
5
|
+
*
|
6
|
+
* The contents of this file are subject to the Mozilla Public License Version
|
7
|
+
* 1.1 (the "License"); you may not use this file except in compliance with
|
8
|
+
* the License. You may obtain a copy of the License at
|
9
|
+
* http://www.mozilla.org/MPL/
|
10
|
+
*
|
11
|
+
* Software distributed under the License is distributed on an "AS IS" basis,
|
12
|
+
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
13
|
+
* for the specific language governing rights and limitations under the
|
14
|
+
* License.
|
15
|
+
*
|
16
|
+
* The Original Code is Mozilla Communicator client code, released
|
17
|
+
* March 31, 1998.
|
18
|
+
*
|
19
|
+
* The Initial Developer of the Original Code is
|
20
|
+
* Netscape Communications Corporation.
|
21
|
+
* Portions created by the Initial Developer are Copyright (C) 1998
|
22
|
+
* the Initial Developer. All Rights Reserved.
|
23
|
+
*
|
24
|
+
* Contributor(s):
|
25
|
+
* John Bandhauer <jband@netscape.com> (original author)
|
26
|
+
* Pierre Phaneuf <pp@ludusdesign.com>
|
27
|
+
* Mike Shaver <shaver@mozilla.org>
|
28
|
+
*
|
29
|
+
* Alternatively, the contents of this file may be used under the terms of
|
30
|
+
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
31
|
+
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
32
|
+
* in which case the provisions of the GPL or the LGPL are applicable instead
|
33
|
+
* of those above. If you wish to allow use of your version of this file only
|
34
|
+
* under the terms of either the GPL or the LGPL, and not to allow others to
|
35
|
+
* use your version of this file under the terms of the MPL, indicate your
|
36
|
+
* decision by deleting the provisions above and replace them with the notice
|
37
|
+
* and other provisions required by the GPL or the LGPL. If you do not delete
|
38
|
+
* the provisions above, a recipient may use your version of this file under
|
39
|
+
* the terms of any one of the MPL, the GPL or the LGPL.
|
40
|
+
*
|
41
|
+
* ***** END LICENSE BLOCK ***** */
|
42
|
+
|
43
|
+
/* Data conversion between native and JavaScript types. */
|
44
|
+
|
45
|
+
#include "xpcprivate.h"
|
46
|
+
#include "nsString.h"
|
47
|
+
#include "XPCNativeWrapper.h"
|
48
|
+
#include "nsIAtom.h"
|
49
|
+
#include "XPCWrapper.h"
|
50
|
+
#include "nsJSPrincipals.h"
|
51
|
+
#include "nsWrapperCache.h"
|
52
|
+
|
53
|
+
//#define STRICT_CHECK_OF_UNICODE
|
54
|
+
#ifdef STRICT_CHECK_OF_UNICODE
|
55
|
+
#define ILLEGAL_RANGE(c) (0!=((c) & 0xFF80))
|
56
|
+
#else // STRICT_CHECK_OF_UNICODE
|
57
|
+
#define ILLEGAL_RANGE(c) (0!=((c) & 0xFF00))
|
58
|
+
#endif // STRICT_CHECK_OF_UNICODE
|
59
|
+
|
60
|
+
#define ILLEGAL_CHAR_RANGE(c) (0!=((c) & 0x80))
|
61
|
+
/*
|
62
|
+
* This is a table driven scheme to determine if the types of the params of the
|
63
|
+
* given method exclude that method from being reflected via XPConnect.
|
64
|
+
*
|
65
|
+
* The table can be appended and modified as requirements change. However...
|
66
|
+
*
|
67
|
+
* The table ASSUMES that all the type idenetifiers are contiguous starting
|
68
|
+
* at ZERO. And, it also ASSUMES that the additional criteria of whether or
|
69
|
+
* not a give type is reflectable are its use as a pointer and/or 'out' type.
|
70
|
+
*
|
71
|
+
* The table has a row for each type and columns for the combinations of
|
72
|
+
* that type being used as a pointer type and/or as an 'out' param.
|
73
|
+
*/
|
74
|
+
|
75
|
+
#define XPC_MK_BIT(p,o) (1 << (((p)?1:0)+((o)?2:0)))
|
76
|
+
#define XPC_IS_REFLECTABLE(f, p, o) ((f) & XPC_MK_BIT((p),(o)))
|
77
|
+
#define XPC_MK_FLAG(np_no,p_no,np_o,p_o) \
|
78
|
+
((uint8)((np_no) | ((p_no) << 1) | ((np_o) << 2) | ((p_o) << 3)))
|
79
|
+
|
80
|
+
/***********************************************************/
|
81
|
+
// xpt uses 5 bits for this info. We deal with the possibility that
|
82
|
+
// some new types might exist that we don't know about.
|
83
|
+
|
84
|
+
#define XPC_FLAG_COUNT (1 << 5)
|
85
|
+
|
86
|
+
/* '1' means 'reflectable'. '0' means 'not reflectable'. */
|
87
|
+
static uint8 xpc_reflectable_flags[XPC_FLAG_COUNT] = {
|
88
|
+
/* 'p' stands for 'pointer' and 'o' stands for 'out' */
|
89
|
+
/* !p&!o, p&!o, !p&o, p&o */
|
90
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_I8 */
|
91
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_I16 */
|
92
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_I32 */
|
93
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_I64 */
|
94
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_U8 */
|
95
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_U16 */
|
96
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_U32 */
|
97
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_U64 */
|
98
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_FLOAT */
|
99
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_DOUBLE */
|
100
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_BOOL */
|
101
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_CHAR */
|
102
|
+
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_WCHAR */
|
103
|
+
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* T_VOID */
|
104
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_IID */
|
105
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 0 ), /* T_DOMSTRING */
|
106
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_CHAR_STR */
|
107
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_WCHAR_STR */
|
108
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_INTERFACE */
|
109
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_INTERFACE_IS */
|
110
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_ARRAY */
|
111
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_PSTRING_SIZE_IS */
|
112
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_PWSTRING_SIZE_IS */
|
113
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 0 ), /* T_UTF8STRING */
|
114
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 0 ), /* T_CSTRING */
|
115
|
+
XPC_MK_FLAG( 0 , 1 , 0 , 0 ), /* T_ASTRING */
|
116
|
+
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 26 - reserved */
|
117
|
+
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 27 - reserved */
|
118
|
+
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 28 - reserved */
|
119
|
+
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 29 - reserved */
|
120
|
+
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 30 - reserved */
|
121
|
+
XPC_MK_FLAG( 0 , 0 , 0 , 0 ) /* 31 - reserved */
|
122
|
+
};
|
123
|
+
|
124
|
+
static intN sXPCOMUCStringFinalizerIndex = -1;
|
125
|
+
|
126
|
+
/***********************************************************/
|
127
|
+
|
128
|
+
// static
|
129
|
+
JSBool
|
130
|
+
XPCConvert::IsMethodReflectable(const XPTMethodDescriptor& info)
|
131
|
+
{
|
132
|
+
if(XPT_MD_IS_NOTXPCOM(info.flags) || XPT_MD_IS_HIDDEN(info.flags))
|
133
|
+
return JS_FALSE;
|
134
|
+
|
135
|
+
for(int i = info.num_args-1; i >= 0; i--)
|
136
|
+
{
|
137
|
+
const nsXPTParamInfo& param = info.params[i];
|
138
|
+
const nsXPTType& type = param.GetType();
|
139
|
+
|
140
|
+
uint8 base_type = type.TagPart();
|
141
|
+
NS_ASSERTION(base_type < XPC_FLAG_COUNT, "BAD TYPE");
|
142
|
+
|
143
|
+
if(!XPC_IS_REFLECTABLE(xpc_reflectable_flags[base_type],
|
144
|
+
type.IsPointer(), param.IsOut()))
|
145
|
+
return JS_FALSE;
|
146
|
+
}
|
147
|
+
return JS_TRUE;
|
148
|
+
}
|
149
|
+
|
150
|
+
/***************************************************************************/
|
151
|
+
|
152
|
+
// static
|
153
|
+
JSBool
|
154
|
+
XPCConvert::GetISupportsFromJSObject(JSObject* obj, nsISupports** iface)
|
155
|
+
{
|
156
|
+
JSClass* jsclass = STOBJ_GET_CLASS(obj);
|
157
|
+
NS_ASSERTION(jsclass, "obj has no class");
|
158
|
+
if(jsclass &&
|
159
|
+
(jsclass->flags & JSCLASS_HAS_PRIVATE) &&
|
160
|
+
(jsclass->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS))
|
161
|
+
{
|
162
|
+
*iface = (nsISupports*) xpc_GetJSPrivate(obj);
|
163
|
+
return JS_TRUE;
|
164
|
+
}
|
165
|
+
return JS_FALSE;
|
166
|
+
}
|
167
|
+
|
168
|
+
/***************************************************************************/
|
169
|
+
|
170
|
+
static void
|
171
|
+
FinalizeXPCOMUCString(JSContext *cx, JSString *str)
|
172
|
+
{
|
173
|
+
NS_ASSERTION(sXPCOMUCStringFinalizerIndex != -1,
|
174
|
+
"XPCConvert: XPCOM Unicode string finalizer called uninitialized!");
|
175
|
+
|
176
|
+
jschar* buffer = JS_GetStringChars(str);
|
177
|
+
nsMemory::Free(buffer);
|
178
|
+
}
|
179
|
+
|
180
|
+
|
181
|
+
static JSBool
|
182
|
+
AddXPCOMUCStringFinalizer()
|
183
|
+
{
|
184
|
+
|
185
|
+
sXPCOMUCStringFinalizerIndex =
|
186
|
+
JS_AddExternalStringFinalizer(FinalizeXPCOMUCString);
|
187
|
+
|
188
|
+
if(sXPCOMUCStringFinalizerIndex == -1)
|
189
|
+
{
|
190
|
+
return JS_FALSE;
|
191
|
+
}
|
192
|
+
|
193
|
+
return JS_TRUE;
|
194
|
+
}
|
195
|
+
|
196
|
+
//static
|
197
|
+
void
|
198
|
+
XPCConvert::RemoveXPCOMUCStringFinalizer()
|
199
|
+
{
|
200
|
+
JS_RemoveExternalStringFinalizer(FinalizeXPCOMUCString);
|
201
|
+
sXPCOMUCStringFinalizerIndex = -1;
|
202
|
+
}
|
203
|
+
|
204
|
+
|
205
|
+
#define FIT_32(cx,i,d) (INT_FITS_IN_JSVAL(i) \
|
206
|
+
? *d = INT_TO_JSVAL(i), JS_TRUE \
|
207
|
+
: JS_NewDoubleValue(cx, i, d))
|
208
|
+
|
209
|
+
#define FIT_U32(cx,i,d) ((i) <= JSVAL_INT_MAX \
|
210
|
+
? *d = INT_TO_JSVAL(i), JS_TRUE \
|
211
|
+
: JS_NewDoubleValue(cx, i, d))
|
212
|
+
|
213
|
+
/*
|
214
|
+
* Support for 64 bit conversions where 'long long' not supported.
|
215
|
+
* (from John Fairhurst <mjf35@cam.ac.uk>)
|
216
|
+
*/
|
217
|
+
|
218
|
+
#ifdef HAVE_LONG_LONG
|
219
|
+
|
220
|
+
#define INT64_TO_DOUBLE(i) ((jsdouble) (i))
|
221
|
+
// Win32 can't handle uint64 to double conversion
|
222
|
+
#define UINT64_TO_DOUBLE(u) ((jsdouble) (int64) (u))
|
223
|
+
|
224
|
+
#else
|
225
|
+
|
226
|
+
inline jsdouble
|
227
|
+
INT64_TO_DOUBLE(const int64 &v)
|
228
|
+
{
|
229
|
+
jsdouble d;
|
230
|
+
LL_L2D(d, v);
|
231
|
+
return d;
|
232
|
+
}
|
233
|
+
|
234
|
+
// if !HAVE_LONG_LONG, then uint64 is a typedef of int64
|
235
|
+
#define UINT64_TO_DOUBLE INT64_TO_DOUBLE
|
236
|
+
|
237
|
+
#endif
|
238
|
+
|
239
|
+
// static
|
240
|
+
JSBool
|
241
|
+
XPCConvert::NativeData2JS(XPCCallContext& ccx, jsval* d, const void* s,
|
242
|
+
const nsXPTType& type, const nsID* iid,
|
243
|
+
JSObject* scope, nsresult* pErr)
|
244
|
+
{
|
245
|
+
NS_PRECONDITION(s, "bad param");
|
246
|
+
NS_PRECONDITION(d, "bad param");
|
247
|
+
|
248
|
+
JSContext* cx = ccx.GetJSContext();
|
249
|
+
|
250
|
+
if(pErr)
|
251
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
|
252
|
+
|
253
|
+
switch(type.TagPart())
|
254
|
+
{
|
255
|
+
case nsXPTType::T_I8 : *d = INT_TO_JSVAL((int32)*((int8*)s)); break;
|
256
|
+
case nsXPTType::T_I16 : *d = INT_TO_JSVAL((int32)*((int16*)s)); break;
|
257
|
+
case nsXPTType::T_I32 : return FIT_32(cx,*((int32*)s),d);
|
258
|
+
case nsXPTType::T_I64 :
|
259
|
+
return JS_NewNumberValue(cx, INT64_TO_DOUBLE(*((int64*)s)), d);
|
260
|
+
case nsXPTType::T_U8 : *d = INT_TO_JSVAL((int32)*((uint8*)s)); break;
|
261
|
+
case nsXPTType::T_U16 : *d = INT_TO_JSVAL((int32)*((uint16*)s)); break;
|
262
|
+
case nsXPTType::T_U32 : return FIT_U32(cx,*((uint32*)s),d);
|
263
|
+
case nsXPTType::T_U64 :
|
264
|
+
return JS_NewNumberValue(cx, UINT64_TO_DOUBLE(*((uint64*)s)), d);
|
265
|
+
case nsXPTType::T_FLOAT : return JS_NewNumberValue(cx, *((float*)s), d);
|
266
|
+
case nsXPTType::T_DOUBLE: return JS_NewNumberValue(cx, *((double*)s), d);
|
267
|
+
case nsXPTType::T_BOOL : *d = *((PRBool*)s)?JSVAL_TRUE:JSVAL_FALSE; break;
|
268
|
+
case nsXPTType::T_CHAR :
|
269
|
+
{
|
270
|
+
char* p = (char*)s;
|
271
|
+
if(!p)
|
272
|
+
return JS_FALSE;
|
273
|
+
|
274
|
+
#ifdef STRICT_CHECK_OF_UNICODE
|
275
|
+
NS_ASSERTION(! ILLEGAL_CHAR_RANGE(p) , "passing non ASCII data");
|
276
|
+
#endif // STRICT_CHECK_OF_UNICODE
|
277
|
+
|
278
|
+
JSString* str;
|
279
|
+
if(!(str = JS_NewStringCopyN(cx, p, 1)))
|
280
|
+
return JS_FALSE;
|
281
|
+
*d = STRING_TO_JSVAL(str);
|
282
|
+
break;
|
283
|
+
}
|
284
|
+
case nsXPTType::T_WCHAR :
|
285
|
+
{
|
286
|
+
jschar* p = (jschar*)s;
|
287
|
+
if(!p)
|
288
|
+
return JS_FALSE;
|
289
|
+
JSString* str;
|
290
|
+
if(!(str = JS_NewUCStringCopyN(cx, p, 1)))
|
291
|
+
return JS_FALSE;
|
292
|
+
*d = STRING_TO_JSVAL(str);
|
293
|
+
break;
|
294
|
+
}
|
295
|
+
default:
|
296
|
+
if(!type.IsPointer())
|
297
|
+
{
|
298
|
+
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : unsupported type"));
|
299
|
+
return JS_FALSE;
|
300
|
+
}
|
301
|
+
|
302
|
+
// set the default result
|
303
|
+
*d = JSVAL_NULL;
|
304
|
+
|
305
|
+
switch(type.TagPart())
|
306
|
+
{
|
307
|
+
case nsXPTType::T_VOID:
|
308
|
+
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : void* params not supported"));
|
309
|
+
return JS_FALSE;
|
310
|
+
|
311
|
+
case nsXPTType::T_IID:
|
312
|
+
{
|
313
|
+
nsID* iid2 = *((nsID**)s);
|
314
|
+
if(!iid2)
|
315
|
+
break;
|
316
|
+
JSObject* obj;
|
317
|
+
if(!(obj = xpc_NewIDObject(cx, scope, *iid2)))
|
318
|
+
return JS_FALSE;
|
319
|
+
*d = OBJECT_TO_JSVAL(obj);
|
320
|
+
break;
|
321
|
+
}
|
322
|
+
|
323
|
+
case nsXPTType::T_ASTRING:
|
324
|
+
// Fall through to T_DOMSTRING case
|
325
|
+
|
326
|
+
case nsXPTType::T_DOMSTRING:
|
327
|
+
{
|
328
|
+
const nsAString* p = *((const nsAString**)s);
|
329
|
+
if(!p)
|
330
|
+
break;
|
331
|
+
|
332
|
+
if(!p->IsVoid()) {
|
333
|
+
JSString *str =
|
334
|
+
XPCStringConvert::ReadableToJSString(cx, *p);
|
335
|
+
if(!str)
|
336
|
+
return JS_FALSE;
|
337
|
+
|
338
|
+
*d = STRING_TO_JSVAL(str);
|
339
|
+
}
|
340
|
+
|
341
|
+
// *d is defaulted to JSVAL_NULL so no need to set it
|
342
|
+
// again if p is a "void" string
|
343
|
+
|
344
|
+
break;
|
345
|
+
}
|
346
|
+
|
347
|
+
case nsXPTType::T_CHAR_STR:
|
348
|
+
{
|
349
|
+
char* p = *((char**)s);
|
350
|
+
if(!p)
|
351
|
+
break;
|
352
|
+
|
353
|
+
#ifdef STRICT_CHECK_OF_UNICODE
|
354
|
+
PRBool isAscii = PR_TRUE;
|
355
|
+
char* t;
|
356
|
+
for(t=p; *t && isAscii ; t++) {
|
357
|
+
if(ILLEGAL_CHAR_RANGE(*t))
|
358
|
+
isAscii = PR_FALSE;
|
359
|
+
}
|
360
|
+
NS_ASSERTION(isAscii, "passing non ASCII data");
|
361
|
+
#endif // STRICT_CHECK_OF_UNICODE
|
362
|
+
JSString* str;
|
363
|
+
if(!(str = JS_NewStringCopyZ(cx, p)))
|
364
|
+
return JS_FALSE;
|
365
|
+
*d = STRING_TO_JSVAL(str);
|
366
|
+
break;
|
367
|
+
}
|
368
|
+
|
369
|
+
case nsXPTType::T_WCHAR_STR:
|
370
|
+
{
|
371
|
+
jschar* p = *((jschar**)s);
|
372
|
+
if(!p)
|
373
|
+
break;
|
374
|
+
JSString* str;
|
375
|
+
if(!(str = JS_NewUCStringCopyZ(cx, p)))
|
376
|
+
return JS_FALSE;
|
377
|
+
*d = STRING_TO_JSVAL(str);
|
378
|
+
break;
|
379
|
+
}
|
380
|
+
case nsXPTType::T_UTF8STRING:
|
381
|
+
{
|
382
|
+
const nsACString* cString = *((const nsACString**)s);
|
383
|
+
|
384
|
+
if(!cString)
|
385
|
+
break;
|
386
|
+
|
387
|
+
if(!cString->IsVoid())
|
388
|
+
{
|
389
|
+
PRUint32 len;
|
390
|
+
jschar *p = (jschar *)UTF8ToNewUnicode(*cString, &len);
|
391
|
+
|
392
|
+
if(!p)
|
393
|
+
return JS_FALSE;
|
394
|
+
|
395
|
+
if(sXPCOMUCStringFinalizerIndex == -1 &&
|
396
|
+
!AddXPCOMUCStringFinalizer())
|
397
|
+
return JS_FALSE;
|
398
|
+
|
399
|
+
JSString* jsString =
|
400
|
+
JS_NewExternalString(cx, p, len,
|
401
|
+
sXPCOMUCStringFinalizerIndex);
|
402
|
+
|
403
|
+
if(!jsString) {
|
404
|
+
nsMemory::Free(p);
|
405
|
+
return JS_FALSE;
|
406
|
+
}
|
407
|
+
|
408
|
+
*d = STRING_TO_JSVAL(jsString);
|
409
|
+
}
|
410
|
+
|
411
|
+
break;
|
412
|
+
|
413
|
+
}
|
414
|
+
case nsXPTType::T_CSTRING:
|
415
|
+
{
|
416
|
+
const nsACString* cString = *((const nsACString**)s);
|
417
|
+
|
418
|
+
if(!cString)
|
419
|
+
break;
|
420
|
+
|
421
|
+
if(!cString->IsVoid())
|
422
|
+
{
|
423
|
+
PRUnichar* unicodeString = ToNewUnicode(*cString);
|
424
|
+
if(!unicodeString)
|
425
|
+
return JS_FALSE;
|
426
|
+
|
427
|
+
if(sXPCOMUCStringFinalizerIndex == -1 &&
|
428
|
+
!AddXPCOMUCStringFinalizer())
|
429
|
+
return JS_FALSE;
|
430
|
+
|
431
|
+
JSString* jsString = JS_NewExternalString(cx,
|
432
|
+
(jschar*)unicodeString,
|
433
|
+
cString->Length(),
|
434
|
+
sXPCOMUCStringFinalizerIndex);
|
435
|
+
|
436
|
+
if(!jsString)
|
437
|
+
{
|
438
|
+
nsMemory::Free(unicodeString);
|
439
|
+
return JS_FALSE;
|
440
|
+
}
|
441
|
+
|
442
|
+
*d = STRING_TO_JSVAL(jsString);
|
443
|
+
}
|
444
|
+
|
445
|
+
break;
|
446
|
+
}
|
447
|
+
|
448
|
+
case nsXPTType::T_INTERFACE:
|
449
|
+
case nsXPTType::T_INTERFACE_IS:
|
450
|
+
{
|
451
|
+
nsISupports* iface = *((nsISupports**)s);
|
452
|
+
if(iface)
|
453
|
+
{
|
454
|
+
if(iid->Equals(NS_GET_IID(nsIVariant)))
|
455
|
+
{
|
456
|
+
nsCOMPtr<nsIVariant> variant = do_QueryInterface(iface);
|
457
|
+
if(!variant)
|
458
|
+
return JS_FALSE;
|
459
|
+
|
460
|
+
return XPCVariant::VariantDataToJS(ccx, variant,
|
461
|
+
scope, pErr, d);
|
462
|
+
}
|
463
|
+
// else...
|
464
|
+
|
465
|
+
// XXX The OBJ_IS_NOT_GLOBAL here is not really right. In
|
466
|
+
// fact, this code is depending on the fact that the
|
467
|
+
// global object will not have been collected, and
|
468
|
+
// therefore this NativeInterface2JSObject will not end up
|
469
|
+
// creating a new XPCNativeScriptableShared.
|
470
|
+
if(!NativeInterface2JSObject(ccx, d, nsnull, iface, iid,
|
471
|
+
nsnull, nsnull, scope, PR_TRUE,
|
472
|
+
OBJ_IS_NOT_GLOBAL, pErr))
|
473
|
+
return JS_FALSE;
|
474
|
+
|
475
|
+
#ifdef DEBUG
|
476
|
+
JSObject* jsobj = JSVAL_TO_OBJECT(*d);
|
477
|
+
if(jsobj && !STOBJ_GET_PARENT(jsobj))
|
478
|
+
NS_ASSERTION(STOBJ_GET_CLASS(jsobj)->flags & JSCLASS_IS_GLOBAL,
|
479
|
+
"Why did we recreate this wrapper?");
|
480
|
+
#endif
|
481
|
+
}
|
482
|
+
break;
|
483
|
+
}
|
484
|
+
default:
|
485
|
+
NS_ASSERTION(0, "bad type");
|
486
|
+
return JS_FALSE;
|
487
|
+
}
|
488
|
+
}
|
489
|
+
return JS_TRUE;
|
490
|
+
}
|
491
|
+
|
492
|
+
/***************************************************************************/
|
493
|
+
|
494
|
+
// static
|
495
|
+
JSBool
|
496
|
+
XPCConvert::JSData2Native(XPCCallContext& ccx, void* d, jsval s,
|
497
|
+
const nsXPTType& type,
|
498
|
+
JSBool useAllocator, const nsID* iid,
|
499
|
+
nsresult* pErr)
|
500
|
+
{
|
501
|
+
NS_PRECONDITION(d, "bad param");
|
502
|
+
|
503
|
+
JSContext* cx = ccx.GetJSContext();
|
504
|
+
|
505
|
+
int32 ti;
|
506
|
+
uint32 tu;
|
507
|
+
jsdouble td;
|
508
|
+
JSBool isDOMString = JS_TRUE;
|
509
|
+
|
510
|
+
if(pErr)
|
511
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
|
512
|
+
|
513
|
+
switch(type.TagPart())
|
514
|
+
{
|
515
|
+
case nsXPTType::T_I8 :
|
516
|
+
if(!JS_ValueToECMAInt32(cx, s, &ti))
|
517
|
+
return JS_FALSE;
|
518
|
+
*((int8*)d) = (int8) ti;
|
519
|
+
break;
|
520
|
+
case nsXPTType::T_I16 :
|
521
|
+
if(!JS_ValueToECMAInt32(cx, s, &ti))
|
522
|
+
return JS_FALSE;
|
523
|
+
*((int16*)d) = (int16) ti;
|
524
|
+
break;
|
525
|
+
case nsXPTType::T_I32 :
|
526
|
+
if(!JS_ValueToECMAInt32(cx, s, (int32*)d))
|
527
|
+
return JS_FALSE;
|
528
|
+
break;
|
529
|
+
case nsXPTType::T_I64 :
|
530
|
+
if(JSVAL_IS_INT(s))
|
531
|
+
{
|
532
|
+
if(!JS_ValueToECMAInt32(cx, s, &ti))
|
533
|
+
return JS_FALSE;
|
534
|
+
LL_I2L(*((int64*)d),ti);
|
535
|
+
|
536
|
+
}
|
537
|
+
else
|
538
|
+
{
|
539
|
+
if(!JS_ValueToNumber(cx, s, &td))
|
540
|
+
return JS_FALSE;
|
541
|
+
LL_D2L(*((int64*)d),td);
|
542
|
+
}
|
543
|
+
break;
|
544
|
+
case nsXPTType::T_U8 :
|
545
|
+
if(!JS_ValueToECMAUint32(cx, s, &tu))
|
546
|
+
return JS_FALSE;
|
547
|
+
*((uint8*)d) = (uint8) tu;
|
548
|
+
break;
|
549
|
+
case nsXPTType::T_U16 :
|
550
|
+
if(!JS_ValueToECMAUint32(cx, s, &tu))
|
551
|
+
return JS_FALSE;
|
552
|
+
*((uint16*)d) = (uint16) tu;
|
553
|
+
break;
|
554
|
+
case nsXPTType::T_U32 :
|
555
|
+
if(!JS_ValueToECMAUint32(cx, s, (uint32*)d))
|
556
|
+
return JS_FALSE;
|
557
|
+
break;
|
558
|
+
case nsXPTType::T_U64 :
|
559
|
+
if(JSVAL_IS_INT(s))
|
560
|
+
{
|
561
|
+
if(!JS_ValueToECMAUint32(cx, s, &tu))
|
562
|
+
return JS_FALSE;
|
563
|
+
LL_UI2L(*((int64*)d),tu);
|
564
|
+
}
|
565
|
+
else
|
566
|
+
{
|
567
|
+
if(!JS_ValueToNumber(cx, s, &td))
|
568
|
+
return JS_FALSE;
|
569
|
+
#ifdef XP_WIN
|
570
|
+
// Note: Win32 can't handle double to uint64 directly
|
571
|
+
*((uint64*)d) = (uint64)((int64) td);
|
572
|
+
#else
|
573
|
+
LL_D2L(*((uint64*)d),td);
|
574
|
+
#endif
|
575
|
+
}
|
576
|
+
break;
|
577
|
+
case nsXPTType::T_FLOAT :
|
578
|
+
if(!JS_ValueToNumber(cx, s, &td))
|
579
|
+
return JS_FALSE;
|
580
|
+
*((float*)d) = (float) td;
|
581
|
+
break;
|
582
|
+
case nsXPTType::T_DOUBLE :
|
583
|
+
if(!JS_ValueToNumber(cx, s, (double*)d))
|
584
|
+
return JS_FALSE;
|
585
|
+
break;
|
586
|
+
case nsXPTType::T_BOOL :
|
587
|
+
if(!JS_ValueToBoolean(cx, s, (JSBool*)d))
|
588
|
+
return JS_FALSE;
|
589
|
+
break;
|
590
|
+
case nsXPTType::T_CHAR :
|
591
|
+
{
|
592
|
+
char* bytes=nsnull;
|
593
|
+
JSString* str;
|
594
|
+
|
595
|
+
if(!(str = JS_ValueToString(cx, s))||
|
596
|
+
!(bytes = JS_GetStringBytes(str)))
|
597
|
+
{
|
598
|
+
return JS_FALSE;
|
599
|
+
}
|
600
|
+
#ifdef DEBUG
|
601
|
+
jschar* chars=nsnull;
|
602
|
+
if(nsnull!=(chars = JS_GetStringChars(str)))
|
603
|
+
{
|
604
|
+
NS_ASSERTION((! ILLEGAL_RANGE(chars[0])),"U+0080/U+0100 - U+FFFF data lost");
|
605
|
+
}
|
606
|
+
#endif // DEBUG
|
607
|
+
*((char*)d) = bytes[0];
|
608
|
+
break;
|
609
|
+
}
|
610
|
+
case nsXPTType::T_WCHAR :
|
611
|
+
{
|
612
|
+
jschar* chars=nsnull;
|
613
|
+
JSString* str;
|
614
|
+
if(!(str = JS_ValueToString(cx, s))||
|
615
|
+
!(chars = JS_GetStringChars(str)))
|
616
|
+
{
|
617
|
+
return JS_FALSE;
|
618
|
+
}
|
619
|
+
*((uint16*)d) = (uint16) chars[0];
|
620
|
+
break;
|
621
|
+
}
|
622
|
+
default:
|
623
|
+
if(!type.IsPointer())
|
624
|
+
{
|
625
|
+
NS_ASSERTION(0,"unsupported type");
|
626
|
+
return JS_FALSE;
|
627
|
+
}
|
628
|
+
|
629
|
+
switch(type.TagPart())
|
630
|
+
{
|
631
|
+
case nsXPTType::T_VOID:
|
632
|
+
XPC_LOG_ERROR(("XPCConvert::JSData2Native : void* params not supported"));
|
633
|
+
NS_ASSERTION(0,"void* params not supported");
|
634
|
+
return JS_FALSE;
|
635
|
+
case nsXPTType::T_IID:
|
636
|
+
{
|
637
|
+
NS_ASSERTION(useAllocator,"trying to convert a JSID to nsID without allocator : this would leak");
|
638
|
+
|
639
|
+
JSObject* obj;
|
640
|
+
const nsID* pid=nsnull;
|
641
|
+
|
642
|
+
if(JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
|
643
|
+
{
|
644
|
+
if(type.IsReference())
|
645
|
+
{
|
646
|
+
if(pErr)
|
647
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
|
648
|
+
return JS_FALSE;
|
649
|
+
}
|
650
|
+
// else ...
|
651
|
+
*((const nsID**)d) = nsnull;
|
652
|
+
return JS_TRUE;
|
653
|
+
}
|
654
|
+
|
655
|
+
if(!JSVAL_IS_OBJECT(s) ||
|
656
|
+
(!(obj = JSVAL_TO_OBJECT(s))) ||
|
657
|
+
(!(pid = xpc_JSObjectToID(cx, obj))) ||
|
658
|
+
(!(pid = (const nsID*) nsMemory::Clone(pid, sizeof(nsID)))))
|
659
|
+
{
|
660
|
+
return JS_FALSE;
|
661
|
+
}
|
662
|
+
*((const nsID**)d) = pid;
|
663
|
+
return JS_TRUE;
|
664
|
+
}
|
665
|
+
|
666
|
+
case nsXPTType::T_ASTRING:
|
667
|
+
{
|
668
|
+
isDOMString = JS_FALSE;
|
669
|
+
// Fall through to T_DOMSTRING case.
|
670
|
+
}
|
671
|
+
case nsXPTType::T_DOMSTRING:
|
672
|
+
{
|
673
|
+
static const PRUnichar EMPTY_STRING[] = { '\0' };
|
674
|
+
static const PRUnichar VOID_STRING[] = { 'u', 'n', 'd', 'e', 'f', 'i', 'n', 'e', 'd', '\0' };
|
675
|
+
|
676
|
+
const PRUnichar* chars;
|
677
|
+
JSString* str = nsnull;
|
678
|
+
JSBool isNewString = JS_FALSE;
|
679
|
+
PRUint32 length;
|
680
|
+
|
681
|
+
if(JSVAL_IS_VOID(s))
|
682
|
+
{
|
683
|
+
if(isDOMString)
|
684
|
+
{
|
685
|
+
chars = VOID_STRING;
|
686
|
+
length = NS_ARRAY_LENGTH(VOID_STRING) - 1;
|
687
|
+
}
|
688
|
+
else
|
689
|
+
{
|
690
|
+
chars = EMPTY_STRING;
|
691
|
+
length = 0;
|
692
|
+
}
|
693
|
+
}
|
694
|
+
else if(!JSVAL_IS_NULL(s))
|
695
|
+
{
|
696
|
+
str = JS_ValueToString(cx, s);
|
697
|
+
if(!str)
|
698
|
+
return JS_FALSE;
|
699
|
+
|
700
|
+
length = (PRUint32) JS_GetStringLength(str);
|
701
|
+
if(length)
|
702
|
+
{
|
703
|
+
chars = (const PRUnichar*) JS_GetStringChars(str);
|
704
|
+
if(!chars)
|
705
|
+
return JS_FALSE;
|
706
|
+
if(STRING_TO_JSVAL(str) != s)
|
707
|
+
isNewString = JS_TRUE;
|
708
|
+
}
|
709
|
+
else
|
710
|
+
{
|
711
|
+
str = nsnull;
|
712
|
+
chars = EMPTY_STRING;
|
713
|
+
}
|
714
|
+
}
|
715
|
+
|
716
|
+
if(useAllocator)
|
717
|
+
{
|
718
|
+
// XXX extra string copy when isNewString
|
719
|
+
if(str && !isNewString)
|
720
|
+
{
|
721
|
+
XPCReadableJSStringWrapper *wrapper =
|
722
|
+
XPCStringConvert::JSStringToReadable(ccx, str);
|
723
|
+
if(!wrapper)
|
724
|
+
return JS_FALSE;
|
725
|
+
|
726
|
+
*((const nsAString**)d) = wrapper;
|
727
|
+
}
|
728
|
+
else if(JSVAL_IS_NULL(s))
|
729
|
+
{
|
730
|
+
XPCReadableJSStringWrapper *wrapper =
|
731
|
+
new XPCReadableJSStringWrapper();
|
732
|
+
if(!wrapper)
|
733
|
+
return JS_FALSE;
|
734
|
+
|
735
|
+
*((const nsAString**)d) = wrapper;
|
736
|
+
}
|
737
|
+
else
|
738
|
+
{
|
739
|
+
// use nsString to encourage sharing
|
740
|
+
const nsAString *rs = new nsString(chars, length);
|
741
|
+
if(!rs)
|
742
|
+
return JS_FALSE;
|
743
|
+
*((const nsAString**)d) = rs;
|
744
|
+
}
|
745
|
+
}
|
746
|
+
else
|
747
|
+
{
|
748
|
+
nsAString* ws = *((nsAString**)d);
|
749
|
+
|
750
|
+
if(JSVAL_IS_NULL(s) || (!isDOMString && JSVAL_IS_VOID(s)))
|
751
|
+
{
|
752
|
+
ws->Truncate();
|
753
|
+
ws->SetIsVoid(PR_TRUE);
|
754
|
+
}
|
755
|
+
else
|
756
|
+
ws->Assign(chars, length);
|
757
|
+
}
|
758
|
+
return JS_TRUE;
|
759
|
+
}
|
760
|
+
|
761
|
+
case nsXPTType::T_CHAR_STR:
|
762
|
+
{
|
763
|
+
char* bytes=nsnull;
|
764
|
+
JSString* str;
|
765
|
+
|
766
|
+
if(JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
|
767
|
+
{
|
768
|
+
if(type.IsReference())
|
769
|
+
{
|
770
|
+
if(pErr)
|
771
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
|
772
|
+
return JS_FALSE;
|
773
|
+
}
|
774
|
+
// else ...
|
775
|
+
*((char**)d) = nsnull;
|
776
|
+
return JS_TRUE;
|
777
|
+
}
|
778
|
+
|
779
|
+
if(!(str = JS_ValueToString(cx, s))||
|
780
|
+
!(bytes = JS_GetStringBytes(str)))
|
781
|
+
{
|
782
|
+
return JS_FALSE;
|
783
|
+
}
|
784
|
+
#ifdef DEBUG
|
785
|
+
jschar* chars=nsnull;
|
786
|
+
if(nsnull != (chars = JS_GetStringChars(str)))
|
787
|
+
{
|
788
|
+
PRBool legalRange = PR_TRUE;
|
789
|
+
int len = JS_GetStringLength(str);
|
790
|
+
jschar* t;
|
791
|
+
PRInt32 i=0;
|
792
|
+
for(t=chars; (i< len) && legalRange ; i++,t++) {
|
793
|
+
if(ILLEGAL_RANGE(*t))
|
794
|
+
legalRange = PR_FALSE;
|
795
|
+
}
|
796
|
+
NS_ASSERTION(legalRange,"U+0080/U+0100 - U+FFFF data lost");
|
797
|
+
}
|
798
|
+
#endif // DEBUG
|
799
|
+
if(useAllocator)
|
800
|
+
{
|
801
|
+
int len = (JS_GetStringLength(str) + 1) * sizeof(char);
|
802
|
+
if(!(*((void**)d) = nsMemory::Alloc(len)))
|
803
|
+
{
|
804
|
+
return JS_FALSE;
|
805
|
+
}
|
806
|
+
memcpy(*((void**)d), bytes, len);
|
807
|
+
}
|
808
|
+
else
|
809
|
+
*((char**)d) = bytes;
|
810
|
+
|
811
|
+
return JS_TRUE;
|
812
|
+
}
|
813
|
+
|
814
|
+
case nsXPTType::T_WCHAR_STR:
|
815
|
+
{
|
816
|
+
jschar* chars=nsnull;
|
817
|
+
JSString* str;
|
818
|
+
|
819
|
+
if(JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
|
820
|
+
{
|
821
|
+
if(type.IsReference())
|
822
|
+
{
|
823
|
+
if(pErr)
|
824
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
|
825
|
+
return JS_FALSE;
|
826
|
+
}
|
827
|
+
// else ...
|
828
|
+
*((jschar**)d) = nsnull;
|
829
|
+
return JS_TRUE;
|
830
|
+
}
|
831
|
+
|
832
|
+
if(!(str = JS_ValueToString(cx, s))||
|
833
|
+
!(chars = JS_GetStringChars(str)))
|
834
|
+
{
|
835
|
+
return JS_FALSE;
|
836
|
+
}
|
837
|
+
if(useAllocator)
|
838
|
+
{
|
839
|
+
int byte_len = (JS_GetStringLength(str)+1)*sizeof(jschar);
|
840
|
+
if(!(*((void**)d) = nsMemory::Alloc(byte_len)))
|
841
|
+
{
|
842
|
+
// XXX should report error
|
843
|
+
return JS_FALSE;
|
844
|
+
}
|
845
|
+
memcpy(*((void**)d), chars, byte_len);
|
846
|
+
}
|
847
|
+
else
|
848
|
+
*((jschar**)d) = chars;
|
849
|
+
|
850
|
+
return JS_TRUE;
|
851
|
+
}
|
852
|
+
|
853
|
+
case nsXPTType::T_UTF8STRING:
|
854
|
+
{
|
855
|
+
jschar* chars;
|
856
|
+
PRUint32 length;
|
857
|
+
JSString* str;
|
858
|
+
|
859
|
+
if(JSVAL_IS_NULL(s) || JSVAL_IS_VOID(s))
|
860
|
+
{
|
861
|
+
if(useAllocator)
|
862
|
+
{
|
863
|
+
nsACString *rs = new nsCString();
|
864
|
+
if(!rs)
|
865
|
+
return JS_FALSE;
|
866
|
+
|
867
|
+
rs->SetIsVoid(PR_TRUE);
|
868
|
+
*((nsACString**)d) = rs;
|
869
|
+
}
|
870
|
+
else
|
871
|
+
{
|
872
|
+
nsCString* rs = *((nsCString**)d);
|
873
|
+
rs->Truncate();
|
874
|
+
rs->SetIsVoid(PR_TRUE);
|
875
|
+
}
|
876
|
+
return JS_TRUE;
|
877
|
+
}
|
878
|
+
|
879
|
+
// The JS val is neither null nor void...
|
880
|
+
|
881
|
+
if(!(str = JS_ValueToString(cx, s))||
|
882
|
+
!(chars = JS_GetStringChars(str)))
|
883
|
+
{
|
884
|
+
return JS_FALSE;
|
885
|
+
}
|
886
|
+
|
887
|
+
length = JS_GetStringLength(str);
|
888
|
+
|
889
|
+
nsCString *rs;
|
890
|
+
if(useAllocator)
|
891
|
+
{
|
892
|
+
// Use nsCString to enable sharing
|
893
|
+
rs = new nsCString();
|
894
|
+
if(!rs)
|
895
|
+
return JS_FALSE;
|
896
|
+
|
897
|
+
*((const nsCString**)d) = rs;
|
898
|
+
}
|
899
|
+
else
|
900
|
+
{
|
901
|
+
rs = *((nsCString**)d);
|
902
|
+
}
|
903
|
+
CopyUTF16toUTF8(nsDependentString((const PRUnichar*)chars, length),
|
904
|
+
*rs);
|
905
|
+
return JS_TRUE;
|
906
|
+
}
|
907
|
+
|
908
|
+
case nsXPTType::T_CSTRING:
|
909
|
+
{
|
910
|
+
const char* chars;
|
911
|
+
PRUint32 length;
|
912
|
+
JSString* str;
|
913
|
+
|
914
|
+
if(JSVAL_IS_NULL(s) || JSVAL_IS_VOID(s))
|
915
|
+
{
|
916
|
+
if(useAllocator)
|
917
|
+
{
|
918
|
+
nsACString *rs = new nsCString();
|
919
|
+
if(!rs)
|
920
|
+
return JS_FALSE;
|
921
|
+
|
922
|
+
rs->SetIsVoid(PR_TRUE);
|
923
|
+
*((nsACString**)d) = rs;
|
924
|
+
}
|
925
|
+
else
|
926
|
+
{
|
927
|
+
nsACString* rs = *((nsACString**)d);
|
928
|
+
rs->Truncate();
|
929
|
+
rs->SetIsVoid(PR_TRUE);
|
930
|
+
}
|
931
|
+
return JS_TRUE;
|
932
|
+
}
|
933
|
+
|
934
|
+
// The JS val is neither null nor void...
|
935
|
+
|
936
|
+
if(!(str = JS_ValueToString(cx, s)) ||
|
937
|
+
!(chars = JS_GetStringBytes(str)))
|
938
|
+
{
|
939
|
+
return JS_FALSE;
|
940
|
+
}
|
941
|
+
|
942
|
+
length = JS_GetStringLength(str);
|
943
|
+
|
944
|
+
if(useAllocator)
|
945
|
+
{
|
946
|
+
const nsACString *rs = new nsCString(chars, length);
|
947
|
+
|
948
|
+
if(!rs)
|
949
|
+
return JS_FALSE;
|
950
|
+
|
951
|
+
*((const nsACString**)d) = rs;
|
952
|
+
}
|
953
|
+
else
|
954
|
+
{
|
955
|
+
nsACString* rs = *((nsACString**)d);
|
956
|
+
|
957
|
+
rs->Assign(nsDependentCString(chars, length));
|
958
|
+
}
|
959
|
+
return JS_TRUE;
|
960
|
+
}
|
961
|
+
|
962
|
+
case nsXPTType::T_INTERFACE:
|
963
|
+
case nsXPTType::T_INTERFACE_IS:
|
964
|
+
{
|
965
|
+
JSObject* obj;
|
966
|
+
NS_ASSERTION(iid,"can't do interface conversions without iid");
|
967
|
+
|
968
|
+
if(iid->Equals(NS_GET_IID(nsIVariant)))
|
969
|
+
{
|
970
|
+
XPCVariant* variant = XPCVariant::newVariant(ccx, s);
|
971
|
+
if(!variant)
|
972
|
+
return JS_FALSE;
|
973
|
+
*((nsISupports**)d) = static_cast<nsIVariant*>(variant);
|
974
|
+
return JS_TRUE;
|
975
|
+
}
|
976
|
+
else if(iid->Equals(NS_GET_IID(nsIAtom)) &&
|
977
|
+
JSVAL_IS_STRING(s))
|
978
|
+
{
|
979
|
+
// We're trying to pass a string as an nsIAtom. Let's atomize!
|
980
|
+
JSString* str = JSVAL_TO_STRING(s);
|
981
|
+
PRUnichar* chars =
|
982
|
+
reinterpret_cast<PRUnichar*>(JS_GetStringChars(str));
|
983
|
+
if (!chars) {
|
984
|
+
if (pErr)
|
985
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
|
986
|
+
return JS_FALSE;
|
987
|
+
}
|
988
|
+
PRUint32 length = JS_GetStringLength(str);
|
989
|
+
nsIAtom* atom = NS_NewAtom(nsDependentString(chars, length));
|
990
|
+
if (!atom && pErr)
|
991
|
+
*pErr = NS_ERROR_OUT_OF_MEMORY;
|
992
|
+
*((nsISupports**)d) = atom;
|
993
|
+
return atom != nsnull;
|
994
|
+
}
|
995
|
+
//else ...
|
996
|
+
|
997
|
+
if(JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
|
998
|
+
{
|
999
|
+
if(type.IsReference())
|
1000
|
+
{
|
1001
|
+
if(pErr)
|
1002
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
|
1003
|
+
return JS_FALSE;
|
1004
|
+
}
|
1005
|
+
// else ...
|
1006
|
+
*((nsISupports**)d) = nsnull;
|
1007
|
+
return JS_TRUE;
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
// only wrap JSObjects
|
1011
|
+
if(!JSVAL_IS_OBJECT(s) || !(obj = JSVAL_TO_OBJECT(s)))
|
1012
|
+
{
|
1013
|
+
if(pErr && JSVAL_IS_INT(s) && 0 == JSVAL_TO_INT(s))
|
1014
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_ZERO_ISNOT_NULL;
|
1015
|
+
return JS_FALSE;
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
return JSObject2NativeInterface(ccx, (void**)d, obj, iid,
|
1019
|
+
nsnull, pErr);
|
1020
|
+
}
|
1021
|
+
default:
|
1022
|
+
NS_ASSERTION(0, "bad type");
|
1023
|
+
return JS_FALSE;
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
return JS_TRUE;
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
inline JSBool
|
1030
|
+
CreateHolderIfNeeded(XPCCallContext& ccx, JSObject* obj, jsval* d,
|
1031
|
+
nsIXPConnectJSObjectHolder** dest)
|
1032
|
+
{
|
1033
|
+
if(dest)
|
1034
|
+
{
|
1035
|
+
XPCJSObjectHolder* objHolder = XPCJSObjectHolder::newHolder(ccx, obj);
|
1036
|
+
if(!objHolder)
|
1037
|
+
return JS_FALSE;
|
1038
|
+
|
1039
|
+
NS_ADDREF(*dest = objHolder);
|
1040
|
+
}
|
1041
|
+
|
1042
|
+
*d = OBJECT_TO_JSVAL(obj);
|
1043
|
+
|
1044
|
+
return JS_TRUE;
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
/***************************************************************************/
|
1048
|
+
// static
|
1049
|
+
JSBool
|
1050
|
+
XPCConvert::NativeInterface2JSObject(XPCCallContext& ccx,
|
1051
|
+
jsval* d,
|
1052
|
+
nsIXPConnectJSObjectHolder** dest,
|
1053
|
+
nsISupports* src,
|
1054
|
+
const nsID* iid,
|
1055
|
+
XPCNativeInterface* Interface,
|
1056
|
+
nsWrapperCache *cache,
|
1057
|
+
JSObject* scope,
|
1058
|
+
PRBool allowNativeWrapper,
|
1059
|
+
PRBool isGlobal,
|
1060
|
+
nsresult* pErr)
|
1061
|
+
{
|
1062
|
+
NS_ASSERTION(scope, "bad param");
|
1063
|
+
|
1064
|
+
*d = JSVAL_NULL;
|
1065
|
+
if(dest)
|
1066
|
+
*dest = nsnull;
|
1067
|
+
if(!src)
|
1068
|
+
return JS_TRUE;
|
1069
|
+
if(pErr)
|
1070
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
|
1071
|
+
|
1072
|
+
// #define this if we want to 'double wrap' of JSObjects.
|
1073
|
+
// This is for the case where we have a JSObject wrapped for native use
|
1074
|
+
// which needs to be converted to a JSObject. Originally, we were unwrapping
|
1075
|
+
// and just exposing the underlying JSObject. This causes anomolies when
|
1076
|
+
// JSComponents are accessed from other JS code - they don't act like
|
1077
|
+
// other xpconnect wrapped components. Eventually we want to build a new
|
1078
|
+
// kind of wrapper especially for JS <-> JS. For now we are building a wrapper
|
1079
|
+
// around a wrapper. This is not optimal, but good enough for now.
|
1080
|
+
#define XPC_DO_DOUBLE_WRAP 1
|
1081
|
+
|
1082
|
+
#ifndef XPC_DO_DOUBLE_WRAP
|
1083
|
+
// is this a wrapped JS object?
|
1084
|
+
if(nsXPCWrappedJSClass::IsWrappedJS(src))
|
1085
|
+
{
|
1086
|
+
NS_ASSERTION(!isGlobal, "The global object must be native");
|
1087
|
+
|
1088
|
+
// verify that this wrapper is for the right interface
|
1089
|
+
nsCOMPtr<nsISupports> wrapper;
|
1090
|
+
if(Interface)
|
1091
|
+
src->QueryInterface(*Interface->GetIID(),
|
1092
|
+
(void**)getter_AddRefs(wrapper));
|
1093
|
+
else if(iid)
|
1094
|
+
src->QueryInterface(*iid, (void**)getter_AddRefs(wrapper));
|
1095
|
+
else
|
1096
|
+
wrapper = do_QueryInterface(src);
|
1097
|
+
nsCOMPtr<nsIXPConnectJSObjectHolder> holder =
|
1098
|
+
do_QueryInterface(wrapper);
|
1099
|
+
JSObject* flat;
|
1100
|
+
if(!holder || !(flat = holder->GetFlatJSObject()))
|
1101
|
+
return JS_FALSE;
|
1102
|
+
|
1103
|
+
*d = OBJECT_TO_JSVAL(flat);
|
1104
|
+
if(dest)
|
1105
|
+
holder.swap(*dest);
|
1106
|
+
return JS_TRUE;
|
1107
|
+
}
|
1108
|
+
else
|
1109
|
+
#endif /* XPC_DO_DOUBLE_WRAP */
|
1110
|
+
{
|
1111
|
+
XPCWrappedNativeScope* xpcscope =
|
1112
|
+
XPCWrappedNativeScope::FindInJSObjectScope(ccx, scope);
|
1113
|
+
if(!xpcscope)
|
1114
|
+
return JS_FALSE;
|
1115
|
+
|
1116
|
+
AutoMarkingNativeInterfacePtr iface(ccx, Interface);
|
1117
|
+
if(!iface && iid)
|
1118
|
+
{
|
1119
|
+
iface = XPCNativeInterface::GetNewOrUsed(ccx, iid);
|
1120
|
+
if(!iface)
|
1121
|
+
return JS_FALSE;
|
1122
|
+
}
|
1123
|
+
|
1124
|
+
nsresult rv;
|
1125
|
+
XPCWrappedNative* wrapper;
|
1126
|
+
nsRefPtr<XPCWrappedNative> strongWrapper;
|
1127
|
+
if(!cache)
|
1128
|
+
CallQueryInterface(src, &cache);
|
1129
|
+
if(cache &&
|
1130
|
+
(wrapper = static_cast<XPCWrappedNative*>(cache->GetWrapper())))
|
1131
|
+
{
|
1132
|
+
// If asked to return the wrapper we'll return a strong reference,
|
1133
|
+
// otherwise we'll just return its JSObject in rval (which should be
|
1134
|
+
// rooted in that case).
|
1135
|
+
if(dest)
|
1136
|
+
strongWrapper = wrapper;
|
1137
|
+
if(iface)
|
1138
|
+
wrapper->FindTearOff(ccx, iface, JS_FALSE, &rv);
|
1139
|
+
else
|
1140
|
+
rv = NS_OK;
|
1141
|
+
}
|
1142
|
+
else
|
1143
|
+
{
|
1144
|
+
rv = XPCWrappedNative::GetNewOrUsed(ccx, src, xpcscope, iface,
|
1145
|
+
cache, isGlobal,
|
1146
|
+
getter_AddRefs(strongWrapper));
|
1147
|
+
|
1148
|
+
wrapper = strongWrapper;
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
if(pErr)
|
1152
|
+
*pErr = rv;
|
1153
|
+
if(NS_SUCCEEDED(rv) && wrapper)
|
1154
|
+
{
|
1155
|
+
uint32 flags = 0;
|
1156
|
+
JSObject *flat = wrapper->GetFlatJSObject();
|
1157
|
+
jsval v = OBJECT_TO_JSVAL(flat);
|
1158
|
+
|
1159
|
+
JSBool sameOrigin;
|
1160
|
+
if (allowNativeWrapper &&
|
1161
|
+
!xpc_SameScope(wrapper->GetScope(), xpcscope, &sameOrigin))
|
1162
|
+
{
|
1163
|
+
// Cross scope access detected. Check if chrome code
|
1164
|
+
// is accessing non-chrome objects, and if so, wrap
|
1165
|
+
// the XPCWrappedNative with an XPCNativeWrapper to
|
1166
|
+
// prevent user-defined properties from shadowing DOM
|
1167
|
+
// properties from chrome code.
|
1168
|
+
|
1169
|
+
// printf("Wrapped native accessed across scope boundary\n");
|
1170
|
+
|
1171
|
+
JSScript* script = nsnull;
|
1172
|
+
JSObject* callee = nsnull;
|
1173
|
+
if(ccx.GetXPCContext()->CallerTypeIsJavaScript())
|
1174
|
+
{
|
1175
|
+
// Called from JS. We're going to hand the resulting
|
1176
|
+
// JSObject to said JS, so look for the script we want on
|
1177
|
+
// the stack.
|
1178
|
+
JSContext* cx = ccx;
|
1179
|
+
JSStackFrame* fp = JS_GetScriptedCaller(cx, NULL);
|
1180
|
+
if(fp)
|
1181
|
+
{
|
1182
|
+
script = fp->script;
|
1183
|
+
callee = fp->callee;
|
1184
|
+
}
|
1185
|
+
}
|
1186
|
+
else if(ccx.GetXPCContext()->CallerTypeIsNative())
|
1187
|
+
{
|
1188
|
+
callee = ccx.GetCallee();
|
1189
|
+
if(callee && JS_ObjectIsFunction(ccx, callee))
|
1190
|
+
{
|
1191
|
+
// Called from c++, and calling out to |callee|, which
|
1192
|
+
// is a JS function object. Look for the script for
|
1193
|
+
// this function.
|
1194
|
+
JSFunction* fun =
|
1195
|
+
(JSFunction*) xpc_GetJSPrivate(callee);
|
1196
|
+
NS_ASSERTION(fun,
|
1197
|
+
"Must have JSFunction for a Function "
|
1198
|
+
"object");
|
1199
|
+
script = JS_GetFunctionScript(ccx, fun);
|
1200
|
+
}
|
1201
|
+
else
|
1202
|
+
{
|
1203
|
+
// Else we don't know whom we're calling, so don't
|
1204
|
+
// create XPCNativeWrappers.
|
1205
|
+
callee = nsnull;
|
1206
|
+
}
|
1207
|
+
}
|
1208
|
+
// else don't create XPCNativeWrappers, since we have
|
1209
|
+
// no idea what's calling what here.
|
1210
|
+
|
1211
|
+
flags = script ? JS_GetScriptFilenameFlags(script) : 0;
|
1212
|
+
NS_ASSERTION(flags != JSFILENAME_NULL, "null script filename");
|
1213
|
+
|
1214
|
+
if(!JS_IsSystemObject(ccx, flat))
|
1215
|
+
{
|
1216
|
+
// From here on we might create new JSObjects, so we need to
|
1217
|
+
// make sure that wrapper stays alive.
|
1218
|
+
if(!strongWrapper)
|
1219
|
+
strongWrapper = wrapper;
|
1220
|
+
|
1221
|
+
JSObject *destObj = nsnull;
|
1222
|
+
JSBool triedWrapping = JS_FALSE;
|
1223
|
+
if(flags & JSFILENAME_PROTECTED)
|
1224
|
+
{
|
1225
|
+
#ifdef DEBUG_XPCNativeWrapper
|
1226
|
+
{
|
1227
|
+
char *s = wrapper->ToString(ccx);
|
1228
|
+
printf("Content accessed from chrome, wrapping "
|
1229
|
+
"wrapper (%s) in XPCNativeWrapper\n", s);
|
1230
|
+
if (s)
|
1231
|
+
JS_smprintf_free(s);
|
1232
|
+
}
|
1233
|
+
#endif
|
1234
|
+
nsIScriptSecurityManager *ssm =
|
1235
|
+
XPCWrapper::GetSecurityManager();
|
1236
|
+
nsCOMPtr<nsIPrincipal> objPrincipal;
|
1237
|
+
if(callee)
|
1238
|
+
{
|
1239
|
+
// Prefer getting the object princpal here.
|
1240
|
+
nsresult rv =
|
1241
|
+
ssm->GetObjectPrincipal(ccx, callee,
|
1242
|
+
getter_AddRefs(objPrincipal));
|
1243
|
+
if(NS_FAILED(rv))
|
1244
|
+
return JS_FALSE;
|
1245
|
+
}
|
1246
|
+
else
|
1247
|
+
{
|
1248
|
+
JSPrincipals *scriptPrincipal =
|
1249
|
+
JS_GetScriptPrincipals(ccx, script);
|
1250
|
+
if(scriptPrincipal)
|
1251
|
+
{
|
1252
|
+
nsJSPrincipals *nsjsp =
|
1253
|
+
static_cast<nsJSPrincipals *>(scriptPrincipal);
|
1254
|
+
objPrincipal = nsjsp->nsIPrincipalPtr;
|
1255
|
+
}
|
1256
|
+
}
|
1257
|
+
|
1258
|
+
destObj =
|
1259
|
+
XPCNativeWrapper::GetNewOrUsed(ccx, wrapper,
|
1260
|
+
objPrincipal);
|
1261
|
+
triedWrapping = JS_TRUE;
|
1262
|
+
}
|
1263
|
+
else if (flags & JSFILENAME_SYSTEM)
|
1264
|
+
{
|
1265
|
+
#ifdef DEBUG_mrbkap
|
1266
|
+
printf("Content accessed from chrome, wrapping in an "
|
1267
|
+
"XPCSafeJSObjectWrapper\n");
|
1268
|
+
#endif
|
1269
|
+
|
1270
|
+
if(XPC_SJOW_Construct(ccx, nsnull, 1, &v, &v))
|
1271
|
+
destObj = JSVAL_TO_OBJECT(v);
|
1272
|
+
triedWrapping = JS_TRUE;
|
1273
|
+
}
|
1274
|
+
else if (!sameOrigin)
|
1275
|
+
{
|
1276
|
+
// Reaching across scopes from content code. Wrap
|
1277
|
+
// the new object in a XOW.
|
1278
|
+
if (XPC_XOW_WrapObject(ccx, scope, &v))
|
1279
|
+
destObj = JSVAL_TO_OBJECT(v);
|
1280
|
+
triedWrapping = JS_TRUE;
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
if(triedWrapping)
|
1284
|
+
{
|
1285
|
+
if(!destObj)
|
1286
|
+
return JS_FALSE;
|
1287
|
+
|
1288
|
+
jsval wrappedObjVal = OBJECT_TO_JSVAL(destObj);
|
1289
|
+
AUTO_MARK_JSVAL(ccx, &wrappedObjVal);
|
1290
|
+
if(wrapper->NeedsChromeWrapper())
|
1291
|
+
{
|
1292
|
+
if(!XPC_SOW_WrapObject(ccx, xpcscope->GetGlobalJSObject(),
|
1293
|
+
OBJECT_TO_JSVAL(destObj),
|
1294
|
+
&wrappedObjVal))
|
1295
|
+
return JS_FALSE;
|
1296
|
+
}
|
1297
|
+
|
1298
|
+
return CreateHolderIfNeeded(ccx, JSVAL_TO_OBJECT(wrappedObjVal),
|
1299
|
+
d, dest);
|
1300
|
+
}
|
1301
|
+
}
|
1302
|
+
}
|
1303
|
+
|
1304
|
+
const char *name = STOBJ_GET_CLASS(flat)->name;
|
1305
|
+
if(allowNativeWrapper &&
|
1306
|
+
!(flags & JSFILENAME_SYSTEM) &&
|
1307
|
+
!JS_IsSystemObject(ccx, flat) &&
|
1308
|
+
XPC_XOW_ClassNeedsXOW(name))
|
1309
|
+
{
|
1310
|
+
// From here on we might create new JSObjects, so we need to
|
1311
|
+
// make sure that wrapper stays alive.
|
1312
|
+
if(!strongWrapper)
|
1313
|
+
strongWrapper = wrapper;
|
1314
|
+
|
1315
|
+
AUTO_MARK_JSVAL(ccx, &v);
|
1316
|
+
return XPC_XOW_WrapObject(ccx, scope, &v) &&
|
1317
|
+
(!wrapper->NeedsChromeWrapper() ||
|
1318
|
+
XPC_SOW_WrapObject(ccx, xpcscope->GetGlobalJSObject(),
|
1319
|
+
v, &v)) &&
|
1320
|
+
CreateHolderIfNeeded(ccx, JSVAL_TO_OBJECT(v), d, dest);
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
if(allowNativeWrapper && wrapper->NeedsChromeWrapper())
|
1324
|
+
{
|
1325
|
+
if(!XPC_SOW_WrapObject(ccx, xpcscope->GetGlobalJSObject(), v, d))
|
1326
|
+
return JS_FALSE;
|
1327
|
+
}
|
1328
|
+
else
|
1329
|
+
{
|
1330
|
+
*d = v;
|
1331
|
+
}
|
1332
|
+
if(dest)
|
1333
|
+
*dest = strongWrapper.forget().get();
|
1334
|
+
return JS_TRUE;
|
1335
|
+
}
|
1336
|
+
}
|
1337
|
+
return JS_FALSE;
|
1338
|
+
}
|
1339
|
+
|
1340
|
+
/***************************************************************************/
|
1341
|
+
|
1342
|
+
// static
|
1343
|
+
JSBool
|
1344
|
+
XPCConvert::JSObject2NativeInterface(XPCCallContext& ccx,
|
1345
|
+
void** dest, JSObject* src,
|
1346
|
+
const nsID* iid,
|
1347
|
+
nsISupports* aOuter,
|
1348
|
+
nsresult* pErr)
|
1349
|
+
{
|
1350
|
+
NS_ASSERTION(dest, "bad param");
|
1351
|
+
NS_ASSERTION(src, "bad param");
|
1352
|
+
NS_ASSERTION(iid, "bad param");
|
1353
|
+
|
1354
|
+
JSContext* cx = ccx.GetJSContext();
|
1355
|
+
|
1356
|
+
*dest = nsnull;
|
1357
|
+
if(pErr)
|
1358
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
|
1359
|
+
|
1360
|
+
nsISupports* iface;
|
1361
|
+
|
1362
|
+
if(!aOuter)
|
1363
|
+
{
|
1364
|
+
// Note that if we have a non-null aOuter then it means that we are
|
1365
|
+
// forcing the creation of a wrapper even if the object *is* a
|
1366
|
+
// wrappedNative or other wise has 'nsISupportness'.
|
1367
|
+
// This allows wrapJSAggregatedToNative to work.
|
1368
|
+
|
1369
|
+
// Is this really a native xpcom object with a wrapper?
|
1370
|
+
XPCWrappedNative* wrappedNative =
|
1371
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(cx, src);
|
1372
|
+
if(wrappedNative)
|
1373
|
+
{
|
1374
|
+
iface = wrappedNative->GetIdentityObject();
|
1375
|
+
return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
|
1376
|
+
}
|
1377
|
+
// else...
|
1378
|
+
|
1379
|
+
// XXX E4X breaks the world. Don't try wrapping E4X objects!
|
1380
|
+
// This hack can be removed (or changed accordingly) when the
|
1381
|
+
// DOM <-> E4X bindings are complete, see bug 270553
|
1382
|
+
if(JS_TypeOfValue(cx, OBJECT_TO_JSVAL(src)) == JSTYPE_XML)
|
1383
|
+
return JS_FALSE;
|
1384
|
+
|
1385
|
+
// Does the JSObject have 'nsISupportness'?
|
1386
|
+
// XXX hmm, I wonder if this matters anymore with no
|
1387
|
+
// oldstyle DOM objects around.
|
1388
|
+
if(GetISupportsFromJSObject(src, &iface))
|
1389
|
+
{
|
1390
|
+
if(iface)
|
1391
|
+
return NS_SUCCEEDED(iface->QueryInterface(*iid, dest));
|
1392
|
+
|
1393
|
+
return JS_FALSE;
|
1394
|
+
}
|
1395
|
+
}
|
1396
|
+
|
1397
|
+
// else...
|
1398
|
+
|
1399
|
+
nsXPCWrappedJS* wrapper;
|
1400
|
+
nsresult rv = nsXPCWrappedJS::GetNewOrUsed(ccx, src, *iid, aOuter, &wrapper);
|
1401
|
+
if(pErr)
|
1402
|
+
*pErr = rv;
|
1403
|
+
if(NS_SUCCEEDED(rv) && wrapper)
|
1404
|
+
{
|
1405
|
+
// We need to go through the QueryInterface logic to make this return
|
1406
|
+
// the right thing for the various 'special' interfaces; e.g.
|
1407
|
+
// nsIPropertyBag. We must use AggregatedQueryInterface in cases where
|
1408
|
+
// there is an outer to avoid nasty recursion.
|
1409
|
+
rv = aOuter ? wrapper->AggregatedQueryInterface(*iid, dest) :
|
1410
|
+
wrapper->QueryInterface(*iid, dest);
|
1411
|
+
if(pErr)
|
1412
|
+
*pErr = rv;
|
1413
|
+
NS_RELEASE(wrapper);
|
1414
|
+
return NS_SUCCEEDED(rv);
|
1415
|
+
}
|
1416
|
+
|
1417
|
+
// else...
|
1418
|
+
return JS_FALSE;
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
/***************************************************************************/
|
1422
|
+
/***************************************************************************/
|
1423
|
+
|
1424
|
+
// static
|
1425
|
+
nsresult
|
1426
|
+
XPCConvert::ConstructException(nsresult rv, const char* message,
|
1427
|
+
const char* ifaceName, const char* methodName,
|
1428
|
+
nsISupports* data,
|
1429
|
+
nsIException** exceptn,
|
1430
|
+
JSContext* cx,
|
1431
|
+
jsval* jsExceptionPtr)
|
1432
|
+
{
|
1433
|
+
NS_ASSERTION(!cx == !jsExceptionPtr, "Expected cx and jsExceptionPtr to cooccur.");
|
1434
|
+
|
1435
|
+
static const char format[] = "\'%s\' when calling method: [%s::%s]";
|
1436
|
+
const char * msg = message;
|
1437
|
+
char* sz = nsnull;
|
1438
|
+
nsXPIDLString xmsg;
|
1439
|
+
nsCAutoString sxmsg;
|
1440
|
+
|
1441
|
+
nsCOMPtr<nsIScriptError> errorObject = do_QueryInterface(data);
|
1442
|
+
if(errorObject) {
|
1443
|
+
if (NS_SUCCEEDED(errorObject->GetMessageMoz(getter_Copies(xmsg)))) {
|
1444
|
+
CopyUTF16toUTF8(xmsg, sxmsg);
|
1445
|
+
msg = sxmsg.get();
|
1446
|
+
}
|
1447
|
+
}
|
1448
|
+
if(!msg)
|
1449
|
+
if(!nsXPCException::NameAndFormatForNSResult(rv, nsnull, &msg) || ! msg)
|
1450
|
+
msg = "<error>";
|
1451
|
+
if(ifaceName && methodName)
|
1452
|
+
msg = sz = JS_smprintf(format, msg, ifaceName, methodName);
|
1453
|
+
|
1454
|
+
nsresult res = nsXPCException::NewException(msg, rv, nsnull, data, exceptn);
|
1455
|
+
|
1456
|
+
if(NS_SUCCEEDED(res) && cx && jsExceptionPtr && *exceptn)
|
1457
|
+
{
|
1458
|
+
nsCOMPtr<nsXPCException> xpcEx = do_QueryInterface(*exceptn);
|
1459
|
+
if(xpcEx)
|
1460
|
+
xpcEx->StowThrownJSVal(cx, *jsExceptionPtr);
|
1461
|
+
}
|
1462
|
+
|
1463
|
+
if(sz)
|
1464
|
+
JS_smprintf_free(sz);
|
1465
|
+
return res;
|
1466
|
+
}
|
1467
|
+
|
1468
|
+
/********************************/
|
1469
|
+
|
1470
|
+
class AutoExceptionRestorer : public JSAutoTempValueRooter
|
1471
|
+
{
|
1472
|
+
public:
|
1473
|
+
AutoExceptionRestorer(JSContext *cx, jsval v)
|
1474
|
+
: JSAutoTempValueRooter(cx, v),
|
1475
|
+
mVal(v)
|
1476
|
+
{
|
1477
|
+
JS_ClearPendingException(mContext);
|
1478
|
+
}
|
1479
|
+
|
1480
|
+
~AutoExceptionRestorer()
|
1481
|
+
{
|
1482
|
+
JS_SetPendingException(mContext, mVal);
|
1483
|
+
}
|
1484
|
+
|
1485
|
+
private:
|
1486
|
+
jsval mVal;
|
1487
|
+
};
|
1488
|
+
|
1489
|
+
// static
|
1490
|
+
nsresult
|
1491
|
+
XPCConvert::JSValToXPCException(XPCCallContext& ccx,
|
1492
|
+
jsval s,
|
1493
|
+
const char* ifaceName,
|
1494
|
+
const char* methodName,
|
1495
|
+
nsIException** exceptn)
|
1496
|
+
{
|
1497
|
+
JSContext* cx = ccx.GetJSContext();
|
1498
|
+
AutoExceptionRestorer aer(cx, s);
|
1499
|
+
|
1500
|
+
if(!JSVAL_IS_PRIMITIVE(s))
|
1501
|
+
{
|
1502
|
+
// we have a JSObject
|
1503
|
+
JSObject* obj = JSVAL_TO_OBJECT(s);
|
1504
|
+
|
1505
|
+
if(!obj)
|
1506
|
+
{
|
1507
|
+
NS_ASSERTION(0, "when is an object not an object?");
|
1508
|
+
return NS_ERROR_FAILURE;
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
// is this really a native xpcom object with a wrapper?
|
1512
|
+
XPCWrappedNative* wrapper;
|
1513
|
+
if(nsnull != (wrapper =
|
1514
|
+
XPCWrappedNative::GetWrappedNativeOfJSObject(cx,obj)))
|
1515
|
+
{
|
1516
|
+
nsISupports* supports = wrapper->GetIdentityObject();
|
1517
|
+
nsCOMPtr<nsIException> iface = do_QueryInterface(supports);
|
1518
|
+
if(iface)
|
1519
|
+
{
|
1520
|
+
// just pass through the exception (with extra ref and all)
|
1521
|
+
nsIException* temp = iface;
|
1522
|
+
NS_ADDREF(temp);
|
1523
|
+
*exceptn = temp;
|
1524
|
+
return NS_OK;
|
1525
|
+
}
|
1526
|
+
else
|
1527
|
+
{
|
1528
|
+
// it is a wrapped native, but not an exception!
|
1529
|
+
return ConstructException(NS_ERROR_XPC_JS_THREW_NATIVE_OBJECT,
|
1530
|
+
nsnull, ifaceName, methodName, supports,
|
1531
|
+
exceptn, nsnull, nsnull);
|
1532
|
+
}
|
1533
|
+
}
|
1534
|
+
else
|
1535
|
+
{
|
1536
|
+
// It is a JSObject, but not a wrapped native...
|
1537
|
+
|
1538
|
+
// If it is an engine Error with an error report then let's
|
1539
|
+
// extract the report and build an xpcexception from that
|
1540
|
+
const JSErrorReport* report;
|
1541
|
+
if(nsnull != (report = JS_ErrorFromException(cx, s)))
|
1542
|
+
{
|
1543
|
+
const char* message = nsnull;
|
1544
|
+
JSString* str;
|
1545
|
+
if(nsnull != (str = JS_ValueToString(cx, s)))
|
1546
|
+
message = JS_GetStringBytes(str);
|
1547
|
+
return JSErrorToXPCException(ccx, message, ifaceName,
|
1548
|
+
methodName, report, exceptn);
|
1549
|
+
}
|
1550
|
+
|
1551
|
+
|
1552
|
+
uintN ignored;
|
1553
|
+
JSBool found;
|
1554
|
+
|
1555
|
+
// heuristic to see if it might be usable as an xpcexception
|
1556
|
+
if(JS_GetPropertyAttributes(cx, obj, "message", &ignored, &found) &&
|
1557
|
+
found &&
|
1558
|
+
JS_GetPropertyAttributes(cx, obj, "result", &ignored, &found) &&
|
1559
|
+
found)
|
1560
|
+
{
|
1561
|
+
// lets try to build a wrapper around the JSObject
|
1562
|
+
nsXPCWrappedJS* jswrapper;
|
1563
|
+
nsresult rv =
|
1564
|
+
nsXPCWrappedJS::GetNewOrUsed(ccx, obj,
|
1565
|
+
NS_GET_IID(nsIException),
|
1566
|
+
nsnull, &jswrapper);
|
1567
|
+
if(NS_FAILED(rv))
|
1568
|
+
return rv;
|
1569
|
+
*exceptn = reinterpret_cast<nsIException*>
|
1570
|
+
(jswrapper);
|
1571
|
+
return NS_OK;
|
1572
|
+
}
|
1573
|
+
|
1574
|
+
|
1575
|
+
// XXX we should do a check against 'js_ErrorClass' here and
|
1576
|
+
// do the right thing - even though it has no JSErrorReport,
|
1577
|
+
// The fact that it is a JSError exceptions means we can extract
|
1578
|
+
// particular info and our 'result' should reflect that.
|
1579
|
+
|
1580
|
+
// otherwise we'll just try to convert it to a string
|
1581
|
+
|
1582
|
+
JSString* str = JS_ValueToString(cx, s);
|
1583
|
+
if(!str)
|
1584
|
+
return NS_ERROR_FAILURE;
|
1585
|
+
|
1586
|
+
return ConstructException(NS_ERROR_XPC_JS_THREW_JS_OBJECT,
|
1587
|
+
JS_GetStringBytes(str),
|
1588
|
+
ifaceName, methodName, nsnull,
|
1589
|
+
exceptn, cx, &s);
|
1590
|
+
}
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
if(JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
|
1594
|
+
{
|
1595
|
+
return ConstructException(NS_ERROR_XPC_JS_THREW_NULL,
|
1596
|
+
nsnull, ifaceName, methodName, nsnull,
|
1597
|
+
exceptn, cx, &s);
|
1598
|
+
}
|
1599
|
+
|
1600
|
+
if(JSVAL_IS_NUMBER(s))
|
1601
|
+
{
|
1602
|
+
// lets see if it looks like an nsresult
|
1603
|
+
nsresult rv;
|
1604
|
+
double number;
|
1605
|
+
JSBool isResult = JS_FALSE;
|
1606
|
+
|
1607
|
+
if(JSVAL_IS_INT(s))
|
1608
|
+
{
|
1609
|
+
rv = (nsresult) JSVAL_TO_INT(s);
|
1610
|
+
if(NS_FAILED(rv))
|
1611
|
+
isResult = JS_TRUE;
|
1612
|
+
else
|
1613
|
+
number = (double) JSVAL_TO_INT(s);
|
1614
|
+
}
|
1615
|
+
else
|
1616
|
+
{
|
1617
|
+
number = *(JSVAL_TO_DOUBLE(s));
|
1618
|
+
if(number > 0.0 &&
|
1619
|
+
number < (double)0xffffffff &&
|
1620
|
+
0.0 == fmod(number,1))
|
1621
|
+
{
|
1622
|
+
rv = (nsresult) number;
|
1623
|
+
if(NS_FAILED(rv))
|
1624
|
+
isResult = JS_TRUE;
|
1625
|
+
}
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
if(isResult)
|
1629
|
+
return ConstructException(rv, nsnull, ifaceName, methodName,
|
1630
|
+
nsnull, exceptn, cx, &s);
|
1631
|
+
else
|
1632
|
+
{
|
1633
|
+
// XXX all this nsISupportsDouble code seems a little redundant
|
1634
|
+
// now that we're storing the jsval in the exception...
|
1635
|
+
nsISupportsDouble* data;
|
1636
|
+
nsCOMPtr<nsIComponentManager> cm;
|
1637
|
+
if(NS_FAILED(NS_GetComponentManager(getter_AddRefs(cm))) || !cm ||
|
1638
|
+
NS_FAILED(cm->CreateInstanceByContractID(
|
1639
|
+
NS_SUPPORTS_DOUBLE_CONTRACTID,
|
1640
|
+
nsnull,
|
1641
|
+
NS_GET_IID(nsISupportsDouble),
|
1642
|
+
(void**)&data)))
|
1643
|
+
return NS_ERROR_FAILURE;
|
1644
|
+
data->SetData(number);
|
1645
|
+
rv = ConstructException(NS_ERROR_XPC_JS_THREW_NUMBER, nsnull,
|
1646
|
+
ifaceName, methodName, data, exceptn, cx, &s);
|
1647
|
+
NS_RELEASE(data);
|
1648
|
+
return rv;
|
1649
|
+
}
|
1650
|
+
}
|
1651
|
+
|
1652
|
+
// otherwise we'll just try to convert it to a string
|
1653
|
+
// Note: e.g., JSBools get converted to JSStrings by this code.
|
1654
|
+
|
1655
|
+
JSString* str = JS_ValueToString(cx, s);
|
1656
|
+
if(str)
|
1657
|
+
return ConstructException(NS_ERROR_XPC_JS_THREW_STRING,
|
1658
|
+
JS_GetStringBytes(str),
|
1659
|
+
ifaceName, methodName, nsnull,
|
1660
|
+
exceptn, cx, &s);
|
1661
|
+
return NS_ERROR_FAILURE;
|
1662
|
+
}
|
1663
|
+
|
1664
|
+
/********************************/
|
1665
|
+
|
1666
|
+
// static
|
1667
|
+
nsresult
|
1668
|
+
XPCConvert::JSErrorToXPCException(XPCCallContext& ccx,
|
1669
|
+
const char* message,
|
1670
|
+
const char* ifaceName,
|
1671
|
+
const char* methodName,
|
1672
|
+
const JSErrorReport* report,
|
1673
|
+
nsIException** exceptn)
|
1674
|
+
{
|
1675
|
+
nsresult rv = NS_ERROR_FAILURE;
|
1676
|
+
nsScriptError* data;
|
1677
|
+
if(report)
|
1678
|
+
{
|
1679
|
+
nsAutoString bestMessage;
|
1680
|
+
if(report && report->ucmessage)
|
1681
|
+
{
|
1682
|
+
bestMessage = (const PRUnichar *)report->ucmessage;
|
1683
|
+
}
|
1684
|
+
else if(message)
|
1685
|
+
{
|
1686
|
+
bestMessage.AssignWithConversion(message);
|
1687
|
+
}
|
1688
|
+
else
|
1689
|
+
{
|
1690
|
+
bestMessage.AssignLiteral("JavaScript Error");
|
1691
|
+
}
|
1692
|
+
|
1693
|
+
data = new nsScriptError();
|
1694
|
+
if(!data)
|
1695
|
+
return NS_ERROR_OUT_OF_MEMORY;
|
1696
|
+
|
1697
|
+
NS_ADDREF(data);
|
1698
|
+
data->Init(bestMessage.get(),
|
1699
|
+
NS_ConvertASCIItoUTF16(report->filename).get(),
|
1700
|
+
(const PRUnichar *)report->uclinebuf, report->lineno,
|
1701
|
+
report->uctokenptr - report->uclinebuf, report->flags,
|
1702
|
+
"XPConnect JavaScript");
|
1703
|
+
}
|
1704
|
+
else
|
1705
|
+
data = nsnull;
|
1706
|
+
|
1707
|
+
if(data)
|
1708
|
+
{
|
1709
|
+
nsCAutoString formattedMsg;
|
1710
|
+
data->ToString(formattedMsg);
|
1711
|
+
|
1712
|
+
rv = ConstructException(NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS,
|
1713
|
+
formattedMsg.get(), ifaceName, methodName, data,
|
1714
|
+
exceptn, nsnull, nsnull);
|
1715
|
+
|
1716
|
+
NS_RELEASE(data);
|
1717
|
+
}
|
1718
|
+
else
|
1719
|
+
{
|
1720
|
+
rv = ConstructException(NS_ERROR_XPC_JAVASCRIPT_ERROR,
|
1721
|
+
nsnull, ifaceName, methodName, nsnull,
|
1722
|
+
exceptn, nsnull, nsnull);
|
1723
|
+
}
|
1724
|
+
return rv;
|
1725
|
+
}
|
1726
|
+
|
1727
|
+
|
1728
|
+
/***************************************************************************/
|
1729
|
+
|
1730
|
+
/*
|
1731
|
+
** Note: on some platforms va_list is defined as an array,
|
1732
|
+
** and requires array notation.
|
1733
|
+
*/
|
1734
|
+
#ifdef HAVE_VA_COPY
|
1735
|
+
#define VARARGS_ASSIGN(foo, bar) VA_COPY(foo,bar)
|
1736
|
+
#elif defined(HAVE_VA_LIST_AS_ARRAY)
|
1737
|
+
#define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0]
|
1738
|
+
#else
|
1739
|
+
#define VARARGS_ASSIGN(foo, bar) (foo) = (bar)
|
1740
|
+
#endif
|
1741
|
+
|
1742
|
+
// We assert below that these formats all begin with "%i".
|
1743
|
+
const char* XPC_ARG_FORMATTER_FORMAT_STRINGS[] = {"%ip", "%iv", "%is", nsnull};
|
1744
|
+
|
1745
|
+
JSBool
|
1746
|
+
XPC_JSArgumentFormatter(JSContext *cx, const char *format,
|
1747
|
+
JSBool fromJS, jsval **vpp, va_list *app)
|
1748
|
+
{
|
1749
|
+
XPCCallContext ccx(NATIVE_CALLER, cx);
|
1750
|
+
if(!ccx.IsValid())
|
1751
|
+
return JS_FALSE;
|
1752
|
+
|
1753
|
+
jsval *vp;
|
1754
|
+
va_list ap;
|
1755
|
+
|
1756
|
+
vp = *vpp;
|
1757
|
+
VARARGS_ASSIGN(ap, *app);
|
1758
|
+
|
1759
|
+
nsXPTType type;
|
1760
|
+
const nsIID* iid;
|
1761
|
+
void* p;
|
1762
|
+
|
1763
|
+
NS_ASSERTION(format[0] == '%' && format[1] == 'i', "bad format!");
|
1764
|
+
char which = format[2];
|
1765
|
+
|
1766
|
+
if(fromJS)
|
1767
|
+
{
|
1768
|
+
switch(which)
|
1769
|
+
{
|
1770
|
+
case 'p':
|
1771
|
+
type = nsXPTType((uint8)(TD_INTERFACE_TYPE | XPT_TDP_POINTER));
|
1772
|
+
iid = &NS_GET_IID(nsISupports);
|
1773
|
+
break;
|
1774
|
+
case 'v':
|
1775
|
+
type = nsXPTType((uint8)(TD_INTERFACE_TYPE | XPT_TDP_POINTER));
|
1776
|
+
iid = &NS_GET_IID(nsIVariant);
|
1777
|
+
break;
|
1778
|
+
case 's':
|
1779
|
+
type = nsXPTType((uint8)(TD_DOMSTRING | XPT_TDP_POINTER));
|
1780
|
+
iid = nsnull;
|
1781
|
+
p = va_arg(ap, void *);
|
1782
|
+
break;
|
1783
|
+
default:
|
1784
|
+
NS_ERROR("bad format!");
|
1785
|
+
return JS_FALSE;
|
1786
|
+
}
|
1787
|
+
|
1788
|
+
if(!XPCConvert::JSData2Native(ccx, &p, vp[0], type, JS_FALSE,
|
1789
|
+
iid, nsnull))
|
1790
|
+
return JS_FALSE;
|
1791
|
+
|
1792
|
+
if(which != 's')
|
1793
|
+
*va_arg(ap, void **) = p;
|
1794
|
+
}
|
1795
|
+
else
|
1796
|
+
{
|
1797
|
+
switch(which)
|
1798
|
+
{
|
1799
|
+
case 'p':
|
1800
|
+
type = nsXPTType((uint8)(TD_INTERFACE_TYPE | XPT_TDP_POINTER));
|
1801
|
+
iid = va_arg(ap, const nsIID*);
|
1802
|
+
break;
|
1803
|
+
case 'v':
|
1804
|
+
type = nsXPTType((uint8)(TD_INTERFACE_TYPE | XPT_TDP_POINTER));
|
1805
|
+
iid = &NS_GET_IID(nsIVariant);
|
1806
|
+
break;
|
1807
|
+
case 's':
|
1808
|
+
type = nsXPTType((uint8)(TD_DOMSTRING | XPT_TDP_POINTER));
|
1809
|
+
iid = nsnull;
|
1810
|
+
break;
|
1811
|
+
default:
|
1812
|
+
NS_ERROR("bad format!");
|
1813
|
+
return JS_FALSE;
|
1814
|
+
}
|
1815
|
+
|
1816
|
+
// NOTE: MUST be retrieved *after* the iid in the 'p' case above.
|
1817
|
+
p = va_arg(ap, void *);
|
1818
|
+
|
1819
|
+
if(!XPCConvert::NativeData2JS(ccx, &vp[0], &p, type, iid,
|
1820
|
+
JS_GetGlobalObject(cx), nsnull))
|
1821
|
+
return JS_FALSE;
|
1822
|
+
}
|
1823
|
+
*vpp = vp + 1;
|
1824
|
+
VARARGS_ASSIGN(*app, ap);
|
1825
|
+
return JS_TRUE;
|
1826
|
+
}
|
1827
|
+
|
1828
|
+
/***************************************************************************/
|
1829
|
+
|
1830
|
+
// array fun...
|
1831
|
+
|
1832
|
+
#ifdef POPULATE
|
1833
|
+
#undef POPULATE
|
1834
|
+
#endif
|
1835
|
+
|
1836
|
+
// static
|
1837
|
+
JSBool
|
1838
|
+
XPCConvert::NativeArray2JS(XPCCallContext& ccx,
|
1839
|
+
jsval* d, const void** s,
|
1840
|
+
const nsXPTType& type, const nsID* iid,
|
1841
|
+
JSUint32 count, JSObject* scope,
|
1842
|
+
nsresult* pErr)
|
1843
|
+
{
|
1844
|
+
NS_PRECONDITION(s, "bad param");
|
1845
|
+
NS_PRECONDITION(d, "bad param");
|
1846
|
+
|
1847
|
+
JSContext* cx = ccx.GetJSContext();
|
1848
|
+
|
1849
|
+
// XXX add support for putting chars in a string rather than an array
|
1850
|
+
|
1851
|
+
// XXX add support to indicate *which* array element was not convertable
|
1852
|
+
|
1853
|
+
JSObject *array = JS_NewArrayObject(cx, count, nsnull);
|
1854
|
+
|
1855
|
+
if(!array)
|
1856
|
+
return JS_FALSE;
|
1857
|
+
|
1858
|
+
// root this early
|
1859
|
+
*d = OBJECT_TO_JSVAL(array);
|
1860
|
+
AUTO_MARK_JSVAL(ccx, d);
|
1861
|
+
|
1862
|
+
if(pErr)
|
1863
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
|
1864
|
+
|
1865
|
+
JSUint32 i;
|
1866
|
+
jsval current = JSVAL_NULL;
|
1867
|
+
AUTO_MARK_JSVAL(ccx, ¤t);
|
1868
|
+
|
1869
|
+
#define POPULATE(_t) \
|
1870
|
+
PR_BEGIN_MACRO \
|
1871
|
+
for(i = 0; i < count; i++) \
|
1872
|
+
{ \
|
1873
|
+
if(!NativeData2JS(ccx, ¤t, ((_t*)*s)+i, type, iid, \
|
1874
|
+
scope, pErr) || \
|
1875
|
+
!JS_SetElement(cx, array, i, ¤t)) \
|
1876
|
+
goto failure; \
|
1877
|
+
} \
|
1878
|
+
PR_END_MACRO
|
1879
|
+
|
1880
|
+
// XXX check IsPtr - esp. to handle array of nsID (as opposed to nsID*)
|
1881
|
+
|
1882
|
+
switch(type.TagPart())
|
1883
|
+
{
|
1884
|
+
case nsXPTType::T_I8 : POPULATE(int8); break;
|
1885
|
+
case nsXPTType::T_I16 : POPULATE(int16); break;
|
1886
|
+
case nsXPTType::T_I32 : POPULATE(int32); break;
|
1887
|
+
case nsXPTType::T_I64 : POPULATE(int64); break;
|
1888
|
+
case nsXPTType::T_U8 : POPULATE(uint8); break;
|
1889
|
+
case nsXPTType::T_U16 : POPULATE(uint16); break;
|
1890
|
+
case nsXPTType::T_U32 : POPULATE(uint32); break;
|
1891
|
+
case nsXPTType::T_U64 : POPULATE(uint64); break;
|
1892
|
+
case nsXPTType::T_FLOAT : POPULATE(float); break;
|
1893
|
+
case nsXPTType::T_DOUBLE : POPULATE(double); break;
|
1894
|
+
case nsXPTType::T_BOOL : POPULATE(PRBool); break;
|
1895
|
+
case nsXPTType::T_CHAR : POPULATE(char); break;
|
1896
|
+
case nsXPTType::T_WCHAR : POPULATE(jschar); break;
|
1897
|
+
case nsXPTType::T_VOID : NS_ASSERTION(0,"bad type"); goto failure;
|
1898
|
+
case nsXPTType::T_IID : POPULATE(nsID*); break;
|
1899
|
+
case nsXPTType::T_DOMSTRING : NS_ASSERTION(0,"bad type"); goto failure;
|
1900
|
+
case nsXPTType::T_CHAR_STR : POPULATE(char*); break;
|
1901
|
+
case nsXPTType::T_WCHAR_STR : POPULATE(jschar*); break;
|
1902
|
+
case nsXPTType::T_INTERFACE : POPULATE(nsISupports*); break;
|
1903
|
+
case nsXPTType::T_INTERFACE_IS : POPULATE(nsISupports*); break;
|
1904
|
+
case nsXPTType::T_UTF8STRING : NS_ASSERTION(0,"bad type"); goto failure;
|
1905
|
+
case nsXPTType::T_CSTRING : NS_ASSERTION(0,"bad type"); goto failure;
|
1906
|
+
case nsXPTType::T_ASTRING : NS_ASSERTION(0,"bad type"); goto failure;
|
1907
|
+
default : NS_ASSERTION(0,"bad type"); goto failure;
|
1908
|
+
}
|
1909
|
+
|
1910
|
+
if(pErr)
|
1911
|
+
*pErr = NS_OK;
|
1912
|
+
return JS_TRUE;
|
1913
|
+
|
1914
|
+
failure:
|
1915
|
+
return JS_FALSE;
|
1916
|
+
|
1917
|
+
#undef POPULATE
|
1918
|
+
}
|
1919
|
+
|
1920
|
+
// static
|
1921
|
+
JSBool
|
1922
|
+
XPCConvert::JSArray2Native(XPCCallContext& ccx, void** d, jsval s,
|
1923
|
+
JSUint32 count, JSUint32 capacity,
|
1924
|
+
const nsXPTType& type,
|
1925
|
+
JSBool useAllocator, const nsID* iid,
|
1926
|
+
uintN* pErr)
|
1927
|
+
{
|
1928
|
+
NS_PRECONDITION(d, "bad param");
|
1929
|
+
|
1930
|
+
JSContext* cx = ccx.GetJSContext();
|
1931
|
+
|
1932
|
+
// No Action, FRee memory, RElease object
|
1933
|
+
enum CleanupMode {na, fr, re};
|
1934
|
+
|
1935
|
+
CleanupMode cleanupMode;
|
1936
|
+
|
1937
|
+
JSObject* jsarray = nsnull;
|
1938
|
+
void* array = nsnull;
|
1939
|
+
JSUint32 initedCount;
|
1940
|
+
jsval current;
|
1941
|
+
|
1942
|
+
// XXX add support for getting chars from strings
|
1943
|
+
|
1944
|
+
// XXX add support to indicate *which* array element was not convertable
|
1945
|
+
|
1946
|
+
if(JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
|
1947
|
+
{
|
1948
|
+
if(0 != count)
|
1949
|
+
{
|
1950
|
+
if(pErr)
|
1951
|
+
*pErr = NS_ERROR_XPC_NOT_ENOUGH_ELEMENTS_IN_ARRAY;
|
1952
|
+
return JS_FALSE;
|
1953
|
+
}
|
1954
|
+
|
1955
|
+
// If a non-zero capacity was indicated then we build an
|
1956
|
+
// empty array rather than return nsnull.
|
1957
|
+
if(0 != capacity)
|
1958
|
+
goto fill_array;
|
1959
|
+
|
1960
|
+
*d = nsnull;
|
1961
|
+
return JS_TRUE;
|
1962
|
+
}
|
1963
|
+
|
1964
|
+
if(!JSVAL_IS_OBJECT(s))
|
1965
|
+
{
|
1966
|
+
if(pErr)
|
1967
|
+
*pErr = NS_ERROR_XPC_CANT_CONVERT_PRIMITIVE_TO_ARRAY;
|
1968
|
+
return JS_FALSE;
|
1969
|
+
}
|
1970
|
+
|
1971
|
+
jsarray = JSVAL_TO_OBJECT(s);
|
1972
|
+
if(!JS_IsArrayObject(cx, jsarray))
|
1973
|
+
{
|
1974
|
+
if(pErr)
|
1975
|
+
*pErr = NS_ERROR_XPC_CANT_CONVERT_OBJECT_TO_ARRAY;
|
1976
|
+
return JS_FALSE;
|
1977
|
+
}
|
1978
|
+
|
1979
|
+
jsuint len;
|
1980
|
+
if(!JS_GetArrayLength(cx, jsarray, &len) || len < count || capacity < count)
|
1981
|
+
{
|
1982
|
+
if(pErr)
|
1983
|
+
*pErr = NS_ERROR_XPC_NOT_ENOUGH_ELEMENTS_IN_ARRAY;
|
1984
|
+
return JS_FALSE;
|
1985
|
+
}
|
1986
|
+
|
1987
|
+
if(pErr)
|
1988
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS;
|
1989
|
+
|
1990
|
+
#define POPULATE(_mode, _t) \
|
1991
|
+
PR_BEGIN_MACRO \
|
1992
|
+
cleanupMode = _mode; \
|
1993
|
+
if (capacity > ~(size_t)0 / sizeof(_t) || \
|
1994
|
+
nsnull == (array = nsMemory::Alloc(capacity * sizeof(_t)))) \
|
1995
|
+
{ \
|
1996
|
+
if(pErr) \
|
1997
|
+
*pErr = NS_ERROR_OUT_OF_MEMORY; \
|
1998
|
+
goto failure; \
|
1999
|
+
} \
|
2000
|
+
for(initedCount = 0; initedCount < count; initedCount++) \
|
2001
|
+
{ \
|
2002
|
+
if(!JS_GetElement(cx, jsarray, initedCount, ¤t) || \
|
2003
|
+
!JSData2Native(ccx, ((_t*)array)+initedCount, current, type, \
|
2004
|
+
useAllocator, iid, pErr)) \
|
2005
|
+
goto failure; \
|
2006
|
+
} \
|
2007
|
+
PR_END_MACRO
|
2008
|
+
|
2009
|
+
|
2010
|
+
// XXX check IsPtr - esp. to handle array of nsID (as opposed to nsID*)
|
2011
|
+
|
2012
|
+
// XXX make extra space at end of char* and wchar* and null termintate
|
2013
|
+
|
2014
|
+
fill_array:
|
2015
|
+
switch(type.TagPart())
|
2016
|
+
{
|
2017
|
+
case nsXPTType::T_I8 : POPULATE(na, int8); break;
|
2018
|
+
case nsXPTType::T_I16 : POPULATE(na, int16); break;
|
2019
|
+
case nsXPTType::T_I32 : POPULATE(na, int32); break;
|
2020
|
+
case nsXPTType::T_I64 : POPULATE(na, int64); break;
|
2021
|
+
case nsXPTType::T_U8 : POPULATE(na, uint8); break;
|
2022
|
+
case nsXPTType::T_U16 : POPULATE(na, uint16); break;
|
2023
|
+
case nsXPTType::T_U32 : POPULATE(na, uint32); break;
|
2024
|
+
case nsXPTType::T_U64 : POPULATE(na, uint64); break;
|
2025
|
+
case nsXPTType::T_FLOAT : POPULATE(na, float); break;
|
2026
|
+
case nsXPTType::T_DOUBLE : POPULATE(na, double); break;
|
2027
|
+
case nsXPTType::T_BOOL : POPULATE(na, PRBool); break;
|
2028
|
+
case nsXPTType::T_CHAR : POPULATE(na, char); break;
|
2029
|
+
case nsXPTType::T_WCHAR : POPULATE(na, jschar); break;
|
2030
|
+
case nsXPTType::T_VOID : NS_ASSERTION(0,"bad type"); goto failure;
|
2031
|
+
case nsXPTType::T_IID : POPULATE(fr, nsID*); break;
|
2032
|
+
case nsXPTType::T_DOMSTRING : NS_ASSERTION(0,"bad type"); goto failure;
|
2033
|
+
case nsXPTType::T_CHAR_STR : POPULATE(fr, char*); break;
|
2034
|
+
case nsXPTType::T_WCHAR_STR : POPULATE(fr, jschar*); break;
|
2035
|
+
case nsXPTType::T_INTERFACE : POPULATE(re, nsISupports*); break;
|
2036
|
+
case nsXPTType::T_INTERFACE_IS : POPULATE(re, nsISupports*); break;
|
2037
|
+
case nsXPTType::T_UTF8STRING : NS_ASSERTION(0,"bad type"); goto failure;
|
2038
|
+
case nsXPTType::T_CSTRING : NS_ASSERTION(0,"bad type"); goto failure;
|
2039
|
+
case nsXPTType::T_ASTRING : NS_ASSERTION(0,"bad type"); goto failure;
|
2040
|
+
default : NS_ASSERTION(0,"bad type"); goto failure;
|
2041
|
+
}
|
2042
|
+
|
2043
|
+
*d = array;
|
2044
|
+
if(pErr)
|
2045
|
+
*pErr = NS_OK;
|
2046
|
+
return JS_TRUE;
|
2047
|
+
|
2048
|
+
failure:
|
2049
|
+
// we may need to cleanup the partially filled array of converted stuff
|
2050
|
+
if(array)
|
2051
|
+
{
|
2052
|
+
if(cleanupMode == re)
|
2053
|
+
{
|
2054
|
+
nsISupports** a = (nsISupports**) array;
|
2055
|
+
for(PRUint32 i = 0; i < initedCount; i++)
|
2056
|
+
{
|
2057
|
+
nsISupports* p = a[i];
|
2058
|
+
NS_IF_RELEASE(p);
|
2059
|
+
}
|
2060
|
+
}
|
2061
|
+
else if(cleanupMode == fr && useAllocator)
|
2062
|
+
{
|
2063
|
+
void** a = (void**) array;
|
2064
|
+
for(PRUint32 i = 0; i < initedCount; i++)
|
2065
|
+
{
|
2066
|
+
void* p = a[i];
|
2067
|
+
if(p) nsMemory::Free(p);
|
2068
|
+
}
|
2069
|
+
}
|
2070
|
+
nsMemory::Free(array);
|
2071
|
+
}
|
2072
|
+
|
2073
|
+
return JS_FALSE;
|
2074
|
+
|
2075
|
+
#undef POPULATE
|
2076
|
+
}
|
2077
|
+
|
2078
|
+
// static
|
2079
|
+
JSBool
|
2080
|
+
XPCConvert::NativeStringWithSize2JS(XPCCallContext& ccx,
|
2081
|
+
jsval* d, const void* s,
|
2082
|
+
const nsXPTType& type,
|
2083
|
+
JSUint32 count,
|
2084
|
+
nsresult* pErr)
|
2085
|
+
{
|
2086
|
+
NS_PRECONDITION(s, "bad param");
|
2087
|
+
NS_PRECONDITION(d, "bad param");
|
2088
|
+
|
2089
|
+
JSContext* cx = ccx.GetJSContext();
|
2090
|
+
|
2091
|
+
if(pErr)
|
2092
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
|
2093
|
+
|
2094
|
+
if(!type.IsPointer())
|
2095
|
+
{
|
2096
|
+
XPC_LOG_ERROR(("XPCConvert::NativeStringWithSize2JS : unsupported type"));
|
2097
|
+
return JS_FALSE;
|
2098
|
+
}
|
2099
|
+
switch(type.TagPart())
|
2100
|
+
{
|
2101
|
+
case nsXPTType::T_PSTRING_SIZE_IS:
|
2102
|
+
{
|
2103
|
+
char* p = *((char**)s);
|
2104
|
+
if(!p)
|
2105
|
+
break;
|
2106
|
+
JSString* str;
|
2107
|
+
if(!(str = JS_NewStringCopyN(cx, p, count)))
|
2108
|
+
return JS_FALSE;
|
2109
|
+
*d = STRING_TO_JSVAL(str);
|
2110
|
+
break;
|
2111
|
+
}
|
2112
|
+
case nsXPTType::T_PWSTRING_SIZE_IS:
|
2113
|
+
{
|
2114
|
+
jschar* p = *((jschar**)s);
|
2115
|
+
if(!p)
|
2116
|
+
break;
|
2117
|
+
JSString* str;
|
2118
|
+
if(!(str = JS_NewUCStringCopyN(cx, p, count)))
|
2119
|
+
return JS_FALSE;
|
2120
|
+
*d = STRING_TO_JSVAL(str);
|
2121
|
+
break;
|
2122
|
+
}
|
2123
|
+
default:
|
2124
|
+
XPC_LOG_ERROR(("XPCConvert::NativeStringWithSize2JS : unsupported type"));
|
2125
|
+
return JS_FALSE;
|
2126
|
+
}
|
2127
|
+
return JS_TRUE;
|
2128
|
+
}
|
2129
|
+
|
2130
|
+
// static
|
2131
|
+
JSBool
|
2132
|
+
XPCConvert::JSStringWithSize2Native(XPCCallContext& ccx, void* d, jsval s,
|
2133
|
+
JSUint32 count, JSUint32 capacity,
|
2134
|
+
const nsXPTType& type,
|
2135
|
+
JSBool useAllocator,
|
2136
|
+
uintN* pErr)
|
2137
|
+
{
|
2138
|
+
NS_PRECONDITION(s, "bad param");
|
2139
|
+
NS_PRECONDITION(d, "bad param");
|
2140
|
+
|
2141
|
+
JSContext* cx = ccx.GetJSContext();
|
2142
|
+
|
2143
|
+
JSUint32 len;
|
2144
|
+
|
2145
|
+
if(pErr)
|
2146
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_NATIVE;
|
2147
|
+
|
2148
|
+
if(capacity < count)
|
2149
|
+
{
|
2150
|
+
if(pErr)
|
2151
|
+
*pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
|
2152
|
+
return JS_FALSE;
|
2153
|
+
}
|
2154
|
+
|
2155
|
+
if(!type.IsPointer())
|
2156
|
+
{
|
2157
|
+
XPC_LOG_ERROR(("XPCConvert::JSStringWithSize2Native : unsupported type"));
|
2158
|
+
return JS_FALSE;
|
2159
|
+
}
|
2160
|
+
switch(type.TagPart())
|
2161
|
+
{
|
2162
|
+
case nsXPTType::T_PSTRING_SIZE_IS:
|
2163
|
+
{
|
2164
|
+
char* bytes=nsnull;
|
2165
|
+
JSString* str;
|
2166
|
+
|
2167
|
+
if(JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
|
2168
|
+
{
|
2169
|
+
if(0 != count)
|
2170
|
+
{
|
2171
|
+
if(pErr)
|
2172
|
+
*pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
|
2173
|
+
return JS_FALSE;
|
2174
|
+
}
|
2175
|
+
if(type.IsReference())
|
2176
|
+
{
|
2177
|
+
if(pErr)
|
2178
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
|
2179
|
+
return JS_FALSE;
|
2180
|
+
}
|
2181
|
+
|
2182
|
+
if(useAllocator && 0 != capacity)
|
2183
|
+
{
|
2184
|
+
len = (capacity + 1) * sizeof(char);
|
2185
|
+
if(!(*((void**)d) = nsMemory::Alloc(len)))
|
2186
|
+
return JS_FALSE;
|
2187
|
+
return JS_TRUE;
|
2188
|
+
}
|
2189
|
+
// else ...
|
2190
|
+
|
2191
|
+
*((char**)d) = nsnull;
|
2192
|
+
return JS_TRUE;
|
2193
|
+
}
|
2194
|
+
|
2195
|
+
if(!(str = JS_ValueToString(cx, s))||
|
2196
|
+
!(bytes = JS_GetStringBytes(str)))
|
2197
|
+
{
|
2198
|
+
return JS_FALSE;
|
2199
|
+
}
|
2200
|
+
|
2201
|
+
len = JS_GetStringLength(str);
|
2202
|
+
if(len > count)
|
2203
|
+
{
|
2204
|
+
if(pErr)
|
2205
|
+
*pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
|
2206
|
+
return JS_FALSE;
|
2207
|
+
}
|
2208
|
+
|
2209
|
+
if(len < capacity)
|
2210
|
+
len = capacity;
|
2211
|
+
|
2212
|
+
if(useAllocator)
|
2213
|
+
{
|
2214
|
+
JSUint32 alloc_len = (len + 1) * sizeof(char);
|
2215
|
+
if(!(*((void**)d) = nsMemory::Alloc(alloc_len)))
|
2216
|
+
{
|
2217
|
+
return JS_FALSE;
|
2218
|
+
}
|
2219
|
+
memcpy(*((char**)d), bytes, count);
|
2220
|
+
(*((char**)d))[count] = 0;
|
2221
|
+
}
|
2222
|
+
else
|
2223
|
+
*((char**)d) = bytes;
|
2224
|
+
|
2225
|
+
return JS_TRUE;
|
2226
|
+
}
|
2227
|
+
|
2228
|
+
case nsXPTType::T_PWSTRING_SIZE_IS:
|
2229
|
+
{
|
2230
|
+
jschar* chars=nsnull;
|
2231
|
+
JSString* str;
|
2232
|
+
|
2233
|
+
if(JSVAL_IS_VOID(s) || JSVAL_IS_NULL(s))
|
2234
|
+
{
|
2235
|
+
if(0 != count)
|
2236
|
+
{
|
2237
|
+
if(pErr)
|
2238
|
+
*pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
|
2239
|
+
return JS_FALSE;
|
2240
|
+
}
|
2241
|
+
if(type.IsReference())
|
2242
|
+
{
|
2243
|
+
if(pErr)
|
2244
|
+
*pErr = NS_ERROR_XPC_BAD_CONVERT_JS_NULL_REF;
|
2245
|
+
return JS_FALSE;
|
2246
|
+
}
|
2247
|
+
|
2248
|
+
if(useAllocator && 0 != capacity)
|
2249
|
+
{
|
2250
|
+
len = (capacity + 1) * sizeof(jschar);
|
2251
|
+
if(!(*((void**)d) = nsMemory::Alloc(len)))
|
2252
|
+
return JS_FALSE;
|
2253
|
+
return JS_TRUE;
|
2254
|
+
}
|
2255
|
+
|
2256
|
+
// else ...
|
2257
|
+
*((jschar**)d) = nsnull;
|
2258
|
+
return JS_TRUE;
|
2259
|
+
}
|
2260
|
+
|
2261
|
+
if(!(str = JS_ValueToString(cx, s))||
|
2262
|
+
!(chars = JS_GetStringChars(str)))
|
2263
|
+
{
|
2264
|
+
return JS_FALSE;
|
2265
|
+
}
|
2266
|
+
|
2267
|
+
len = JS_GetStringLength(str);
|
2268
|
+
if(len > count)
|
2269
|
+
{
|
2270
|
+
if(pErr)
|
2271
|
+
*pErr = NS_ERROR_XPC_NOT_ENOUGH_CHARS_IN_STRING;
|
2272
|
+
return JS_FALSE;
|
2273
|
+
}
|
2274
|
+
if(len < capacity)
|
2275
|
+
len = capacity;
|
2276
|
+
|
2277
|
+
if(useAllocator)
|
2278
|
+
{
|
2279
|
+
JSUint32 alloc_len = (len + 1) * sizeof(jschar);
|
2280
|
+
if(!(*((void**)d) = nsMemory::Alloc(alloc_len)))
|
2281
|
+
{
|
2282
|
+
// XXX should report error
|
2283
|
+
return JS_FALSE;
|
2284
|
+
}
|
2285
|
+
memcpy(*((jschar**)d), chars, alloc_len);
|
2286
|
+
(*((jschar**)d))[count] = 0;
|
2287
|
+
}
|
2288
|
+
else
|
2289
|
+
*((jschar**)d) = chars;
|
2290
|
+
|
2291
|
+
return JS_TRUE;
|
2292
|
+
}
|
2293
|
+
default:
|
2294
|
+
XPC_LOG_ERROR(("XPCConvert::JSStringWithSize2Native : unsupported type"));
|
2295
|
+
return JS_FALSE;
|
2296
|
+
}
|
2297
|
+
}
|
2298
|
+
|