brianmario-yajl-ruby 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/CHANGELOG.rdoc +10 -0
  2. data/README.rdoc +25 -23
  3. data/Rakefile +11 -1
  4. data/VERSION.yml +2 -2
  5. data/benchmark/encode.rb +1 -1
  6. data/benchmark/encode_json_and_marshal.rb +1 -1
  7. data/benchmark/encode_json_and_yaml.rb +1 -1
  8. data/benchmark/parse.rb +1 -1
  9. data/benchmark/parse_json_and_marshal.rb +1 -1
  10. data/benchmark/parse_json_and_yaml.rb +1 -1
  11. data/benchmark/subjects/unicode.json +1 -3315
  12. data/ext/api/yajl_common.h +85 -0
  13. data/ext/api/yajl_gen.h +123 -0
  14. data/ext/api/yajl_parse.h +179 -0
  15. data/ext/extconf.rb +2 -8
  16. data/ext/yajl.c +128 -260
  17. data/ext/yajl_alloc.c +65 -0
  18. data/ext/yajl_alloc.h +50 -0
  19. data/ext/yajl_buf.c +119 -0
  20. data/ext/yajl_buf.h +73 -0
  21. data/ext/yajl_bytestack.h +85 -0
  22. data/ext/yajl_encode.c +179 -0
  23. data/ext/yajl_encode.h +44 -0
  24. data/ext/yajl_ext.c +283 -0
  25. data/ext/{yajl.h → yajl_ext.h} +2 -2
  26. data/ext/yajl_gen.c +295 -0
  27. data/ext/yajl_lex.c +737 -0
  28. data/ext/yajl_lex.h +133 -0
  29. data/ext/yajl_parser.c +445 -0
  30. data/ext/yajl_parser.h +79 -0
  31. data/lib/yajl/bzip2.rb +1 -1
  32. data/lib/yajl/deflate.rb +1 -1
  33. data/lib/yajl/gzip.rb +1 -1
  34. data/lib/yajl/http_stream.rb +1 -1
  35. data/lib/yajl.rb +1 -1
  36. data/spec/encoding/encoding_spec.rb +23 -0
  37. data/spec/http/{http.bzip2.dump → fixtures/http.bzip2.dump} +0 -0
  38. data/spec/http/{http.deflate.dump → fixtures/http.deflate.dump} +0 -0
  39. data/spec/http/{http.gzip.dump → fixtures/http.gzip.dump} +0 -0
  40. data/spec/http/{http.raw.dump → fixtures/http.raw.dump} +0 -0
  41. data/spec/http/http_spec.rb +98 -0
  42. data/spec/{active_support_spec.rb → parsing/active_support_spec.rb} +1 -1
  43. data/spec/{fixtures → parsing/fixtures}/fail.15.json +0 -0
  44. data/spec/{fixtures → parsing/fixtures}/fail.16.json +0 -0
  45. data/spec/{fixtures → parsing/fixtures}/fail.17.json +0 -0
  46. data/spec/{fixtures → parsing/fixtures}/fail.26.json +0 -0
  47. data/spec/{fixtures → parsing/fixtures}/fail11.json +0 -0
  48. data/spec/{fixtures → parsing/fixtures}/fail12.json +0 -0
  49. data/spec/{fixtures → parsing/fixtures}/fail13.json +0 -0
  50. data/spec/{fixtures → parsing/fixtures}/fail14.json +0 -0
  51. data/spec/{fixtures → parsing/fixtures}/fail19.json +0 -0
  52. data/spec/{fixtures → parsing/fixtures}/fail20.json +0 -0
  53. data/spec/{fixtures → parsing/fixtures}/fail21.json +0 -0
  54. data/spec/{fixtures → parsing/fixtures}/fail22.json +0 -0
  55. data/spec/{fixtures → parsing/fixtures}/fail23.json +0 -0
  56. data/spec/{fixtures → parsing/fixtures}/fail24.json +0 -0
  57. data/spec/{fixtures → parsing/fixtures}/fail25.json +0 -0
  58. data/spec/{fixtures → parsing/fixtures}/fail27.json +0 -0
  59. data/spec/{fixtures → parsing/fixtures}/fail28.json +0 -0
  60. data/spec/{fixtures → parsing/fixtures}/fail3.json +0 -0
  61. data/spec/{fixtures → parsing/fixtures}/fail4.json +0 -0
  62. data/spec/{fixtures → parsing/fixtures}/fail5.json +0 -0
  63. data/spec/{fixtures → parsing/fixtures}/fail6.json +0 -0
  64. data/spec/{fixtures → parsing/fixtures}/fail9.json +0 -0
  65. data/spec/{fixtures → parsing/fixtures}/pass.array.json +0 -0
  66. data/spec/{fixtures → parsing/fixtures}/pass.codepoints_from_unicode_org.json +0 -0
  67. data/spec/{fixtures → parsing/fixtures}/pass.contacts.json +0 -0
  68. data/spec/{fixtures → parsing/fixtures}/pass.db100.xml.json +0 -0
  69. data/spec/{fixtures → parsing/fixtures}/pass.db1000.xml.json +0 -0
  70. data/spec/{fixtures → parsing/fixtures}/pass.dc_simple_with_comments.json +0 -0
  71. data/spec/{fixtures → parsing/fixtures}/pass.deep_arrays.json +0 -0
  72. data/spec/{fixtures → parsing/fixtures}/pass.difficult_json_c_test_case.json +0 -0
  73. data/spec/{fixtures → parsing/fixtures}/pass.difficult_json_c_test_case_with_comments.json +0 -0
  74. data/spec/{fixtures → parsing/fixtures}/pass.doubles.json +0 -0
  75. data/spec/{fixtures → parsing/fixtures}/pass.empty_array.json +0 -0
  76. data/spec/{fixtures → parsing/fixtures}/pass.empty_string.json +0 -0
  77. data/spec/{fixtures → parsing/fixtures}/pass.escaped_bulgarian.json +0 -0
  78. data/spec/{fixtures → parsing/fixtures}/pass.escaped_foobar.json +0 -0
  79. data/spec/{fixtures → parsing/fixtures}/pass.item.json +0 -0
  80. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample1.json +0 -0
  81. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample2.json +0 -0
  82. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample3.json +0 -0
  83. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample4-nows.json +0 -0
  84. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample4.json +0 -0
  85. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample5.json +0 -0
  86. data/spec/{fixtures → parsing/fixtures}/pass.map-spain.xml.json +0 -0
  87. data/spec/{fixtures → parsing/fixtures}/pass.ns-invoice100.xml.json +0 -0
  88. data/spec/{fixtures → parsing/fixtures}/pass.ns-soap.xml.json +0 -0
  89. data/spec/{fixtures → parsing/fixtures}/pass.numbers-fp-4k.json +0 -0
  90. data/spec/{fixtures → parsing/fixtures}/pass.numbers-fp-64k.json +0 -0
  91. data/spec/{fixtures → parsing/fixtures}/pass.numbers-int-4k.json +0 -0
  92. data/spec/{fixtures → parsing/fixtures}/pass.numbers-int-64k.json +0 -0
  93. data/spec/{fixtures → parsing/fixtures}/pass.twitter-search.json +0 -0
  94. data/spec/{fixtures → parsing/fixtures}/pass.twitter-search2.json +0 -0
  95. data/spec/{fixtures → parsing/fixtures}/pass.unicode.json +0 -0
  96. data/spec/{fixtures → parsing/fixtures}/pass.yelp.json +0 -0
  97. data/spec/{fixtures → parsing/fixtures}/pass1.json +0 -0
  98. data/spec/{fixtures → parsing/fixtures}/pass2.json +0 -0
  99. data/spec/{fixtures → parsing/fixtures}/pass3.json +0 -0
  100. data/spec/{fixtures_spec.rb → parsing/fixtures_spec.rb} +1 -1
  101. data/spec/{one_off_spec.rb → parsing/one_off_spec.rb} +1 -1
  102. data/yajl-ruby.gemspec +91 -72
  103. metadata +91 -71
  104. data/benchmark/subjects/yelp.json +0 -1
