PageRenderTime 64ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/expresso/deps/jscoverage/js/json.h

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
C++ Header | 107 lines | 51 code | 16 blank | 40 comment | 0 complexity | 1a8989427c2a4101c2f61f7af21d1989 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  1. /* ***** 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. #ifndef json_h___
  38. #define json_h___
  39. /*
  40. * JS JSON functions.
  41. */
  42. #define JSON_MAX_DEPTH 2048
  43. #define JSON_PARSER_BUFSIZE 1024
  44. JS_BEGIN_EXTERN_C
  45. extern JSClass js_JSONClass;
  46. extern JSObject *
  47. js_InitJSONClass(JSContext *cx, JSObject *obj);
  48. extern JSBool
  49. js_Stringify(JSContext *cx, jsval *vp, JSObject *replacer,
  50. JSONWriteCallback callback, void *data, uint32 depth);
  51. extern JSBool js_TryJSON(JSContext *cx, jsval *vp);
  52. enum JSONParserState {
  53. JSON_PARSE_STATE_INIT,
  54. JSON_PARSE_STATE_OBJECT_VALUE,
  55. JSON_PARSE_STATE_VALUE,
  56. JSON_PARSE_STATE_OBJECT,
  57. JSON_PARSE_STATE_OBJECT_PAIR,
  58. JSON_PARSE_STATE_OBJECT_IN_PAIR,
  59. JSON_PARSE_STATE_ARRAY,
  60. JSON_PARSE_STATE_STRING,
  61. JSON_PARSE_STATE_STRING_ESCAPE,
  62. JSON_PARSE_STATE_STRING_HEX,
  63. JSON_PARSE_STATE_NUMBER,
  64. JSON_PARSE_STATE_KEYWORD,
  65. JSON_PARSE_STATE_FINISHED
  66. };
  67. enum JSONDataType {
  68. JSON_DATA_STRING,
  69. JSON_DATA_KEYSTRING,
  70. JSON_DATA_NUMBER,
  71. JSON_DATA_KEYWORD
  72. };
  73. struct JSONParser {
  74. /* Used while handling \uNNNN in strings */
  75. jschar hexChar;
  76. uint8 numHex;
  77. JSONParserState *statep;
  78. JSONParserState stateStack[JSON_MAX_DEPTH];
  79. jsval *rootVal;
  80. JSStringBuffer *objectKey;
  81. JSStringBuffer *buffer;
  82. JSObject *objectStack;
  83. };
  84. extern JSONParser *
  85. js_BeginJSONParse(JSContext *cx, jsval *rootVal);
  86. extern JSBool
  87. js_ConsumeJSONText(JSContext *cx, JSONParser *jp, const jschar *data, uint32 len);
  88. extern JSBool
  89. js_FinishJSONParse(JSContext *cx, JSONParser *jp);
  90. JS_END_EXTERN_C
  91. #endif /* json_h___ */