johnson 2.0.0.pre1 → 2.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +12 -0
- data/Manifest.txt +4 -285
- data/Rakefile +13 -20
- data/ext/tracemonkey/global.cc +4 -1
- data/ext/tracemonkey/js.cc +30 -33
- data/ext/tracemonkey/runtime.cc +96 -6
- data/ext/tracemonkey/split_global.cc +0 -5
- data/ext/tracemonkey/tracemonkey.h +2 -2
- data/lib/johnson.rb +2 -2
- data/lib/johnson/runtime.rb +25 -15
- data/lib/johnson/tracemonkey/runtime.rb +6 -3
- data/vendor/tracemonkey/config/system-headers +1 -3
- data/vendor/tracemonkey/jscntxt.h +5 -2
- data/vendor/tracemonkey/jsdbgapi.cpp +9 -1
- data/vendor/tracemonkey/jsdbgapi.h +4 -0
- data/vendor/tracemonkey/tests/ecma/NativeObjects/browser.js +0 -0
- data/vendor/tracemonkey/tests/ecma/NativeObjects/jstests.list +0 -0
- data/vendor/tracemonkey/tests/ecma_3_1/Object/jstests.list +1 -1
- data/vendor/tracemonkey/tests/js1_3/misc/browser.js +0 -0
- data/vendor/tracemonkey/tests/js1_3/misc/jstests.list +0 -0
- data/vendor/tracemonkey/tests/js1_5/Regress/jstests.list +4 -4
- data/vendor/tracemonkey/tests/js1_5/Scope/jstests.list +1 -1
- data/vendor/tracemonkey/tests/js1_5/decompilation/jstests.list +2 -2
- data/vendor/tracemonkey/tests/js1_7/decompilation/jstests.list +1 -1
- data/vendor/tracemonkey/tests/shell.js +2 -1
- metadata +51 -309
- data/ext/spidermonkey/context.c +0 -116
- data/ext/spidermonkey/context.h +0 -19
- data/ext/spidermonkey/conversions.c +0 -361
- data/ext/spidermonkey/conversions.h +0 -31
- data/ext/spidermonkey/debugger.c +0 -234
- data/ext/spidermonkey/debugger.h +0 -10
- data/ext/spidermonkey/extconf.rb +0 -32
- data/ext/spidermonkey/extensions.c +0 -37
- data/ext/spidermonkey/extensions.h +0 -12
- data/ext/spidermonkey/global.c +0 -40
- data/ext/spidermonkey/global.h +0 -11
- data/ext/spidermonkey/idhash.c +0 -16
- data/ext/spidermonkey/idhash.h +0 -8
- data/ext/spidermonkey/immutable_node.c +0 -1153
- data/ext/spidermonkey/immutable_node.c.erb +0 -523
- data/ext/spidermonkey/immutable_node.h +0 -22
- data/ext/spidermonkey/jroot.h +0 -197
- data/ext/spidermonkey/js_land_proxy.c +0 -620
- data/ext/spidermonkey/js_land_proxy.h +0 -20
- data/ext/spidermonkey/ruby_land_proxy.c +0 -618
- data/ext/spidermonkey/ruby_land_proxy.h +0 -38
- data/ext/spidermonkey/runtime.c +0 -396
- data/ext/spidermonkey/runtime.h +0 -27
- data/ext/spidermonkey/spidermonkey.c +0 -22
- data/ext/spidermonkey/spidermonkey.h +0 -29
- data/lib/johnson/spidermonkey.rb +0 -12
- data/lib/johnson/spidermonkey/context.rb +0 -10
- data/lib/johnson/spidermonkey/debugger.rb +0 -67
- data/lib/johnson/spidermonkey/immutable_node.rb +0 -282
- data/lib/johnson/spidermonkey/js_land_proxy.rb +0 -64
- data/lib/johnson/spidermonkey/mutable_tree_visitor.rb +0 -242
- data/lib/johnson/spidermonkey/ruby_land_proxy.rb +0 -17
- data/lib/johnson/spidermonkey/runtime.rb +0 -74
- data/test/johnson/spidermonkey/context_test.rb +0 -21
- data/test/johnson/spidermonkey/immutable_node_test.rb +0 -34
- data/test/johnson/spidermonkey/js_land_proxy_test.rb +0 -273
- data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +0 -274
- data/test/johnson/spidermonkey/runtime_test.rb +0 -41
- data/vendor/spidermonkey/.cvsignore +0 -9
- data/vendor/spidermonkey/Makefile.in +0 -449
- data/vendor/spidermonkey/Makefile.ref +0 -365
- data/vendor/spidermonkey/README.html +0 -820
- data/vendor/spidermonkey/SpiderMonkey.rsp +0 -12
- data/vendor/spidermonkey/Y.js +0 -19
- data/vendor/spidermonkey/build.mk +0 -43
- data/vendor/spidermonkey/config.mk +0 -192
- data/vendor/spidermonkey/config/AIX4.1.mk +0 -65
- data/vendor/spidermonkey/config/AIX4.2.mk +0 -64
- data/vendor/spidermonkey/config/AIX4.3.mk +0 -65
- data/vendor/spidermonkey/config/Darwin.mk +0 -83
- data/vendor/spidermonkey/config/Darwin1.3.mk +0 -81
- data/vendor/spidermonkey/config/Darwin1.4.mk +0 -41
- data/vendor/spidermonkey/config/Darwin5.2.mk +0 -81
- data/vendor/spidermonkey/config/Darwin5.3.mk +0 -81
- data/vendor/spidermonkey/config/HP-UXB.10.10.mk +0 -77
- data/vendor/spidermonkey/config/HP-UXB.10.20.mk +0 -77
- data/vendor/spidermonkey/config/HP-UXB.11.00.mk +0 -80
- data/vendor/spidermonkey/config/IRIX.mk +0 -87
- data/vendor/spidermonkey/config/IRIX5.3.mk +0 -44
- data/vendor/spidermonkey/config/IRIX6.1.mk +0 -44
- data/vendor/spidermonkey/config/IRIX6.2.mk +0 -44
- data/vendor/spidermonkey/config/IRIX6.3.mk +0 -44
- data/vendor/spidermonkey/config/IRIX6.5.mk +0 -44
- data/vendor/spidermonkey/config/Linux_All.mk +0 -103
- data/vendor/spidermonkey/config/Mac_OS10.0.mk +0 -82
- data/vendor/spidermonkey/config/OSF1V4.0.mk +0 -72
- data/vendor/spidermonkey/config/OSF1V5.0.mk +0 -69
- data/vendor/spidermonkey/config/SunOS4.1.4.mk +0 -101
- data/vendor/spidermonkey/config/SunOS5.10.mk +0 -50
- data/vendor/spidermonkey/config/SunOS5.3.mk +0 -91
- data/vendor/spidermonkey/config/SunOS5.4.mk +0 -92
- data/vendor/spidermonkey/config/SunOS5.5.1.mk +0 -44
- data/vendor/spidermonkey/config/SunOS5.5.mk +0 -87
- data/vendor/spidermonkey/config/SunOS5.6.mk +0 -89
- data/vendor/spidermonkey/config/SunOS5.7.mk +0 -44
- data/vendor/spidermonkey/config/SunOS5.8.mk +0 -44
- data/vendor/spidermonkey/config/SunOS5.9.mk +0 -44
- data/vendor/spidermonkey/config/WINNT4.0.mk +0 -117
- data/vendor/spidermonkey/config/WINNT5.0.mk +0 -117
- data/vendor/spidermonkey/config/WINNT5.1.mk +0 -117
- data/vendor/spidermonkey/config/WINNT5.2.mk +0 -117
- data/vendor/spidermonkey/config/WINNT6.0.mk +0 -117
- data/vendor/spidermonkey/config/dgux.mk +0 -64
- data/vendor/spidermonkey/editline/Makefile.ref +0 -144
- data/vendor/spidermonkey/editline/README +0 -83
- data/vendor/spidermonkey/editline/editline.3 +0 -175
- data/vendor/spidermonkey/editline/editline.c +0 -1369
- data/vendor/spidermonkey/editline/editline.h +0 -135
- data/vendor/spidermonkey/editline/sysunix.c +0 -182
- data/vendor/spidermonkey/editline/unix.h +0 -82
- data/vendor/spidermonkey/fdlibm/.cvsignore +0 -7
- data/vendor/spidermonkey/fdlibm/Makefile.in +0 -127
- data/vendor/spidermonkey/fdlibm/Makefile.ref +0 -192
- data/vendor/spidermonkey/fdlibm/e_acos.c +0 -147
- data/vendor/spidermonkey/fdlibm/e_acosh.c +0 -105
- data/vendor/spidermonkey/fdlibm/e_asin.c +0 -156
- data/vendor/spidermonkey/fdlibm/e_atan2.c +0 -165
- data/vendor/spidermonkey/fdlibm/e_atanh.c +0 -110
- data/vendor/spidermonkey/fdlibm/e_cosh.c +0 -133
- data/vendor/spidermonkey/fdlibm/e_exp.c +0 -202
- data/vendor/spidermonkey/fdlibm/e_fmod.c +0 -184
- data/vendor/spidermonkey/fdlibm/e_gamma.c +0 -71
- data/vendor/spidermonkey/fdlibm/e_gamma_r.c +0 -70
- data/vendor/spidermonkey/fdlibm/e_hypot.c +0 -173
- data/vendor/spidermonkey/fdlibm/e_j0.c +0 -524
- data/vendor/spidermonkey/fdlibm/e_j1.c +0 -523
- data/vendor/spidermonkey/fdlibm/e_jn.c +0 -315
- data/vendor/spidermonkey/fdlibm/e_lgamma.c +0 -71
- data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +0 -347
- data/vendor/spidermonkey/fdlibm/e_log.c +0 -184
- data/vendor/spidermonkey/fdlibm/e_log10.c +0 -134
- data/vendor/spidermonkey/fdlibm/e_pow.c +0 -386
- data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +0 -222
- data/vendor/spidermonkey/fdlibm/e_remainder.c +0 -120
- data/vendor/spidermonkey/fdlibm/e_scalb.c +0 -89
- data/vendor/spidermonkey/fdlibm/e_sinh.c +0 -122
- data/vendor/spidermonkey/fdlibm/e_sqrt.c +0 -497
- data/vendor/spidermonkey/fdlibm/fdlibm.h +0 -273
- data/vendor/spidermonkey/fdlibm/fdlibm.mak +0 -1453
- data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
- data/vendor/spidermonkey/fdlibm/k_cos.c +0 -135
- data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +0 -354
- data/vendor/spidermonkey/fdlibm/k_sin.c +0 -114
- data/vendor/spidermonkey/fdlibm/k_standard.c +0 -785
- data/vendor/spidermonkey/fdlibm/k_tan.c +0 -170
- data/vendor/spidermonkey/fdlibm/s_asinh.c +0 -101
- data/vendor/spidermonkey/fdlibm/s_atan.c +0 -175
- data/vendor/spidermonkey/fdlibm/s_cbrt.c +0 -133
- data/vendor/spidermonkey/fdlibm/s_ceil.c +0 -120
- data/vendor/spidermonkey/fdlibm/s_copysign.c +0 -72
- data/vendor/spidermonkey/fdlibm/s_cos.c +0 -118
- data/vendor/spidermonkey/fdlibm/s_erf.c +0 -356
- data/vendor/spidermonkey/fdlibm/s_expm1.c +0 -267
- data/vendor/spidermonkey/fdlibm/s_fabs.c +0 -70
- data/vendor/spidermonkey/fdlibm/s_finite.c +0 -71
- data/vendor/spidermonkey/fdlibm/s_floor.c +0 -121
- data/vendor/spidermonkey/fdlibm/s_frexp.c +0 -99
- data/vendor/spidermonkey/fdlibm/s_ilogb.c +0 -85
- data/vendor/spidermonkey/fdlibm/s_isnan.c +0 -74
- data/vendor/spidermonkey/fdlibm/s_ldexp.c +0 -66
- data/vendor/spidermonkey/fdlibm/s_lib_version.c +0 -73
- data/vendor/spidermonkey/fdlibm/s_log1p.c +0 -211
- data/vendor/spidermonkey/fdlibm/s_logb.c +0 -79
- data/vendor/spidermonkey/fdlibm/s_matherr.c +0 -64
- data/vendor/spidermonkey/fdlibm/s_modf.c +0 -132
- data/vendor/spidermonkey/fdlibm/s_nextafter.c +0 -124
- data/vendor/spidermonkey/fdlibm/s_rint.c +0 -131
- data/vendor/spidermonkey/fdlibm/s_scalbn.c +0 -107
- data/vendor/spidermonkey/fdlibm/s_signgam.c +0 -40
- data/vendor/spidermonkey/fdlibm/s_significand.c +0 -68
- data/vendor/spidermonkey/fdlibm/s_sin.c +0 -118
- data/vendor/spidermonkey/fdlibm/s_tan.c +0 -112
- data/vendor/spidermonkey/fdlibm/s_tanh.c +0 -122
- data/vendor/spidermonkey/fdlibm/w_acos.c +0 -78
- data/vendor/spidermonkey/fdlibm/w_acosh.c +0 -78
- data/vendor/spidermonkey/fdlibm/w_asin.c +0 -80
- data/vendor/spidermonkey/fdlibm/w_atan2.c +0 -79
- data/vendor/spidermonkey/fdlibm/w_atanh.c +0 -81
- data/vendor/spidermonkey/fdlibm/w_cosh.c +0 -77
- data/vendor/spidermonkey/fdlibm/w_exp.c +0 -88
- data/vendor/spidermonkey/fdlibm/w_fmod.c +0 -78
- data/vendor/spidermonkey/fdlibm/w_gamma.c +0 -85
- data/vendor/spidermonkey/fdlibm/w_gamma_r.c +0 -81
- data/vendor/spidermonkey/fdlibm/w_hypot.c +0 -78
- data/vendor/spidermonkey/fdlibm/w_j0.c +0 -105
- data/vendor/spidermonkey/fdlibm/w_j1.c +0 -106
- data/vendor/spidermonkey/fdlibm/w_jn.c +0 -128
- data/vendor/spidermonkey/fdlibm/w_lgamma.c +0 -85
- data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +0 -81
- data/vendor/spidermonkey/fdlibm/w_log.c +0 -78
- data/vendor/spidermonkey/fdlibm/w_log10.c +0 -81
- data/vendor/spidermonkey/fdlibm/w_pow.c +0 -99
- data/vendor/spidermonkey/fdlibm/w_remainder.c +0 -77
- data/vendor/spidermonkey/fdlibm/w_scalb.c +0 -95
- data/vendor/spidermonkey/fdlibm/w_sinh.c +0 -77
- data/vendor/spidermonkey/fdlibm/w_sqrt.c +0 -77
- data/vendor/spidermonkey/javascript-trace.d +0 -73
- data/vendor/spidermonkey/js.c +0 -3951
- data/vendor/spidermonkey/js.mdp +0 -0
- data/vendor/spidermonkey/js.msg +0 -308
- data/vendor/spidermonkey/js.pkg +0 -2
- data/vendor/spidermonkey/js3240.rc +0 -79
- data/vendor/spidermonkey/jsOS240.def +0 -654
- data/vendor/spidermonkey/jsapi.c +0 -5836
- data/vendor/spidermonkey/jsapi.h +0 -2624
- data/vendor/spidermonkey/jsarena.c +0 -450
- data/vendor/spidermonkey/jsarena.h +0 -318
- data/vendor/spidermonkey/jsarray.c +0 -2996
- data/vendor/spidermonkey/jsarray.h +0 -127
- data/vendor/spidermonkey/jsatom.c +0 -1045
- data/vendor/spidermonkey/jsatom.h +0 -442
- data/vendor/spidermonkey/jsbit.h +0 -253
- data/vendor/spidermonkey/jsbool.c +0 -176
- data/vendor/spidermonkey/jsbool.h +0 -73
- data/vendor/spidermonkey/jsclist.h +0 -139
- data/vendor/spidermonkey/jscntxt.c +0 -1348
- data/vendor/spidermonkey/jscntxt.h +0 -1120
- data/vendor/spidermonkey/jscompat.h +0 -57
- data/vendor/spidermonkey/jsconfig.h +0 -248
- data/vendor/spidermonkey/jsconfig.mk +0 -181
- data/vendor/spidermonkey/jscpucfg.c +0 -396
- data/vendor/spidermonkey/jscpucfg.h +0 -212
- data/vendor/spidermonkey/jsdate.c +0 -2390
- data/vendor/spidermonkey/jsdate.h +0 -124
- data/vendor/spidermonkey/jsdbgapi.c +0 -1802
- data/vendor/spidermonkey/jsdbgapi.h +0 -464
- data/vendor/spidermonkey/jsdhash.c +0 -868
- data/vendor/spidermonkey/jsdhash.h +0 -592
- data/vendor/spidermonkey/jsdtoa.c +0 -3167
- data/vendor/spidermonkey/jsdtoa.h +0 -130
- data/vendor/spidermonkey/jsdtracef.c +0 -317
- data/vendor/spidermonkey/jsdtracef.h +0 -77
- data/vendor/spidermonkey/jsemit.c +0 -6909
- data/vendor/spidermonkey/jsemit.h +0 -741
- data/vendor/spidermonkey/jsexn.c +0 -1371
- data/vendor/spidermonkey/jsexn.h +0 -96
- data/vendor/spidermonkey/jsfile.c +0 -2736
- data/vendor/spidermonkey/jsfile.h +0 -56
- data/vendor/spidermonkey/jsfile.msg +0 -90
- data/vendor/spidermonkey/jsfun.c +0 -2634
- data/vendor/spidermonkey/jsfun.h +0 -254
- data/vendor/spidermonkey/jsgc.c +0 -3562
- data/vendor/spidermonkey/jsgc.h +0 -403
- data/vendor/spidermonkey/jshash.c +0 -476
- data/vendor/spidermonkey/jshash.h +0 -151
- data/vendor/spidermonkey/jsify.pl +0 -485
- data/vendor/spidermonkey/jsinterp.c +0 -7007
- data/vendor/spidermonkey/jsinterp.h +0 -525
- data/vendor/spidermonkey/jsinvoke.c +0 -43
- data/vendor/spidermonkey/jsiter.c +0 -1067
- data/vendor/spidermonkey/jsiter.h +0 -122
- data/vendor/spidermonkey/jskeyword.tbl +0 -124
- data/vendor/spidermonkey/jskwgen.c +0 -460
- data/vendor/spidermonkey/jslibmath.h +0 -266
- data/vendor/spidermonkey/jslock.c +0 -1309
- data/vendor/spidermonkey/jslock.h +0 -313
- data/vendor/spidermonkey/jslocko.asm +0 -60
- data/vendor/spidermonkey/jslog2.c +0 -94
- data/vendor/spidermonkey/jslong.c +0 -264
- data/vendor/spidermonkey/jslong.h +0 -412
- data/vendor/spidermonkey/jsmath.c +0 -567
- data/vendor/spidermonkey/jsmath.h +0 -57
- data/vendor/spidermonkey/jsnum.c +0 -1239
- data/vendor/spidermonkey/jsnum.h +0 -283
- data/vendor/spidermonkey/jsobj.c +0 -5282
- data/vendor/spidermonkey/jsobj.h +0 -709
- data/vendor/spidermonkey/jsopcode.c +0 -5245
- data/vendor/spidermonkey/jsopcode.h +0 -394
- data/vendor/spidermonkey/jsopcode.tbl +0 -523
- data/vendor/spidermonkey/jsotypes.h +0 -202
- data/vendor/spidermonkey/jsparse.c +0 -6704
- data/vendor/spidermonkey/jsparse.h +0 -511
- data/vendor/spidermonkey/jsprf.c +0 -1264
- data/vendor/spidermonkey/jsprf.h +0 -150
- data/vendor/spidermonkey/jsproto.tbl +0 -128
- data/vendor/spidermonkey/jsprvtd.h +0 -267
- data/vendor/spidermonkey/jspubtd.h +0 -744
- data/vendor/spidermonkey/jsregexp.c +0 -4364
- data/vendor/spidermonkey/jsregexp.h +0 -183
- data/vendor/spidermonkey/jsreops.tbl +0 -145
- data/vendor/spidermonkey/jsscan.c +0 -2012
- data/vendor/spidermonkey/jsscan.h +0 -387
- data/vendor/spidermonkey/jsscope.c +0 -1957
- data/vendor/spidermonkey/jsscope.h +0 -418
- data/vendor/spidermonkey/jsscript.c +0 -1832
- data/vendor/spidermonkey/jsscript.h +0 -287
- data/vendor/spidermonkey/jsshell.msg +0 -50
- data/vendor/spidermonkey/jsstddef.h +0 -83
- data/vendor/spidermonkey/jsstr.c +0 -5005
- data/vendor/spidermonkey/jsstr.h +0 -641
- data/vendor/spidermonkey/jstypes.h +0 -475
- data/vendor/spidermonkey/jsutil.c +0 -345
- data/vendor/spidermonkey/jsutil.h +0 -157
- data/vendor/spidermonkey/jsxdrapi.c +0 -800
- data/vendor/spidermonkey/jsxdrapi.h +0 -218
- data/vendor/spidermonkey/jsxml.c +0 -8476
- data/vendor/spidermonkey/jsxml.h +0 -349
- data/vendor/spidermonkey/lock_SunOS.s +0 -119
- data/vendor/spidermonkey/perfect.js +0 -39
- data/vendor/spidermonkey/plify_jsdhash.sed +0 -36
- data/vendor/spidermonkey/prmjtime.c +0 -846
- data/vendor/spidermonkey/prmjtime.h +0 -103
- data/vendor/spidermonkey/resource.h +0 -15
- data/vendor/spidermonkey/rules.mk +0 -197
- data/vendor/spidermonkey/win32.order +0 -384
data/vendor/spidermonkey/jsstr.h
DELETED
@@ -1,641 +0,0 @@
|
|
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
|
-
*
|
26
|
-
* Alternatively, the contents of this file may be used under the terms of
|
27
|
-
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
28
|
-
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
29
|
-
* in which case the provisions of the GPL or the LGPL are applicable instead
|
30
|
-
* of those above. If you wish to allow use of your version of this file only
|
31
|
-
* under the terms of either the GPL or the LGPL, and not to allow others to
|
32
|
-
* use your version of this file under the terms of the MPL, indicate your
|
33
|
-
* decision by deleting the provisions above and replace them with the notice
|
34
|
-
* and other provisions required by the GPL or the LGPL. If you do not delete
|
35
|
-
* the provisions above, a recipient may use your version of this file under
|
36
|
-
* the terms of any one of the MPL, the GPL or the LGPL.
|
37
|
-
*
|
38
|
-
* ***** END LICENSE BLOCK ***** */
|
39
|
-
|
40
|
-
#ifndef jsstr_h___
|
41
|
-
#define jsstr_h___
|
42
|
-
/*
|
43
|
-
* JS string type implementation.
|
44
|
-
*
|
45
|
-
* A JS string is a counted array of unicode characters. To support handoff
|
46
|
-
* of API client memory, the chars are allocated separately from the length,
|
47
|
-
* necessitating a pointer after the count, to form a separately allocated
|
48
|
-
* string descriptor. String descriptors are GC'ed, while their chars are
|
49
|
-
* allocated from the malloc heap.
|
50
|
-
*/
|
51
|
-
#include <ctype.h>
|
52
|
-
#include "jspubtd.h"
|
53
|
-
#include "jsprvtd.h"
|
54
|
-
|
55
|
-
JS_BEGIN_EXTERN_C
|
56
|
-
|
57
|
-
/*
|
58
|
-
* The GC-thing "string" type.
|
59
|
-
*
|
60
|
-
* When the JSSTRFLAG_DEPENDENT bit of the length field is unset, the u.chars
|
61
|
-
* field points to a flat character array owned by its GC-thing descriptor.
|
62
|
-
* The array is terminated at index length by a zero character and the size of
|
63
|
-
* the array in bytes is (length + 1) * sizeof(jschar). The terminator is
|
64
|
-
* purely a backstop, in case the chars pointer flows out to native code that
|
65
|
-
* requires \u0000 termination.
|
66
|
-
*
|
67
|
-
* A flat string with JSSTRFLAG_MUTABLE set means that the string is accessible
|
68
|
-
* only from one thread and it is possible to turn it into a dependent string
|
69
|
-
* of the same length to optimize js_ConcatStrings. It is also possible to grow
|
70
|
-
* such a string, but extreme care must be taken to ensure that no other code
|
71
|
-
* relies on the original length of the string.
|
72
|
-
*
|
73
|
-
* A flat string with JSSTRFLAG_ATOMIZED set means that the string is hashed as
|
74
|
-
* an atom. This flag is used to avoid re-hashing the already-atomized string.
|
75
|
-
*
|
76
|
-
* When JSSTRFLAG_DEPENDENT is set, the string depends on characters of another
|
77
|
-
* string strongly referenced by the u.base field. The base member may point to
|
78
|
-
* another dependent string if JSSTRING_CHARS has not been called yet.
|
79
|
-
*
|
80
|
-
* JSSTRFLAG_PREFIX determines the kind of the dependent string. When the flag
|
81
|
-
* is unset, the length field encodes both starting position relative to the
|
82
|
-
* base string and the number of characters in the dependent string, see
|
83
|
-
* JSSTRDEP_START_MASK and JSSTRDEP_LENGTH_MASK macros below for details.
|
84
|
-
*
|
85
|
-
* When JSSTRFLAG_PREFIX is set, the dependent string is a prefix of the base
|
86
|
-
* string. The number of characters in the prefix is encoded using all non-flag
|
87
|
-
* bits of the length field and spans the same 0 .. SIZE_T_MAX/4 range as the
|
88
|
-
* length of the flat string.
|
89
|
-
*
|
90
|
-
* NB: Always use the JSSTRING_LENGTH and JSSTRING_CHARS accessor macros.
|
91
|
-
*/
|
92
|
-
struct JSString {
|
93
|
-
size_t length;
|
94
|
-
union {
|
95
|
-
jschar *chars;
|
96
|
-
JSString *base;
|
97
|
-
} u;
|
98
|
-
};
|
99
|
-
|
100
|
-
/*
|
101
|
-
* Definitions for flags stored in the high order bits of JSString.length.
|
102
|
-
* JSSTRFLAG_PREFIX and JSSTRFLAG_MUTABLE are two aliases for the same value.
|
103
|
-
* JSSTRFLAG_PREFIX should be used only if JSSTRFLAG_DEPENDENT is set and
|
104
|
-
* JSSTRFLAG_MUTABLE should be used only if the string is flat.
|
105
|
-
* JSSTRFLAG_ATOMIZED is used only with the flat immutable strings.
|
106
|
-
*/
|
107
|
-
#define JSSTRFLAG_DEPENDENT JSSTRING_BIT(JS_BITS_PER_WORD - 1)
|
108
|
-
#define JSSTRFLAG_PREFIX JSSTRING_BIT(JS_BITS_PER_WORD - 2)
|
109
|
-
#define JSSTRFLAG_MUTABLE JSSTRFLAG_PREFIX
|
110
|
-
#define JSSTRFLAG_ATOMIZED JSSTRING_BIT(JS_BITS_PER_WORD - 3)
|
111
|
-
|
112
|
-
#define JSSTRING_LENGTH_BITS (JS_BITS_PER_WORD - 3)
|
113
|
-
#define JSSTRING_LENGTH_MASK JSSTRING_BITMASK(JSSTRING_LENGTH_BITS)
|
114
|
-
|
115
|
-
/* Universal JSString type inquiry and accessor macros. */
|
116
|
-
#define JSSTRING_BIT(n) ((size_t)1 << (n))
|
117
|
-
#define JSSTRING_BITMASK(n) (JSSTRING_BIT(n) - 1)
|
118
|
-
#define JSSTRING_HAS_FLAG(str,flg) ((str)->length & (flg))
|
119
|
-
#define JSSTRING_IS_DEPENDENT(str) JSSTRING_HAS_FLAG(str, JSSTRFLAG_DEPENDENT)
|
120
|
-
#define JSSTRING_IS_FLAT(str) (!JSSTRING_IS_DEPENDENT(str))
|
121
|
-
#define JSSTRING_IS_MUTABLE(str) (((str)->length & (JSSTRFLAG_DEPENDENT | \
|
122
|
-
JSSTRFLAG_MUTABLE)) == \
|
123
|
-
JSSTRFLAG_MUTABLE)
|
124
|
-
#define JSSTRING_IS_ATOMIZED(str) (((str)->length & (JSSTRFLAG_DEPENDENT | \
|
125
|
-
JSSTRFLAG_ATOMIZED)) ==\
|
126
|
-
JSSTRFLAG_ATOMIZED)
|
127
|
-
|
128
|
-
#define JSSTRING_CHARS(str) (JSSTRING_IS_DEPENDENT(str) \
|
129
|
-
? JSSTRDEP_CHARS(str) \
|
130
|
-
: JSFLATSTR_CHARS(str))
|
131
|
-
#define JSSTRING_LENGTH(str) (JSSTRING_IS_DEPENDENT(str) \
|
132
|
-
? JSSTRDEP_LENGTH(str) \
|
133
|
-
: JSFLATSTR_LENGTH(str))
|
134
|
-
|
135
|
-
#define JSSTRING_CHARS_AND_LENGTH(str, chars_, length_) \
|
136
|
-
((void)(JSSTRING_IS_DEPENDENT(str) \
|
137
|
-
? ((length_) = JSSTRDEP_LENGTH(str), \
|
138
|
-
(chars_) = JSSTRDEP_CHARS(str)) \
|
139
|
-
: ((length_) = JSFLATSTR_LENGTH(str), \
|
140
|
-
(chars_) = JSFLATSTR_CHARS(str))))
|
141
|
-
|
142
|
-
#define JSSTRING_CHARS_AND_END(str, chars_, end) \
|
143
|
-
((void)((end) = JSSTRING_IS_DEPENDENT(str) \
|
144
|
-
? JSSTRDEP_LENGTH(str) + ((chars_) = JSSTRDEP_CHARS(str)) \
|
145
|
-
: JSFLATSTR_LENGTH(str) + ((chars_) = JSFLATSTR_CHARS(str))))
|
146
|
-
|
147
|
-
/* Specific flat string initializer and accessor macros. */
|
148
|
-
#define JSFLATSTR_INIT(str, chars_, length_) \
|
149
|
-
((void)(JS_ASSERT(((length_) & ~JSSTRING_LENGTH_MASK) == 0), \
|
150
|
-
(str)->length = (length_), (str)->u.chars = (chars_)))
|
151
|
-
|
152
|
-
#define JSFLATSTR_LENGTH(str) \
|
153
|
-
(JS_ASSERT(JSSTRING_IS_FLAT(str)), (str)->length & JSSTRING_LENGTH_MASK)
|
154
|
-
|
155
|
-
#define JSFLATSTR_CHARS(str) \
|
156
|
-
(JS_ASSERT(JSSTRING_IS_FLAT(str)), (str)->u.chars)
|
157
|
-
|
158
|
-
/*
|
159
|
-
* Macros to manipulate atomized and mutable flags of flat strings. It is safe
|
160
|
-
* to use these without extra locking due to the following properties:
|
161
|
-
*
|
162
|
-
* * We do not have a macro like JSFLATSTR_CLEAR_ATOMIZED as a string
|
163
|
-
* remains atomized until the GC collects it.
|
164
|
-
*
|
165
|
-
* * A thread may call JSFLATSTR_SET_MUTABLE only when it is the only thread
|
166
|
-
* accessing the string until a later call to JSFLATSTR_CLEAR_MUTABLE.
|
167
|
-
*
|
168
|
-
* * Multiple threads can call JSFLATSTR_CLEAR_MUTABLE but the macro
|
169
|
-
* actually clears the mutable flag only when the flag is set -- in which
|
170
|
-
* case only one thread can access the string (see previous property).
|
171
|
-
*
|
172
|
-
* Thus, when multiple threads access the string, JSFLATSTR_SET_ATOMIZED is
|
173
|
-
* the only macro that can update the length field of the string by changing
|
174
|
-
* the mutable bit from 0 to 1. We call the macro only after the string has
|
175
|
-
* been hashed. When some threads in js_ValueToStringId see that the flag is
|
176
|
-
* set, it knows that the string was atomized.
|
177
|
-
*
|
178
|
-
* On the other hand, if the thread sees that the flag is unset, it could be
|
179
|
-
* seeing a stale value when another thread has just atomized the string and
|
180
|
-
* set the flag. But this can lead only to an extra call to js_AtomizeString.
|
181
|
-
* This function would find that the string was already hashed and return it
|
182
|
-
* with the atomized bit set.
|
183
|
-
*/
|
184
|
-
#define JSFLATSTR_SET_ATOMIZED(str) \
|
185
|
-
((void)(JS_ASSERT(JSSTRING_IS_FLAT(str) && !JSSTRING_IS_MUTABLE(str)), \
|
186
|
-
(str)->length |= JSSTRFLAG_ATOMIZED))
|
187
|
-
|
188
|
-
#define JSFLATSTR_SET_MUTABLE(str) \
|
189
|
-
((void)(JS_ASSERT(JSSTRING_IS_FLAT(str) && !JSSTRING_IS_ATOMIZED(str)), \
|
190
|
-
(str)->length |= JSSTRFLAG_MUTABLE))
|
191
|
-
|
192
|
-
#define JSFLATSTR_CLEAR_MUTABLE(str) \
|
193
|
-
((void)(JS_ASSERT(JSSTRING_IS_FLAT(str)), \
|
194
|
-
JSSTRING_HAS_FLAG(str, JSSTRFLAG_MUTABLE) && \
|
195
|
-
((str)->length &= ~JSSTRFLAG_MUTABLE)))
|
196
|
-
|
197
|
-
/* Specific dependent string shift/mask accessor and mutator macros. */
|
198
|
-
#define JSSTRDEP_START_BITS (JSSTRING_LENGTH_BITS-JSSTRDEP_LENGTH_BITS)
|
199
|
-
#define JSSTRDEP_START_SHIFT JSSTRDEP_LENGTH_BITS
|
200
|
-
#define JSSTRDEP_START_MASK JSSTRING_BITMASK(JSSTRDEP_START_BITS)
|
201
|
-
#define JSSTRDEP_LENGTH_BITS (JSSTRING_LENGTH_BITS / 2)
|
202
|
-
#define JSSTRDEP_LENGTH_MASK JSSTRING_BITMASK(JSSTRDEP_LENGTH_BITS)
|
203
|
-
|
204
|
-
#define JSSTRDEP_IS_PREFIX(str) JSSTRING_HAS_FLAG(str, JSSTRFLAG_PREFIX)
|
205
|
-
|
206
|
-
#define JSSTRDEP_START(str) (JSSTRDEP_IS_PREFIX(str) ? 0 \
|
207
|
-
: (((str)->length \
|
208
|
-
>> JSSTRDEP_START_SHIFT) \
|
209
|
-
& JSSTRDEP_START_MASK))
|
210
|
-
#define JSSTRDEP_LENGTH(str) ((str)->length \
|
211
|
-
& (JSSTRDEP_IS_PREFIX(str) \
|
212
|
-
? JSSTRING_LENGTH_MASK \
|
213
|
-
: JSSTRDEP_LENGTH_MASK))
|
214
|
-
|
215
|
-
#define JSSTRDEP_INIT(str,bstr,off,len) \
|
216
|
-
((str)->length = JSSTRFLAG_DEPENDENT \
|
217
|
-
| ((off) << JSSTRDEP_START_SHIFT) \
|
218
|
-
| (len), \
|
219
|
-
(str)->u.base = (bstr))
|
220
|
-
|
221
|
-
#define JSPREFIX_INIT(str,bstr,len) \
|
222
|
-
((str)->length = JSSTRFLAG_DEPENDENT | JSSTRFLAG_PREFIX | (len), \
|
223
|
-
(str)->u.base = (bstr))
|
224
|
-
|
225
|
-
#define JSSTRDEP_BASE(str) ((str)->u.base)
|
226
|
-
#define JSPREFIX_BASE(str) JSSTRDEP_BASE(str)
|
227
|
-
#define JSPREFIX_SET_BASE(str,bstr) ((str)->u.base = (bstr))
|
228
|
-
|
229
|
-
#define JSSTRDEP_CHARS(str) \
|
230
|
-
(JSSTRING_IS_DEPENDENT(JSSTRDEP_BASE(str)) \
|
231
|
-
? js_GetDependentStringChars(str) \
|
232
|
-
: JSFLATSTR_CHARS(JSSTRDEP_BASE(str)) + JSSTRDEP_START(str))
|
233
|
-
|
234
|
-
extern size_t
|
235
|
-
js_MinimizeDependentStrings(JSString *str, int level, JSString **basep);
|
236
|
-
|
237
|
-
extern jschar *
|
238
|
-
js_GetDependentStringChars(JSString *str);
|
239
|
-
|
240
|
-
extern const jschar *
|
241
|
-
js_GetStringChars(JSContext *cx, JSString *str);
|
242
|
-
|
243
|
-
extern JSString *
|
244
|
-
js_ConcatStrings(JSContext *cx, JSString *left, JSString *right);
|
245
|
-
|
246
|
-
extern const jschar *
|
247
|
-
js_UndependString(JSContext *cx, JSString *str);
|
248
|
-
|
249
|
-
extern JSBool
|
250
|
-
js_MakeStringImmutable(JSContext *cx, JSString *str);
|
251
|
-
|
252
|
-
typedef struct JSCharBuffer {
|
253
|
-
size_t length;
|
254
|
-
jschar *chars;
|
255
|
-
} JSCharBuffer;
|
256
|
-
|
257
|
-
struct JSSubString {
|
258
|
-
size_t length;
|
259
|
-
const jschar *chars;
|
260
|
-
};
|
261
|
-
|
262
|
-
extern jschar js_empty_ucstr[];
|
263
|
-
extern JSSubString js_EmptySubString;
|
264
|
-
|
265
|
-
/* Unicode character attribute lookup tables. */
|
266
|
-
extern const uint8 js_X[];
|
267
|
-
extern const uint8 js_Y[];
|
268
|
-
extern const uint32 js_A[];
|
269
|
-
|
270
|
-
/* Enumerated Unicode general category types. */
|
271
|
-
typedef enum JSCharType {
|
272
|
-
JSCT_UNASSIGNED = 0,
|
273
|
-
JSCT_UPPERCASE_LETTER = 1,
|
274
|
-
JSCT_LOWERCASE_LETTER = 2,
|
275
|
-
JSCT_TITLECASE_LETTER = 3,
|
276
|
-
JSCT_MODIFIER_LETTER = 4,
|
277
|
-
JSCT_OTHER_LETTER = 5,
|
278
|
-
JSCT_NON_SPACING_MARK = 6,
|
279
|
-
JSCT_ENCLOSING_MARK = 7,
|
280
|
-
JSCT_COMBINING_SPACING_MARK = 8,
|
281
|
-
JSCT_DECIMAL_DIGIT_NUMBER = 9,
|
282
|
-
JSCT_LETTER_NUMBER = 10,
|
283
|
-
JSCT_OTHER_NUMBER = 11,
|
284
|
-
JSCT_SPACE_SEPARATOR = 12,
|
285
|
-
JSCT_LINE_SEPARATOR = 13,
|
286
|
-
JSCT_PARAGRAPH_SEPARATOR = 14,
|
287
|
-
JSCT_CONTROL = 15,
|
288
|
-
JSCT_FORMAT = 16,
|
289
|
-
JSCT_PRIVATE_USE = 18,
|
290
|
-
JSCT_SURROGATE = 19,
|
291
|
-
JSCT_DASH_PUNCTUATION = 20,
|
292
|
-
JSCT_START_PUNCTUATION = 21,
|
293
|
-
JSCT_END_PUNCTUATION = 22,
|
294
|
-
JSCT_CONNECTOR_PUNCTUATION = 23,
|
295
|
-
JSCT_OTHER_PUNCTUATION = 24,
|
296
|
-
JSCT_MATH_SYMBOL = 25,
|
297
|
-
JSCT_CURRENCY_SYMBOL = 26,
|
298
|
-
JSCT_MODIFIER_SYMBOL = 27,
|
299
|
-
JSCT_OTHER_SYMBOL = 28
|
300
|
-
} JSCharType;
|
301
|
-
|
302
|
-
/* Character classifying and mapping macros, based on java.lang.Character. */
|
303
|
-
#define JS_CCODE(c) (js_A[js_Y[(js_X[(uint16)(c)>>6]<<6)|((c)&0x3F)]])
|
304
|
-
#define JS_CTYPE(c) (JS_CCODE(c) & 0x1F)
|
305
|
-
|
306
|
-
#define JS_ISALPHA(c) ((((1 << JSCT_UPPERCASE_LETTER) | \
|
307
|
-
(1 << JSCT_LOWERCASE_LETTER) | \
|
308
|
-
(1 << JSCT_TITLECASE_LETTER) | \
|
309
|
-
(1 << JSCT_MODIFIER_LETTER) | \
|
310
|
-
(1 << JSCT_OTHER_LETTER)) \
|
311
|
-
>> JS_CTYPE(c)) & 1)
|
312
|
-
|
313
|
-
#define JS_ISALNUM(c) ((((1 << JSCT_UPPERCASE_LETTER) | \
|
314
|
-
(1 << JSCT_LOWERCASE_LETTER) | \
|
315
|
-
(1 << JSCT_TITLECASE_LETTER) | \
|
316
|
-
(1 << JSCT_MODIFIER_LETTER) | \
|
317
|
-
(1 << JSCT_OTHER_LETTER) | \
|
318
|
-
(1 << JSCT_DECIMAL_DIGIT_NUMBER)) \
|
319
|
-
>> JS_CTYPE(c)) & 1)
|
320
|
-
|
321
|
-
/* A unicode letter, suitable for use in an identifier. */
|
322
|
-
#define JS_ISLETTER(c) ((((1 << JSCT_UPPERCASE_LETTER) | \
|
323
|
-
(1 << JSCT_LOWERCASE_LETTER) | \
|
324
|
-
(1 << JSCT_TITLECASE_LETTER) | \
|
325
|
-
(1 << JSCT_MODIFIER_LETTER) | \
|
326
|
-
(1 << JSCT_OTHER_LETTER) | \
|
327
|
-
(1 << JSCT_LETTER_NUMBER)) \
|
328
|
-
>> JS_CTYPE(c)) & 1)
|
329
|
-
|
330
|
-
/*
|
331
|
-
* 'IdentifierPart' from ECMA grammar, is Unicode letter or combining mark or
|
332
|
-
* digit or connector punctuation.
|
333
|
-
*/
|
334
|
-
#define JS_ISIDPART(c) ((((1 << JSCT_UPPERCASE_LETTER) | \
|
335
|
-
(1 << JSCT_LOWERCASE_LETTER) | \
|
336
|
-
(1 << JSCT_TITLECASE_LETTER) | \
|
337
|
-
(1 << JSCT_MODIFIER_LETTER) | \
|
338
|
-
(1 << JSCT_OTHER_LETTER) | \
|
339
|
-
(1 << JSCT_LETTER_NUMBER) | \
|
340
|
-
(1 << JSCT_NON_SPACING_MARK) | \
|
341
|
-
(1 << JSCT_COMBINING_SPACING_MARK) | \
|
342
|
-
(1 << JSCT_DECIMAL_DIGIT_NUMBER) | \
|
343
|
-
(1 << JSCT_CONNECTOR_PUNCTUATION)) \
|
344
|
-
>> JS_CTYPE(c)) & 1)
|
345
|
-
|
346
|
-
/* Unicode control-format characters, ignored in input */
|
347
|
-
#define JS_ISFORMAT(c) (((1 << JSCT_FORMAT) >> JS_CTYPE(c)) & 1)
|
348
|
-
|
349
|
-
/*
|
350
|
-
* Per ECMA-262 15.10.2.6, these characters are the only ones that make up a
|
351
|
-
* "word", as far as a RegExp is concerned. If we want a Unicode-friendlier
|
352
|
-
* definition of "word", we should rename this macro to something regexp-y.
|
353
|
-
*/
|
354
|
-
#define JS_ISWORD(c) ((c) < 128 && (isalnum(c) || (c) == '_'))
|
355
|
-
|
356
|
-
#define JS_ISIDSTART(c) (JS_ISLETTER(c) || (c) == '_' || (c) == '$')
|
357
|
-
#define JS_ISIDENT(c) (JS_ISIDPART(c) || (c) == '_' || (c) == '$')
|
358
|
-
|
359
|
-
#define JS_ISXMLSPACE(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || \
|
360
|
-
(c) == '\n')
|
361
|
-
#define JS_ISXMLNSSTART(c) ((JS_CCODE(c) & 0x00000100) || (c) == '_')
|
362
|
-
#define JS_ISXMLNS(c) ((JS_CCODE(c) & 0x00000080) || (c) == '.' || \
|
363
|
-
(c) == '-' || (c) == '_')
|
364
|
-
#define JS_ISXMLNAMESTART(c) (JS_ISXMLNSSTART(c) || (c) == ':')
|
365
|
-
#define JS_ISXMLNAME(c) (JS_ISXMLNS(c) || (c) == ':')
|
366
|
-
|
367
|
-
#define JS_ISDIGIT(c) (JS_CTYPE(c) == JSCT_DECIMAL_DIGIT_NUMBER)
|
368
|
-
|
369
|
-
/* XXXbe unify on A/X/Y tbls, avoid ctype.h? */
|
370
|
-
/* XXXbe fs, etc. ? */
|
371
|
-
#define JS_ISSPACE(c) ((JS_CCODE(c) & 0x00070000) == 0x00040000)
|
372
|
-
#define JS_ISPRINT(c) ((c) < 128 && isprint(c))
|
373
|
-
|
374
|
-
#define JS_ISUPPER(c) (JS_CTYPE(c) == JSCT_UPPERCASE_LETTER)
|
375
|
-
#define JS_ISLOWER(c) (JS_CTYPE(c) == JSCT_LOWERCASE_LETTER)
|
376
|
-
|
377
|
-
#define JS_TOUPPER(c) ((jschar) ((JS_CCODE(c) & 0x00100000) \
|
378
|
-
? (c) - ((int32)JS_CCODE(c) >> 22) \
|
379
|
-
: (c)))
|
380
|
-
#define JS_TOLOWER(c) ((jschar) ((JS_CCODE(c) & 0x00200000) \
|
381
|
-
? (c) + ((int32)JS_CCODE(c) >> 22) \
|
382
|
-
: (c)))
|
383
|
-
|
384
|
-
/*
|
385
|
-
* Shorthands for ASCII (7-bit) decimal and hex conversion.
|
386
|
-
* Manually inline isdigit for performance; MSVC doesn't do this for us.
|
387
|
-
*/
|
388
|
-
#define JS7_ISDEC(c) ((((unsigned)(c)) - '0') <= 9)
|
389
|
-
#define JS7_UNDEC(c) ((c) - '0')
|
390
|
-
#define JS7_ISHEX(c) ((c) < 128 && isxdigit(c))
|
391
|
-
#define JS7_UNHEX(c) (uintN)(JS7_ISDEC(c) ? (c) - '0' : 10 + tolower(c) - 'a')
|
392
|
-
#define JS7_ISLET(c) ((c) < 128 && isalpha(c))
|
393
|
-
|
394
|
-
/* Initialize per-runtime string state for the first context in the runtime. */
|
395
|
-
extern JSBool
|
396
|
-
js_InitRuntimeStringState(JSContext *cx);
|
397
|
-
|
398
|
-
extern JSBool
|
399
|
-
js_InitDeflatedStringCache(JSRuntime *rt);
|
400
|
-
|
401
|
-
/*
|
402
|
-
* Maximum character code for which we will create a pinned unit string on
|
403
|
-
* demand -- see JSRuntime.unitStrings in jscntxt.h.
|
404
|
-
*/
|
405
|
-
#define UNIT_STRING_LIMIT 256U
|
406
|
-
|
407
|
-
/*
|
408
|
-
* Get the independent string containing only character code at index in str
|
409
|
-
* (backstopped with a zero character as usual for independent strings).
|
410
|
-
*/
|
411
|
-
extern JSString *
|
412
|
-
js_GetUnitString(JSContext *cx, JSString *str, size_t index);
|
413
|
-
|
414
|
-
extern void
|
415
|
-
js_FinishUnitStrings(JSRuntime *rt);
|
416
|
-
|
417
|
-
extern void
|
418
|
-
js_FinishRuntimeStringState(JSContext *cx);
|
419
|
-
|
420
|
-
extern void
|
421
|
-
js_FinishDeflatedStringCache(JSRuntime *rt);
|
422
|
-
|
423
|
-
/* Initialize the String class, returning its prototype object. */
|
424
|
-
extern JSClass js_StringClass;
|
425
|
-
|
426
|
-
extern JSObject *
|
427
|
-
js_InitStringClass(JSContext *cx, JSObject *obj);
|
428
|
-
|
429
|
-
extern const char js_escape_str[];
|
430
|
-
extern const char js_unescape_str[];
|
431
|
-
extern const char js_uneval_str[];
|
432
|
-
extern const char js_decodeURI_str[];
|
433
|
-
extern const char js_encodeURI_str[];
|
434
|
-
extern const char js_decodeURIComponent_str[];
|
435
|
-
extern const char js_encodeURIComponent_str[];
|
436
|
-
|
437
|
-
/* GC-allocate a string descriptor for the given malloc-allocated chars. */
|
438
|
-
extern JSString *
|
439
|
-
js_NewString(JSContext *cx, jschar *chars, size_t length);
|
440
|
-
|
441
|
-
extern JSString *
|
442
|
-
js_NewDependentString(JSContext *cx, JSString *base, size_t start,
|
443
|
-
size_t length);
|
444
|
-
|
445
|
-
/* Copy a counted string and GC-allocate a descriptor for it. */
|
446
|
-
extern JSString *
|
447
|
-
js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n);
|
448
|
-
|
449
|
-
/* Copy a C string and GC-allocate a descriptor for it. */
|
450
|
-
extern JSString *
|
451
|
-
js_NewStringCopyZ(JSContext *cx, const jschar *s);
|
452
|
-
|
453
|
-
/*
|
454
|
-
* Free the chars held by str when it is finalized by the GC. When type is
|
455
|
-
* less then zero, it denotes an internal string. Otherwise it denotes the
|
456
|
-
* type of the external string allocated with JS_NewExternalString.
|
457
|
-
*
|
458
|
-
* This function always needs rt but can live with null cx.
|
459
|
-
*/
|
460
|
-
extern void
|
461
|
-
js_FinalizeStringRT(JSRuntime *rt, JSString *str, intN type, JSContext *cx);
|
462
|
-
|
463
|
-
/*
|
464
|
-
* Convert a value to a printable C string.
|
465
|
-
*/
|
466
|
-
typedef JSString *(*JSValueToStringFun)(JSContext *cx, jsval v);
|
467
|
-
|
468
|
-
extern JS_FRIEND_API(const char *)
|
469
|
-
js_ValueToPrintable(JSContext *cx, jsval v, JSValueToStringFun v2sfun);
|
470
|
-
|
471
|
-
#define js_ValueToPrintableString(cx,v) \
|
472
|
-
js_ValueToPrintable(cx, v, js_ValueToString)
|
473
|
-
|
474
|
-
#define js_ValueToPrintableSource(cx,v) \
|
475
|
-
js_ValueToPrintable(cx, v, js_ValueToSource)
|
476
|
-
|
477
|
-
/*
|
478
|
-
* Convert a value to a string, returning null after reporting an error,
|
479
|
-
* otherwise returning a new string reference.
|
480
|
-
*/
|
481
|
-
extern JS_FRIEND_API(JSString *)
|
482
|
-
js_ValueToString(JSContext *cx, jsval v);
|
483
|
-
|
484
|
-
/*
|
485
|
-
* Convert a value to its source expression, returning null after reporting
|
486
|
-
* an error, otherwise returning a new string reference.
|
487
|
-
*/
|
488
|
-
extern JS_FRIEND_API(JSString *)
|
489
|
-
js_ValueToSource(JSContext *cx, jsval v);
|
490
|
-
|
491
|
-
/*
|
492
|
-
* Compute a hash function from str. The caller can call this function even if
|
493
|
-
* str is not a GC-allocated thing.
|
494
|
-
*/
|
495
|
-
extern uint32
|
496
|
-
js_HashString(JSString *str);
|
497
|
-
|
498
|
-
/*
|
499
|
-
* Test if strings are equal. The caller can call the function even if str1
|
500
|
-
* or str2 are not GC-allocated things.
|
501
|
-
*/
|
502
|
-
extern JSBool
|
503
|
-
js_EqualStrings(JSString *str1, JSString *str2);
|
504
|
-
|
505
|
-
/*
|
506
|
-
* Return less than, equal to, or greater than zero depending on whether
|
507
|
-
* str1 is less than, equal to, or greater than str2.
|
508
|
-
*/
|
509
|
-
extern intN
|
510
|
-
js_CompareStrings(JSString *str1, JSString *str2);
|
511
|
-
|
512
|
-
/*
|
513
|
-
* Boyer-Moore-Horspool superlinear search for pat:patlen in text:textlen.
|
514
|
-
* The patlen argument must be positive and no greater than BMH_PATLEN_MAX.
|
515
|
-
* The start argument tells where in text to begin the search.
|
516
|
-
*
|
517
|
-
* Return the index of pat in text, or -1 if not found.
|
518
|
-
*/
|
519
|
-
#define BMH_CHARSET_SIZE 256 /* ISO-Latin-1 */
|
520
|
-
#define BMH_PATLEN_MAX 255 /* skip table element is uint8 */
|
521
|
-
|
522
|
-
#define BMH_BAD_PATTERN (-2) /* return value if pat is not ISO-Latin-1 */
|
523
|
-
|
524
|
-
extern jsint
|
525
|
-
js_BoyerMooreHorspool(const jschar *text, jsint textlen,
|
526
|
-
const jschar *pat, jsint patlen,
|
527
|
-
jsint start);
|
528
|
-
|
529
|
-
extern size_t
|
530
|
-
js_strlen(const jschar *s);
|
531
|
-
|
532
|
-
extern jschar *
|
533
|
-
js_strchr(const jschar *s, jschar c);
|
534
|
-
|
535
|
-
extern jschar *
|
536
|
-
js_strchr_limit(const jschar *s, jschar c, const jschar *limit);
|
537
|
-
|
538
|
-
#define js_strncpy(t, s, n) memcpy((t), (s), (n) * sizeof(jschar))
|
539
|
-
|
540
|
-
/*
|
541
|
-
* Return s advanced past any Unicode white space characters.
|
542
|
-
*/
|
543
|
-
extern const jschar *
|
544
|
-
js_SkipWhiteSpace(const jschar *s, const jschar *end);
|
545
|
-
|
546
|
-
/*
|
547
|
-
* Inflate bytes to JS chars and vice versa. Report out of memory via cx
|
548
|
-
* and return null on error, otherwise return the jschar or byte vector that
|
549
|
-
* was JS_malloc'ed. length is updated with the length of the new string in jschars.
|
550
|
-
*/
|
551
|
-
extern jschar *
|
552
|
-
js_InflateString(JSContext *cx, const char *bytes, size_t *length);
|
553
|
-
|
554
|
-
extern char *
|
555
|
-
js_DeflateString(JSContext *cx, const jschar *chars, size_t length);
|
556
|
-
|
557
|
-
/*
|
558
|
-
* Inflate bytes to JS chars into a buffer. 'chars' must be large enough for
|
559
|
-
* 'length' jschars. The buffer is NOT null-terminated. The destination length
|
560
|
-
* must be be initialized with the buffer size and will contain on return the
|
561
|
-
* number of copied chars.
|
562
|
-
*/
|
563
|
-
extern JSBool
|
564
|
-
js_InflateStringToBuffer(JSContext* cx, const char *bytes, size_t length,
|
565
|
-
jschar *chars, size_t* charsLength);
|
566
|
-
|
567
|
-
/*
|
568
|
-
* Get number of bytes in the deflated sequence of characters.
|
569
|
-
*/
|
570
|
-
extern size_t
|
571
|
-
js_GetDeflatedStringLength(JSContext *cx, const jschar *chars,
|
572
|
-
size_t charsLength);
|
573
|
-
|
574
|
-
/*
|
575
|
-
* Deflate JS chars to bytes into a buffer. 'bytes' must be large enough for
|
576
|
-
* 'length chars. The buffer is NOT null-terminated. The destination length
|
577
|
-
* must to be initialized with the buffer size and will contain on return the
|
578
|
-
* number of copied bytes.
|
579
|
-
*/
|
580
|
-
extern JSBool
|
581
|
-
js_DeflateStringToBuffer(JSContext* cx, const jschar *chars,
|
582
|
-
size_t charsLength, char *bytes, size_t* length);
|
583
|
-
|
584
|
-
/*
|
585
|
-
* Associate bytes with str in the deflated string cache, returning true on
|
586
|
-
* successful association, false on out of memory.
|
587
|
-
*/
|
588
|
-
extern JSBool
|
589
|
-
js_SetStringBytes(JSContext *cx, JSString *str, char *bytes, size_t length);
|
590
|
-
|
591
|
-
/*
|
592
|
-
* Find or create a deflated string cache entry for str that contains its
|
593
|
-
* characters chopped from Unicode code points into bytes.
|
594
|
-
*/
|
595
|
-
extern const char *
|
596
|
-
js_GetStringBytes(JSContext *cx, JSString *str);
|
597
|
-
|
598
|
-
/* Remove a deflated string cache entry associated with str if any. */
|
599
|
-
extern void
|
600
|
-
js_PurgeDeflatedStringCache(JSRuntime *rt, JSString *str);
|
601
|
-
|
602
|
-
JSBool
|
603
|
-
js_str_escape(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
604
|
-
jsval *rval);
|
605
|
-
|
606
|
-
/*
|
607
|
-
* Convert one UCS-4 char and write it into a UTF-8 buffer, which must be at
|
608
|
-
* least 6 bytes long. Return the number of UTF-8 bytes of data written.
|
609
|
-
*/
|
610
|
-
extern int
|
611
|
-
js_OneUcs4ToUtf8Char(uint8 *utf8Buffer, uint32 ucs4Char);
|
612
|
-
|
613
|
-
/*
|
614
|
-
* Write str into buffer escaping any non-printable or non-ASCII character.
|
615
|
-
* Guarantees that a NUL is at the end of the buffer. Returns the length of
|
616
|
-
* the written output, NOT including the NUL. If buffer is null, just returns
|
617
|
-
* the length of the output. If quote is not 0, it must be a single or double
|
618
|
-
* quote character that will quote the output.
|
619
|
-
*
|
620
|
-
* The function is only defined for debug builds.
|
621
|
-
*/
|
622
|
-
#define js_PutEscapedString(buffer, bufferSize, str, quote) \
|
623
|
-
js_PutEscapedStringImpl(buffer, bufferSize, NULL, str, quote)
|
624
|
-
|
625
|
-
/*
|
626
|
-
* Write str into file escaping any non-printable or non-ASCII character.
|
627
|
-
* Returns the number of bytes written to file. If quote is not 0, it must
|
628
|
-
* be a single or double quote character that will quote the output.
|
629
|
-
*
|
630
|
-
* The function is only defined for debug builds.
|
631
|
-
*/
|
632
|
-
#define js_FileEscapedString(file, str, quote) \
|
633
|
-
(JS_ASSERT(file), js_PutEscapedStringImpl(NULL, 0, file, str, quote))
|
634
|
-
|
635
|
-
extern JS_FRIEND_API(size_t)
|
636
|
-
js_PutEscapedStringImpl(char *buffer, size_t bufferSize, FILE *fp,
|
637
|
-
JSString *str, uint32 quote);
|
638
|
-
|
639
|
-
JS_END_EXTERN_C
|
640
|
-
|
641
|
-
#endif /* jsstr_h___ */
|