@@ -0,0 +1,85 @@
1
+ /*
2
+ * Copyright 2007-2009, Lloyd Hilaiel.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are
6
+ * met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in
13
+ * the documentation and/or other materials provided with the
14
+ * distribution.
15
+ *
16
+ * 3. Neither the name of Lloyd Hilaiel nor the names of its
17
+ * contributors may be used to endorse or promote products derived
18
+ * from this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ * POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ #ifndef __YAJL_COMMON_H__
34
+ #define __YAJL_COMMON_H__
35
+
36
+ #ifdef __cplusplus
37
+ extern "C" {
38
+ #endif
39
+
40
+ #define YAJL_MAX_DEPTH 128
41
+
42
+ /* msft dll export gunk. To build a DLL on windows, you
43
+ * must define WIN32, YAJL_SHARED, and YAJL_BUILD. To use a shared
44
+ * DLL, you must define YAJL_SHARED and WIN32 */
45
+ #if defined(WIN32) && defined(YAJL_SHARED)
46
+ # ifdef YAJL_BUILD
47
+ # define YAJL_API __declspec(dllexport)
48
+ # else
49
+ # define YAJL_API __declspec(dllimport)
50
+ # endif
51
+ #else
52
+ # define YAJL_API
53
+ #endif
54
+
55
+ /** pointer to a malloc function, supporting client overriding memory
56
+ * allocation routines */
57
+ typedef void * (*yajl_malloc_func)(void *ctx, unsigned int sz);
58
+
59
+ /** pointer to a free function, supporting client overriding memory
60
+ * allocation routines */
61
+ typedef void (*yajl_free_func)(void *ctx, void * ptr);
62
+
63
+ /** pointer to a realloc function which can resize an allocation. */
64
+ typedef void * (*yajl_realloc_func)(void *ctx, void * ptr, unsigned int sz);
65
+
66
+ /** A structure which can be passed to yajl_*_alloc routines to allow the
67
+ * client to specify memory allocation functions to be used. */
68
+ typedef struct
69
+ {
70
+ /** pointer to a function that can allocate uninitialized memory */
71
+ yajl_malloc_func malloc;
72
+ /** pointer to a function that can resize memory allocations */
73
+ yajl_realloc_func realloc;
74
+ /** pointer to a function that can free memory allocated using
75
+ * reallocFunction or mallocFunction */
76
+ yajl_free_func free;
77
+ /** a context pointer that will be passed to above allocation routines */
78
+ void * ctx;
79
+ } yajl_alloc_funcs;
80
+
81
+ #ifdef __cplusplus
82
+ }
83
+ #endif
84
+
85
+ #endif
@@ -0,0 +1,123 @@
1
+ /*
2
+ * Copyright 2007-2009, Lloyd Hilaiel.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are
6
+ * met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in
13
+ * the documentation and/or other materials provided with the
14
+ * distribution.
15
+ *
16
+ * 3. Neither the name of Lloyd Hilaiel nor the names of its
17
+ * contributors may be used to endorse or promote products derived
18
+ * from this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ * POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ /**
34
+ * \file yajl_gen.h
35
+ * Interface to YAJL's JSON generation facilities.
36
+ */
37
+
38
+ #include <yajl/yajl_common.h>
39
+
40
+ #ifndef __YAJL_GEN_H__
41
+ #define __YAJL_GEN_H__
42
+
43
+ #ifdef __cplusplus
44
+ extern "C" {
45
+ #endif
46
+ /** generator status codes */
47
+ typedef enum {
48
+ /** no error */
49
+ yajl_gen_status_ok = 0,
50
+ /** at a point where a map key is generated, a function other than
51
+ * yajl_gen_string was called */
52
+ yajl_gen_keys_must_be_strings,
53
+ /** YAJL's maximum generation depth was exceeded. see
54
+ * YAJL_MAX_DEPTH */
55
+ yajl_max_depth_exceeded,
56
+ /** A generator function (yajl_gen_XXX) was called while in an error
57
+ * state */
58
+ yajl_gen_in_error_state,
59
+ /** A complete JSON document has been generated */
60
+ yajl_gen_generation_complete
61
+ } yajl_gen_status;
62
+
63
+ /** an opaque handle to a generator */
64
+ typedef struct yajl_gen_t * yajl_gen;
65
+
66
+ /** configuration structure for the generator */
67
+ typedef struct {
68
+ /** generate indented (beautiful) output */
69
+ unsigned int beautify;
70
+ /** an opportunity to define an indent string. such as \\t or
71
+ * some number of spaces. default is four spaces ' '. This
72
+ * member is only relevant when beautify is true */
73
+ const char * indentString;
74
+ } yajl_gen_config;
75
+
76
+ /** allocate a generator handle
77
+ * \param config a pointer to a structure containing parameters which
78
+ * configure the behavior of the json generator
79
+ * \param allocFuncs an optional pointer to a structure which allows
80
+ * the client to overide the memory allocation
81
+ * used by yajl. May be NULL, in which case
82
+ * malloc/free/realloc will be used.
83
+ *
84
+ * \returns an allocated handle on success, NULL on failure (bad params)
85
+ */
86
+ yajl_gen YAJL_API yajl_gen_alloc(const yajl_gen_config * config,
87
+ const yajl_alloc_funcs * allocFuncs);
88
+
89
+ /** free a generator handle */
90
+ void YAJL_API yajl_gen_free(yajl_gen handle);
91
+
92
+ yajl_gen_status YAJL_API yajl_gen_integer(yajl_gen hand, long int number);
93
+ yajl_gen_status YAJL_API yajl_gen_double(yajl_gen hand, double number);
94
+ yajl_gen_status YAJL_API yajl_gen_number(yajl_gen hand,
95
+ const char * num,
96
+ unsigned int len);
97
+ yajl_gen_status YAJL_API yajl_gen_string(yajl_gen hand,
98
+ const unsigned char * str,
99
+ unsigned int len);
100
+ yajl_gen_status YAJL_API yajl_gen_null(yajl_gen hand);
101
+ yajl_gen_status YAJL_API yajl_gen_bool(yajl_gen hand, int boolean);
102
+ yajl_gen_status YAJL_API yajl_gen_map_open(yajl_gen hand);
103
+ yajl_gen_status YAJL_API yajl_gen_map_close(yajl_gen hand);
104
+ yajl_gen_status YAJL_API yajl_gen_array_open(yajl_gen hand);
105
+ yajl_gen_status YAJL_API yajl_gen_array_close(yajl_gen hand);
106
+
107
+ /** access the null terminated generator buffer. If incrementally
108
+ * outputing JSON, one should call yajl_gen_clear to clear the
109
+ * buffer. This allows stream generation. */
110
+ yajl_gen_status YAJL_API yajl_gen_get_buf(yajl_gen hand,
111
+ const unsigned char ** buf,
112
+ unsigned int * len);
113
+
114
+ /** clear yajl's output buffer, but maintain all internal generation
115
+ * state. This function will not "reset" the generator state, and is
116
+ * intended to enable incremental JSON outputing. */
117
+ void YAJL_API yajl_gen_clear(yajl_gen hand);
118
+
119
+ #ifdef __cplusplus
120
+ }
121
+ #endif
122
+
123
+ #endif
@@ -0,0 +1,179 @@
1
+ /*
2
+ * Copyright 2007-2009, Lloyd Hilaiel.
3
+ *
4
+ * Redistribution and use in source and binary forms, with or without
5
+ * modification, are permitted provided that the following conditions are
6
+ * met:
7
+ *
8
+ * 1. Redistributions of source code must retain the above copyright
9
+ * notice, this list of conditions and the following disclaimer.
10
+ *
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in
13
+ * the documentation and/or other materials provided with the
14
+ * distribution.
15
+ *
16
+ * 3. Neither the name of Lloyd Hilaiel nor the names of its
17
+ * contributors may be used to endorse or promote products derived
18
+ * from this software without specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
24
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29
+ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ * POSSIBILITY OF SUCH DAMAGE.
31
+ */
32
+
33
+ /**
34
+ * \file yajl_parse.h
35
+ * Interface to YAJL's JSON parsing facilities.
36
+ */
37
+
38
+ #include <yajl/yajl_common.h>
39
+
40
+ #ifndef __YAJL_PARSE_H__
41
+ #define __YAJL_PARSE_H__
42
+
43
+ #ifdef __cplusplus
44
+ extern "C" {
45
+ #endif
46
+ /** error codes returned from this interface */
47
+ typedef enum {
48
+ /** no error was encountered */
49
+ yajl_status_ok,
50
+ /** a client callback returned zero, stopping the parse */
51
+ yajl_status_client_canceled,
52
+ /** The parse cannot yet complete because more json input text
53
+ * is required, call yajl_parse with the next buffer of input text.
54
+ * (pertinent only when stream parsing) */
55
+ yajl_status_insufficient_data,
56
+ /** An error occured during the parse. Call yajl_get_error for
57
+ * more information about the encountered error */
58
+ yajl_status_error
59
+ } yajl_status;
60
+
61
+ /** attain a human readable, english, string for an error */
62
+ const char * YAJL_API yajl_status_to_string(yajl_status code);
63
+
64
+ /** an opaque handle to a parser */
65
+ typedef struct yajl_handle_t * yajl_handle;
66
+
67
+ /** yajl is an event driven parser. this means as json elements are
68
+ * parsed, you are called back to do something with the data. The
69
+ * functions in this table indicate the various events for which
70
+ * you will be called back. Each callback accepts a "context"
71
+ * pointer, this is a void * that is passed into the yajl_parse
72
+ * function which the client code may use to pass around context.
73
+ *
74
+ * All callbacks return an integer. If non-zero, the parse will
75
+ * continue. If zero, the parse will be canceled and
76
+ * yajl_status_client_canceled will be returned from the parse.
77
+ *
78
+ * Note about handling of numbers:
79
+ * yajl will only convert numbers that can be represented in a double
80
+ * or a long int. All other numbers will be passed to the client
81
+ * in string form using the yajl_number callback. Furthermore, if
82
+ * yajl_number is not NULL, it will always be used to return numbers,
83
+ * that is yajl_integer and yajl_double will be ignored. If
84
+ * yajl_number is NULL but one of yajl_integer or yajl_double are
85
+ * defined, parsing of a number larger than is representable
86
+ * in a double or long int will result in a parse error.
87
+ */
88
+ typedef struct {
89
+ int (* yajl_null)(void * ctx);
90
+ int (* yajl_boolean)(void * ctx, int boolVal);
91
+ int (* yajl_integer)(void * ctx, long integerVal);
92
+ int (* yajl_double)(void * ctx, double doubleVal);
93
+ /** A callback which passes the string representation of the number
94
+ * back to the client. Will be used for all numbers when present */
95
+ int (* yajl_number)(void * ctx, const char * numberVal,
96
+ unsigned int numberLen);
97
+
98
+ /** strings are returned as pointers into the JSON text when,
99
+ * possible, as a result, they are _not_ null padded */
100
+ int (* yajl_string)(void * ctx, const unsigned char * stringVal,
101
+ unsigned int stringLen);
102
+
103
+ int (* yajl_start_map)(void * ctx);
104
+ int (* yajl_map_key)(void * ctx, const unsigned char * key,
105
+ unsigned int stringLen);
106
+ int (* yajl_end_map)(void * ctx);
107
+
108
+ int (* yajl_start_array)(void * ctx);
109
+ int (* yajl_end_array)(void * ctx);
110
+ } yajl_callbacks;
111
+
112
+ /** configuration structure for the generator */
113
+ typedef struct {
114
+ /** if nonzero, javascript style comments will be allowed in
115
+ * the json input, both slash star and slash slash */
116
+ unsigned int allowComments;
117
+ /** if nonzero, invalid UTF8 strings will cause a parse
118
+ * error */
119
+ unsigned int checkUTF8;
120
+ } yajl_parser_config;
121
+
122
+ /** allocate a parser handle
123
+ * \param callbacks a yajl callbacks structure specifying the
124
+ * functions to call when different JSON entities
125
+ * are encountered in the input text. May be NULL,
126
+ * which is only useful for validation.
127
+ * \param config configuration parameters for the parse.
128
+ * \param ctx a context pointer that will be passed to callbacks.
129
+ */
130
+ yajl_handle YAJL_API yajl_alloc(const yajl_callbacks * callbacks,
131
+ const yajl_parser_config * config,
132
+ const yajl_alloc_funcs * allocFuncs,
133
+ void * ctx);
134
+
135
+ /** free a parser handle */
136
+ void YAJL_API yajl_free(yajl_handle handle);
137
+
138
+ /** Parse some json!
139
+ * \param hand - a handle to the json parser allocated with yajl_alloc
140
+ * \param jsonText - a pointer to the UTF8 json text to be parsed
141
+ * \param jsonTextLength - the length, in bytes, of input text
142
+ */
143
+ yajl_status YAJL_API yajl_parse(yajl_handle hand,
144
+ const unsigned char * jsonText,
145
+ unsigned int jsonTextLength);
146
+
147
+ /** Parse any remaining buffered json.
148
+ * Since yajl is a stream-based parser, without an explicit end of
149
+ * input, yajl sometimes can't decide if content at the end of the
150
+ * stream is valid or not. For example, if "1" has been fed in,
151
+ * yajl can't know whether another digit is next or some character
152
+ * that would terminate the integer token.
153
+ *
154
+ * \param hand - a handle to the json parser allocated with yajl_alloc
155
+ */
156
+ yajl_status yajl_parse_complete(yajl_handle hand);
157
+
158
+ /** get an error string describing the state of the
159
+ * parse.
160
+ *
161
+ * If verbose is non-zero, the message will include the JSON
162
+ * text where the error occured, along with an arrow pointing to
163
+ * the specific char.
164
+ *
165
+ * A dynamically allocated string will be returned which should
166
+ * be freed with yajl_free_error
167
+ */
168
+ unsigned char * YAJL_API yajl_get_error(yajl_handle hand, int verbose,
169
+ const unsigned char * jsonText,
170
+ unsigned int jsonTextLength);
171
+
172
+ /** free an error returned from yajl_get_error */
173
+ void YAJL_API yajl_free_error(yajl_handle hand, unsigned char * str);
174
+
175
+ #ifdef __cplusplus
176
+ }
177
+ #endif
178
+
179
+ #endif
data/ext/extconf.rb CHANGED
@@ -2,12 +2,6 @@
2
2
  require 'mkmf'
3
3
  require 'rbconfig'
4
4
 
5
- dir_config('yajl')
6
- have_header('yajl/yajl_parse.h')
7
- have_header('yajl/yajl_gen.h')
5
+ # $CFLAGS << ' -Wall'
8
6
 
9
- if have_library("yajl")
10
- create_makefile("yajl_ext")
11
- else
12
- puts "Yajl not found, maybe try manually specifying --with-yajl-dir to find it?"
13
- end
7
+ create_makefile("yajl_ext")