/[jscoverage]/trunk/js/json.h
ViewVC logotype

Annotation of /trunk/js/json.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 460 - (hide annotations)
Sat Sep 26 23:15:22 2009 UTC (12 years, 9 months ago) by siliconforks
File MIME type: text/plain
File size: 3318 byte(s)
Upgrade to SpiderMonkey from Firefox 3.5.3.

1 siliconforks 332 /* ***** BEGIN LICENSE BLOCK *****
2     * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3     *
4     * The contents of this file are subject to the Mozilla Public License Version
5     * 1.1 (the "License"); you may not use this file except in compliance with
6     * the License. You may obtain a copy of the License at
7     * http://www.mozilla.org/MPL/
8     *
9     * Software distributed under the License is distributed on an "AS IS" basis,
10     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11     * for the specific language governing rights and limitations under the
12     * License.
13     *
14     * The Original Code is SpiderMonkey JSON.
15     *
16     * The Initial Developer of the Original Code is
17     * Mozilla Corporation.
18     * Portions created by the Initial Developer are Copyright (C) 1998-1999
19     * the Initial Developer. All Rights Reserved.
20     *
21     * Contributor(s):
22     * Robert Sayre <sayrer@gmail.com>
23     *
24     * Alternatively, the contents of this file may be used under the terms of
25     * either of the GNU General Public License Version 2 or later (the "GPL"),
26     * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27     * in which case the provisions of the GPL or the LGPL are applicable instead
28     * of those above. If you wish to allow use of your version of this file only
29     * under the terms of either the GPL or the LGPL, and not to allow others to
30     * use your version of this file under the terms of the MPL, indicate your
31     * decision by deleting the provisions above and replace them with the notice
32     * and other provisions required by the GPL or the LGPL. If you do not delete
33     * the provisions above, a recipient may use your version of this file under
34     * the terms of any one of the MPL, the GPL or the LGPL.
35     *
36     * ***** END LICENSE BLOCK ***** */
37    
38     #ifndef json_h___
39     #define json_h___
40     /*
41     * JS JSON functions.
42     */
43 siliconforks 460 #include "jsscan.h"
44 siliconforks 332
45     #define JSON_MAX_DEPTH 2048
46     #define JSON_PARSER_BUFSIZE 1024
47    
48     JS_BEGIN_EXTERN_C
49    
50     extern JSClass js_JSONClass;
51    
52     extern JSObject *
53     js_InitJSONClass(JSContext *cx, JSObject *obj);
54    
55     extern JSBool
56 siliconforks 460 js_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space,
57     JSONWriteCallback callback, void *data);
58 siliconforks 332
59     extern JSBool js_TryJSON(JSContext *cx, jsval *vp);
60    
61     enum JSONParserState {
62     JSON_PARSE_STATE_INIT,
63     JSON_PARSE_STATE_OBJECT_VALUE,
64     JSON_PARSE_STATE_VALUE,
65     JSON_PARSE_STATE_OBJECT,
66     JSON_PARSE_STATE_OBJECT_PAIR,
67     JSON_PARSE_STATE_OBJECT_IN_PAIR,
68     JSON_PARSE_STATE_ARRAY,
69     JSON_PARSE_STATE_STRING,
70     JSON_PARSE_STATE_STRING_ESCAPE,
71     JSON_PARSE_STATE_STRING_HEX,
72     JSON_PARSE_STATE_NUMBER,
73     JSON_PARSE_STATE_KEYWORD,
74     JSON_PARSE_STATE_FINISHED
75     };
76    
77     enum JSONDataType {
78     JSON_DATA_STRING,
79     JSON_DATA_KEYSTRING,
80     JSON_DATA_NUMBER,
81     JSON_DATA_KEYWORD
82     };
83    
84     struct JSONParser {
85     /* Used while handling \uNNNN in strings */
86     jschar hexChar;
87     uint8 numHex;
88    
89     JSONParserState *statep;
90     JSONParserState stateStack[JSON_MAX_DEPTH];
91     jsval *rootVal;
92 siliconforks 460 JSStringBuffer objectKey;
93     JSStringBuffer buffer;
94 siliconforks 332 JSObject *objectStack;
95     };
96    
97     extern JSONParser *
98     js_BeginJSONParse(JSContext *cx, jsval *rootVal);
99    
100     extern JSBool
101     js_ConsumeJSONText(JSContext *cx, JSONParser *jp, const jschar *data, uint32 len);
102    
103     extern JSBool
104 siliconforks 460 js_FinishJSONParse(JSContext *cx, JSONParser *jp, jsval reviver);
105 siliconforks 332
106     JS_END_EXTERN_C
107    
108     #endif /* json_h___ */

  ViewVC Help
Powered by ViewVC 1.1.24