oj 3.15.0 → 3.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +29 -0
 - data/ext/oj/cache.c +4 -2
 - data/ext/oj/cache.h +3 -2
 - data/ext/oj/code.c +3 -10
 - data/ext/oj/compat.c +5 -18
 - data/ext/oj/custom.c +5 -13
 - data/ext/oj/dump.c +30 -22
 - data/ext/oj/dump.h +1 -4
 - data/ext/oj/dump_compat.c +16 -16
 - data/ext/oj/extconf.rb +4 -2
 - data/ext/oj/fast.c +10 -12
 - data/ext/oj/intern.c +23 -6
 - data/ext/oj/mimic_json.c +3 -6
 - data/ext/oj/object.c +13 -5
 - data/ext/oj/oj.c +155 -132
 - data/ext/oj/oj.h +26 -33
 - data/ext/oj/parse.c +7 -5
 - data/ext/oj/parse.h +16 -14
 - data/ext/oj/parser.c +61 -50
 - data/ext/oj/parser.h +2 -2
 - data/ext/oj/rails.c +23 -7
 - data/ext/oj/reader.c +1 -3
 - data/ext/oj/saj.c +1 -1
 - data/ext/oj/stream_writer.c +35 -15
 - data/ext/oj/string_writer.c +50 -17
 - data/ext/oj/usual.c +20 -0
 - data/ext/oj/usual.h +1 -0
 - data/ext/oj/val_stack.c +13 -2
 - data/lib/oj/active_support_helper.rb +2 -3
 - data/lib/oj/json.rb +159 -149
 - data/lib/oj/mimic.rb +3 -1
 - data/lib/oj/version.rb +1 -1
 - data/test/foo.rb +3 -4
 - data/test/json_gem/json_common_interface_test.rb +4 -2
 - data/test/json_gem/json_generator_test.rb +7 -1
 - data/test/perf_dump.rb +3 -3
 - data/test/prec.rb +4 -4
 - data/test/test_compat.rb +19 -1
 - data/test/test_custom.rb +2 -1
 - data/test/test_object.rb +14 -0
 - data/test/test_parser_debug.rb +1 -1
 - data/test/test_parser_usual.rb +10 -0
 - data/test/test_strict.rb +10 -0
 - data/test/test_various.rb +6 -0
 - metadata +17 -3
 
    
        data/ext/oj/parse.h
    CHANGED
    
    | 
         @@ -16,22 +16,24 @@ 
     | 
|
| 
       16 
16 
     | 
    
         
             
            #include "val_stack.h"
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
            struct _rxClass;
         
     | 
| 
      
 19 
     | 
    
         
            +
            struct _parseInfo;
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
            typedef struct _numInfo {
         
     | 
| 
       21 
     | 
    
         
            -
                int64_t 
     | 
| 
       22 
     | 
    
         
            -
                int64_t 
     | 
| 
       23 
     | 
    
         
            -
                int64_t 
     | 
| 
       24 
     | 
    
         
            -
                int64_t 
     | 
| 
       25 
     | 
    
         
            -
                const char 
     | 
| 
       26 
     | 
    
         
            -
                size_t 
     | 
| 
       27 
     | 
    
         
            -
                long 
     | 
| 
       28 
     | 
    
         
            -
                 
     | 
| 
       29 
     | 
    
         
            -
                int 
     | 
| 
       30 
     | 
    
         
            -
                int 
     | 
| 
       31 
     | 
    
         
            -
                int 
     | 
| 
       32 
     | 
    
         
            -
                int 
     | 
| 
       33 
     | 
    
         
            -
                int 
     | 
| 
       34 
     | 
    
         
            -
                int 
     | 
| 
      
 22 
     | 
    
         
            +
                int64_t            i;
         
     | 
| 
      
 23 
     | 
    
         
            +
                int64_t            num;
         
     | 
| 
      
 24 
     | 
    
         
            +
                int64_t            div;
         
     | 
| 
      
 25 
     | 
    
         
            +
                int64_t            di;
         
     | 
| 
      
 26 
     | 
    
         
            +
                const char        *str;
         
     | 
| 
      
 27 
     | 
    
         
            +
                size_t             len;
         
     | 
| 
      
 28 
     | 
    
         
            +
                long               exp;
         
     | 
| 
      
 29 
     | 
    
         
            +
                struct _parseInfo *pi;
         
     | 
| 
      
 30 
     | 
    
         
            +
                int                big;
         
     | 
| 
      
 31 
     | 
    
         
            +
                int                infinity;
         
     | 
| 
      
 32 
     | 
    
         
            +
                int                nan;
         
     | 
| 
      
 33 
     | 
    
         
            +
                int                neg;
         
     | 
| 
      
 34 
     | 
    
         
            +
                int                has_exp;
         
     | 
| 
      
 35 
     | 
    
         
            +
                int                no_big;
         
     | 
| 
      
 36 
     | 
    
         
            +
                int                bigdec_load;
         
     | 
| 
       35 
37 
     | 
    
         
             
            } *NumInfo;
         
     | 
| 
       36 
38 
     | 
    
         | 
| 
       37 
39 
     | 
    
         
             
            typedef struct _parseInfo {
         
     | 
    
        data/ext/oj/parser.c
    CHANGED
    
    | 
         @@ -1164,6 +1164,17 @@ static void parser_mark(void *ptr) { 
     | 
|
| 
       1164 
1164 
     | 
    
         
             
                }
         
     | 
| 
       1165 
1165 
     | 
    
         
             
            }
         
     | 
| 
       1166 
1166 
     | 
    
         | 
| 
      
 1167 
     | 
    
         
            +
            static const rb_data_type_t oj_parser_type = {
         
     | 
| 
      
 1168 
     | 
    
         
            +
                "Oj/parser",
         
     | 
| 
      
 1169 
     | 
    
         
            +
                {
         
     | 
| 
      
 1170 
     | 
    
         
            +
                    parser_mark,
         
     | 
| 
      
 1171 
     | 
    
         
            +
                    parser_free,
         
     | 
| 
      
 1172 
     | 
    
         
            +
                    NULL,
         
     | 
| 
      
 1173 
     | 
    
         
            +
                },
         
     | 
| 
      
 1174 
     | 
    
         
            +
                0,
         
     | 
| 
      
 1175 
     | 
    
         
            +
                0,
         
     | 
| 
      
 1176 
     | 
    
         
            +
            };
         
     | 
| 
      
 1177 
     | 
    
         
            +
             
     | 
| 
       1167 
1178 
     | 
    
         
             
            extern void oj_set_parser_validator(ojParser p);
         
     | 
| 
       1168 
1179 
     | 
    
         
             
            extern void oj_set_parser_saj(ojParser p);
         
     | 
| 
       1169 
1180 
     | 
    
         
             
            extern void oj_set_parser_usual(ojParser p);
         
     | 
| 
         @@ -1255,7 +1266,7 @@ static VALUE parser_new(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       1255 
1266 
     | 
    
         
             
                        rb_hash_foreach(ropts, opt_cb, (VALUE)p);
         
     | 
| 
       1256 
1267 
     | 
    
         
             
                    }
         
     | 
| 
       1257 
1268 
     | 
    
         
             
                }
         
     | 
| 
       1258 
     | 
    
         
            -
                return  
     | 
| 
      
 1269 
     | 
    
         
            +
                return TypedData_Wrap_Struct(parser_class, &oj_parser_type, p);
         
     | 
| 
       1259 
1270 
     | 
    
         
             
            }
         
     | 
| 
       1260 
1271 
     | 
    
         | 
| 
       1261 
1272 
     | 
    
         
             
            // Create a new parser without setting the delegate. The parser is
         
     | 
| 
         @@ -1275,7 +1286,7 @@ VALUE oj_parser_new(void) { 
     | 
|
| 
       1275 
1286 
     | 
    
         
             
                buf_init(&p->buf);
         
     | 
| 
       1276 
1287 
     | 
    
         
             
                p->map = value_map;
         
     | 
| 
       1277 
1288 
     | 
    
         | 
| 
       1278 
     | 
    
         
            -
                return  
     | 
| 
      
 1289 
     | 
    
         
            +
                return TypedData_Wrap_Struct(parser_class, &oj_parser_type, p);
         
     | 
| 
       1279 
1290 
     | 
    
         
             
            }
         
     | 
| 
       1280 
1291 
     | 
    
         | 
| 
       1281 
1292 
     | 
    
         
             
            // Set set the options from a hash (ropts).
         
     | 
| 
         @@ -1294,53 +1305,41 @@ void oj_parser_set_option(ojParser p, VALUE ropts) { 
     | 
|
| 
       1294 
1305 
     | 
    
         
             
             *   - no options
         
     | 
| 
       1295 
1306 
     | 
    
         
             
             *
         
     | 
| 
       1296 
1307 
     | 
    
         
             
             * - *:saj*
         
     | 
| 
       1297 
     | 
    
         
            -
             *   -  
     | 
| 
       1298 
     | 
    
         
            -
             *   -  
     | 
| 
       1299 
     | 
    
         
            -
             *   -  
     | 
| 
       1300 
     | 
    
         
            -
             * that length are cached.
         
     | 
| 
       1301 
     | 
    
         
            -
             *   - _cache_strings_ returns the value of the _cache_strings_ integer value.
         
     | 
| 
       1302 
     | 
    
         
            -
             *   - _handler=_ sets the SAJ handler
         
     | 
| 
       1303 
     | 
    
         
            -
             *   - _handler_ returns the SAJ handler
         
     | 
| 
      
 1308 
     | 
    
         
            +
             *   - _cache_keys_ is a flag indicating hash keys should be cached.
         
     | 
| 
      
 1309 
     | 
    
         
            +
             *   - _cache_strings_ is a positive integer less than 35. Strings shorter than that length are cached.
         
     | 
| 
      
 1310 
     | 
    
         
            +
             *   - _handler_ is the SAJ handler
         
     | 
| 
       1304 
1311 
     | 
    
         
             
             *
         
     | 
| 
       1305 
1312 
     | 
    
         
             
             * - *:usual*
         
     | 
| 
       1306 
     | 
    
         
            -
             *   -  
     | 
| 
       1307 
     | 
    
         
            -
             *   -  
     | 
| 
       1308 
     | 
    
         
            -
             *   -  
     | 
| 
       1309 
     | 
    
         
            -
             *  
     | 
| 
       1310 
     | 
    
         
            -
             *   -  
     | 
| 
       1311 
     | 
    
         
            -
             * 
     | 
| 
       1312 
     | 
    
         
            -
             *  
     | 
| 
       1313 
     | 
    
         
            -
             * 
     | 
| 
       1314 
     | 
    
         
            -
             * 
     | 
| 
       1315 
     | 
    
         
            -
             *  
     | 
| 
       1316 
     | 
    
         
            -
             * 
     | 
| 
       1317 
     | 
    
         
            -
             * 
     | 
| 
       1318 
     | 
    
         
            -
             * 
     | 
| 
       1319 
     | 
    
         
            -
             *  
     | 
| 
       1320 
     | 
    
         
            -
             * 
     | 
| 
       1321 
     | 
    
         
            -
             *  
     | 
| 
       1322 
     | 
    
         
            -
             * _: 
     | 
| 
       1323 
     | 
    
         
            -
             * 
     | 
| 
       1324 
     | 
    
         
            -
             *  
     | 
| 
       1325 
     | 
    
         
            -
             * 
     | 
| 
       1326 
     | 
    
         
            -
             *   -  
     | 
| 
       1327 
     | 
    
         
            -
             * ignored on parsing in favor of creating an instance and populating directly.
         
     | 
| 
       1328 
     | 
    
         
            -
             *   - _missing_class_ return the value of the _missing_class_ indicator.
         
     | 
| 
       1329 
     | 
    
         
            -
             *   - _missing_class=_ sets the value of the _missing_class_ flag. Valid values are _:auto_ which creates any missing
         
     | 
| 
       1330 
     | 
    
         
            -
             * classes on parse, :ignore which ignores and continues as a Hash (default), and :raise which raises an exception if
         
     | 
| 
       1331 
     | 
    
         
            -
             * the class is not found.
         
     | 
| 
       1332 
     | 
    
         
            -
             *   - _omit_null=_ sets the _omit_null_ flag. If true then null values in a map or object are omitted from the
         
     | 
| 
       1333 
     | 
    
         
            -
             * resulting Hash or Object.
         
     | 
| 
       1334 
     | 
    
         
            -
             *   - _omit_null_ returns the value of the _omit_null_ flag.
         
     | 
| 
       1335 
     | 
    
         
            -
             *   - _symbol_keys=_ sets the flag that indicates Hash keys should be parsed to Symbols versus Strings.
         
     | 
| 
       1336 
     | 
    
         
            -
             *   - _symbol_keys_ returns the value of the _symbol_keys_ flag.
         
     | 
| 
      
 1313 
     | 
    
         
            +
             *   - _cache_keys_ is a flag indicating hash keys should be cached.
         
     | 
| 
      
 1314 
     | 
    
         
            +
             *   - _cache_strings_ is a positive integer less than 35. Strings shorter than that length are cached.
         
     | 
| 
      
 1315 
     | 
    
         
            +
             *   - _cache_expunge_ dictates when the cache will be expunged where 0 never expunges,
         
     | 
| 
      
 1316 
     | 
    
         
            +
             *     1 expunges slowly, 2 expunges faster, and 3 or higher expunges agressively.
         
     | 
| 
      
 1317 
     | 
    
         
            +
             *   - _capacity_ is the capacity of the parser's internal stack. The parser grows automatically
         
     | 
| 
      
 1318 
     | 
    
         
            +
             *     but can be updated directly with this call.
         
     | 
| 
      
 1319 
     | 
    
         
            +
             *   - _create_id_ if non-nil is the key that is used to specify the type of object to create
         
     | 
| 
      
 1320 
     | 
    
         
            +
             *     when parsing. Parsed JSON objects that include the specified element use the element
         
     | 
| 
      
 1321 
     | 
    
         
            +
             *     value as the name of the class to create an object from instead of a Hash.
         
     | 
| 
      
 1322 
     | 
    
         
            +
             *   - _decimal_ is the approach to how decimals are parsed. If _:auto_ then
         
     | 
| 
      
 1323 
     | 
    
         
            +
             *     the decimals with significant digits are 16 or less are Floats and long
         
     | 
| 
      
 1324 
     | 
    
         
            +
             *     ones are BigDecimal. _:ruby_ uses a call to Ruby to convert a string to a Float.
         
     | 
| 
      
 1325 
     | 
    
         
            +
             *     _:float_ always generates a Float. _:bigdecimal_ always results in a BigDecimal.
         
     | 
| 
      
 1326 
     | 
    
         
            +
             *   - _ignore_json_create_ is a flag that when set the class json_create method is
         
     | 
| 
      
 1327 
     | 
    
         
            +
             *     ignored on parsing in favor of creating an instance and populating directly.
         
     | 
| 
      
 1328 
     | 
    
         
            +
             *   - _missing_class_ is an indicator that determines how unknown class names are handled.
         
     | 
| 
      
 1329 
     | 
    
         
            +
             *     Valid values are _:auto_ which creates any missing classes on parse, :ignore which ignores
         
     | 
| 
      
 1330 
     | 
    
         
            +
             *     and continues as a Hash (default), and :raise which raises an exception if the class is not found.
         
     | 
| 
      
 1331 
     | 
    
         
            +
             *   - _omit_null_ is a flag that if true then null values in a map or object are omitted
         
     | 
| 
      
 1332 
     | 
    
         
            +
             *     from the resulting Hash or Object.
         
     | 
| 
      
 1333 
     | 
    
         
            +
             *   - _symbol_keys_ is a flag that indicates Hash keys should be parsed to Symbols versus Strings.
         
     | 
| 
       1337 
1334 
     | 
    
         
             
             */
         
     | 
| 
       1338 
1335 
     | 
    
         
             
            static VALUE parser_missing(int argc, VALUE *argv, VALUE self) {
         
     | 
| 
       1339 
     | 
    
         
            -
                ojParser       p 
     | 
| 
      
 1336 
     | 
    
         
            +
                ojParser       p;
         
     | 
| 
       1340 
1337 
     | 
    
         
             
                const char    *key  = NULL;
         
     | 
| 
       1341 
1338 
     | 
    
         
             
                volatile VALUE rkey = *argv;
         
     | 
| 
       1342 
1339 
     | 
    
         
             
                volatile VALUE rv   = Qnil;
         
     | 
| 
       1343 
1340 
     | 
    
         | 
| 
      
 1341 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _ojParser, &oj_parser_type, p);
         
     | 
| 
      
 1342 
     | 
    
         
            +
             
     | 
| 
       1344 
1343 
     | 
    
         
             
            #if HAVE_RB_EXT_RACTOR_SAFE
         
     | 
| 
       1345 
1344 
     | 
    
         
             
                // This doesn't seem to do anything.
         
     | 
| 
       1346 
1345 
     | 
    
         
             
                rb_ext_ractor_safe(true);
         
     | 
| 
         @@ -1366,9 +1365,11 @@ static VALUE parser_missing(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       1366 
1365 
     | 
    
         
             
             * Returns the result according to the delegate of the parser.
         
     | 
| 
       1367 
1366 
     | 
    
         
             
             */
         
     | 
| 
       1368 
1367 
     | 
    
         
             
            static VALUE parser_parse(VALUE self, VALUE json) {
         
     | 
| 
       1369 
     | 
    
         
            -
                ojParser    p 
     | 
| 
      
 1368 
     | 
    
         
            +
                ojParser    p;
         
     | 
| 
       1370 
1369 
     | 
    
         
             
                const byte *ptr = (const byte *)StringValuePtr(json);
         
     | 
| 
       1371 
1370 
     | 
    
         | 
| 
      
 1371 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _ojParser, &oj_parser_type, p);
         
     | 
| 
      
 1372 
     | 
    
         
            +
             
     | 
| 
       1372 
1373 
     | 
    
         
             
                parser_reset(p);
         
     | 
| 
       1373 
1374 
     | 
    
         
             
                p->start(p);
         
     | 
| 
       1374 
1375 
     | 
    
         
             
                parse(p, ptr);
         
     | 
| 
         @@ -1382,9 +1383,11 @@ static VALUE load_rescue(VALUE self, VALUE x) { 
     | 
|
| 
       1382 
1383 
     | 
    
         
             
            }
         
     | 
| 
       1383 
1384 
     | 
    
         | 
| 
       1384 
1385 
     | 
    
         
             
            static VALUE load(VALUE self) {
         
     | 
| 
       1385 
     | 
    
         
            -
                ojParser       p 
     | 
| 
      
 1386 
     | 
    
         
            +
                ojParser       p;
         
     | 
| 
       1386 
1387 
     | 
    
         
             
                volatile VALUE rbuf = rb_str_new2("");
         
     | 
| 
       1387 
1388 
     | 
    
         | 
| 
      
 1389 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _ojParser, &oj_parser_type, p);
         
     | 
| 
      
 1390 
     | 
    
         
            +
             
     | 
| 
       1388 
1391 
     | 
    
         
             
                p->start(p);
         
     | 
| 
       1389 
1392 
     | 
    
         
             
                while (true) {
         
     | 
| 
       1390 
1393 
     | 
    
         
             
                    rb_funcall(p->reader, oj_readpartial_id, 2, INT2NUM(16385), rbuf);
         
     | 
| 
         @@ -1403,7 +1406,9 @@ static VALUE load(VALUE self) { 
     | 
|
| 
       1403 
1406 
     | 
    
         
             
             * Returns the result according to the delegate of the parser.
         
     | 
| 
       1404 
1407 
     | 
    
         
             
             */
         
     | 
| 
       1405 
1408 
     | 
    
         
             
            static VALUE parser_load(VALUE self, VALUE reader) {
         
     | 
| 
       1406 
     | 
    
         
            -
                ojParser p 
     | 
| 
      
 1409 
     | 
    
         
            +
                ojParser p;
         
     | 
| 
      
 1410 
     | 
    
         
            +
             
     | 
| 
      
 1411 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _ojParser, &oj_parser_type, p);
         
     | 
| 
       1407 
1412 
     | 
    
         | 
| 
       1408 
1413 
     | 
    
         
             
                parser_reset(p);
         
     | 
| 
       1409 
1414 
     | 
    
         
             
                p->reader = reader;
         
     | 
| 
         @@ -1420,10 +1425,12 @@ static VALUE parser_load(VALUE self, VALUE reader) { 
     | 
|
| 
       1420 
1425 
     | 
    
         
             
             * Returns the result according to the delegate of the parser.
         
     | 
| 
       1421 
1426 
     | 
    
         
             
             */
         
     | 
| 
       1422 
1427 
     | 
    
         
             
            static VALUE parser_file(VALUE self, VALUE filename) {
         
     | 
| 
       1423 
     | 
    
         
            -
                ojParser    p 
     | 
| 
      
 1428 
     | 
    
         
            +
                ojParser    p;
         
     | 
| 
       1424 
1429 
     | 
    
         
             
                const char *path;
         
     | 
| 
       1425 
1430 
     | 
    
         
             
                int         fd;
         
     | 
| 
       1426 
1431 
     | 
    
         | 
| 
      
 1432 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _ojParser, &oj_parser_type, p);
         
     | 
| 
      
 1433 
     | 
    
         
            +
             
     | 
| 
       1427 
1434 
     | 
    
         
             
                path = StringValuePtr(filename);
         
     | 
| 
       1428 
1435 
     | 
    
         | 
| 
       1429 
1436 
     | 
    
         
             
                parser_reset(p);
         
     | 
| 
         @@ -1467,7 +1474,9 @@ static VALUE parser_file(VALUE self, VALUE filename) { 
     | 
|
| 
       1467 
1474 
     | 
    
         
             
             * Returns the current state of the just_one [_Boolean_] option.
         
     | 
| 
       1468 
1475 
     | 
    
         
             
             */
         
     | 
| 
       1469 
1476 
     | 
    
         
             
            static VALUE parser_just_one(VALUE self) {
         
     | 
| 
       1470 
     | 
    
         
            -
                ojParser p 
     | 
| 
      
 1477 
     | 
    
         
            +
                ojParser p;
         
     | 
| 
      
 1478 
     | 
    
         
            +
             
     | 
| 
      
 1479 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _ojParser, &oj_parser_type, p);
         
     | 
| 
       1471 
1480 
     | 
    
         | 
| 
       1472 
1481 
     | 
    
         
             
                return p->just_one ? Qtrue : Qfalse;
         
     | 
| 
       1473 
1482 
     | 
    
         
             
            }
         
     | 
| 
         @@ -1481,7 +1490,9 @@ static VALUE parser_just_one(VALUE self) { 
     | 
|
| 
       1481 
1490 
     | 
    
         
             
             * Returns the current state of the just_one [_Boolean_] option.
         
     | 
| 
       1482 
1491 
     | 
    
         
             
             */
         
     | 
| 
       1483 
1492 
     | 
    
         
             
            static VALUE parser_just_one_set(VALUE self, VALUE v) {
         
     | 
| 
       1484 
     | 
    
         
            -
                ojParser p 
     | 
| 
      
 1493 
     | 
    
         
            +
                ojParser p;
         
     | 
| 
      
 1494 
     | 
    
         
            +
             
     | 
| 
      
 1495 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _ojParser, &oj_parser_type, p);
         
     | 
| 
       1485 
1496 
     | 
    
         | 
| 
       1486 
1497 
     | 
    
         
             
                p->just_one = (Qtrue == v);
         
     | 
| 
       1487 
1498 
     | 
    
         | 
| 
         @@ -1505,7 +1516,7 @@ static VALUE parser_usual(VALUE self) { 
     | 
|
| 
       1505 
1516 
     | 
    
         
             
                    buf_init(&p->buf);
         
     | 
| 
       1506 
1517 
     | 
    
         
             
                    p->map = value_map;
         
     | 
| 
       1507 
1518 
     | 
    
         
             
                    oj_set_parser_usual(p);
         
     | 
| 
       1508 
     | 
    
         
            -
                    usual_parser =  
     | 
| 
      
 1519 
     | 
    
         
            +
                    usual_parser = TypedData_Wrap_Struct(parser_class, &oj_parser_type, p);
         
     | 
| 
       1509 
1520 
     | 
    
         
             
                    rb_gc_register_address(&usual_parser);
         
     | 
| 
       1510 
1521 
     | 
    
         
             
                }
         
     | 
| 
       1511 
1522 
     | 
    
         
             
                return usual_parser;
         
     | 
| 
         @@ -1528,7 +1539,7 @@ static VALUE parser_saj(VALUE self) { 
     | 
|
| 
       1528 
1539 
     | 
    
         
             
                    buf_init(&p->buf);
         
     | 
| 
       1529 
1540 
     | 
    
         
             
                    p->map = value_map;
         
     | 
| 
       1530 
1541 
     | 
    
         
             
                    oj_set_parser_saj(p);
         
     | 
| 
       1531 
     | 
    
         
            -
                    saj_parser =  
     | 
| 
      
 1542 
     | 
    
         
            +
                    saj_parser = TypedData_Wrap_Struct(parser_class, &oj_parser_type, p);
         
     | 
| 
       1532 
1543 
     | 
    
         
             
                    rb_gc_register_address(&saj_parser);
         
     | 
| 
       1533 
1544 
     | 
    
         
             
                }
         
     | 
| 
       1534 
1545 
     | 
    
         
             
                return saj_parser;
         
     | 
| 
         @@ -1550,7 +1561,7 @@ static VALUE parser_validate(VALUE self) { 
     | 
|
| 
       1550 
1561 
     | 
    
         
             
                    buf_init(&p->buf);
         
     | 
| 
       1551 
1562 
     | 
    
         
             
                    p->map = value_map;
         
     | 
| 
       1552 
1563 
     | 
    
         
             
                    oj_set_parser_validator(p);
         
     | 
| 
       1553 
     | 
    
         
            -
                    validate_parser =  
     | 
| 
      
 1564 
     | 
    
         
            +
                    validate_parser = TypedData_Wrap_Struct(parser_class, &oj_parser_type, p);
         
     | 
| 
       1554 
1565 
     | 
    
         
             
                    rb_gc_register_address(&validate_parser);
         
     | 
| 
       1555 
1566 
     | 
    
         
             
                }
         
     | 
| 
       1556 
1567 
     | 
    
         
             
                return validate_parser;
         
     | 
    
        data/ext/oj/parser.h
    CHANGED
    
    | 
         @@ -32,9 +32,9 @@ typedef struct _num { 
     | 
|
| 
       32 
32 
     | 
    
         
             
                long double dub;
         
     | 
| 
       33 
33 
     | 
    
         
             
                int64_t     fixnum;  // holds all digits
         
     | 
| 
       34 
34 
     | 
    
         
             
                uint32_t    len;
         
     | 
| 
       35 
     | 
    
         
            -
                int16_t     div; 
     | 
| 
      
 35 
     | 
    
         
            +
                int16_t     div;     // 10^div
         
     | 
| 
       36 
36 
     | 
    
         
             
                int16_t     exp;
         
     | 
| 
       37 
     | 
    
         
            -
                uint8_t     shift; 
     | 
| 
      
 37 
     | 
    
         
            +
                uint8_t     shift;   // shift of fixnum to get decimal
         
     | 
| 
       38 
38 
     | 
    
         
             
                bool        neg;
         
     | 
| 
       39 
39 
     | 
    
         
             
                bool        exp_neg;
         
     | 
| 
       40 
40 
     | 
    
         
             
                // for numbers as strings, reuse buf
         
     | 
    
        data/ext/oj/rails.c
    CHANGED
    
    | 
         @@ -639,6 +639,17 @@ static void encoder_mark(void *ptr) { 
     | 
|
| 
       639 
639 
     | 
    
         
             
                }
         
     | 
| 
       640 
640 
     | 
    
         
             
            }
         
     | 
| 
       641 
641 
     | 
    
         | 
| 
      
 642 
     | 
    
         
            +
            static const rb_data_type_t oj_encoder_type = {
         
     | 
| 
      
 643 
     | 
    
         
            +
                "Oj/encoder",
         
     | 
| 
      
 644 
     | 
    
         
            +
                {
         
     | 
| 
      
 645 
     | 
    
         
            +
                    encoder_mark,
         
     | 
| 
      
 646 
     | 
    
         
            +
                    encoder_free,
         
     | 
| 
      
 647 
     | 
    
         
            +
                    NULL,
         
     | 
| 
      
 648 
     | 
    
         
            +
                },
         
     | 
| 
      
 649 
     | 
    
         
            +
                0,
         
     | 
| 
      
 650 
     | 
    
         
            +
                0,
         
     | 
| 
      
 651 
     | 
    
         
            +
            };
         
     | 
| 
      
 652 
     | 
    
         
            +
             
     | 
| 
       642 
653 
     | 
    
         
             
            /* Document-method: new
         
     | 
| 
       643 
654 
     | 
    
         
             
             *	call-seq: new(options=nil)
         
     | 
| 
       644 
655 
     | 
    
         
             
             *
         
     | 
| 
         @@ -656,7 +667,7 @@ static VALUE encoder_new(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       656 
667 
     | 
    
         
             
                    oj_parse_options(*argv, &e->opts);
         
     | 
| 
       657 
668 
     | 
    
         
             
                    e->arg = *argv;
         
     | 
| 
       658 
669 
     | 
    
         
             
                }
         
     | 
| 
       659 
     | 
    
         
            -
                return  
     | 
| 
      
 670 
     | 
    
         
            +
                return TypedData_Wrap_Struct(encoder_class, &oj_encoder_type, e);
         
     | 
| 
       660 
671 
     | 
    
         
             
            }
         
     | 
| 
       661 
672 
     | 
    
         | 
| 
       662 
673 
     | 
    
         
             
            static VALUE resolve_classpath(const char *name) {
         
     | 
| 
         @@ -748,7 +759,8 @@ static void optimize(int argc, VALUE *argv, ROptTable rot, bool on) { 
     | 
|
| 
       748 
759 
     | 
    
         
             
             * - *classes* [_Class_] a list of classes to optimize
         
     | 
| 
       749 
760 
     | 
    
         
             
             */
         
     | 
| 
       750 
761 
     | 
    
         
             
            static VALUE encoder_optimize(int argc, VALUE *argv, VALUE self) {
         
     | 
| 
       751 
     | 
    
         
            -
                Encoder e 
     | 
| 
      
 762 
     | 
    
         
            +
                Encoder e;
         
     | 
| 
      
 763 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _encoder, &oj_encoder_type, e);
         
     | 
| 
       752 
764 
     | 
    
         | 
| 
       753 
765 
     | 
    
         
             
                optimize(argc, argv, &e->ropts, true);
         
     | 
| 
       754 
766 
     | 
    
         | 
| 
         @@ -804,7 +816,8 @@ rails_mimic_json(VALUE self) { 
     | 
|
| 
       804 
816 
     | 
    
         
             
             * - *classes* [_Class_] a list of classes to deoptimize
         
     | 
| 
       805 
817 
     | 
    
         
             
             */
         
     | 
| 
       806 
818 
     | 
    
         
             
            static VALUE encoder_deoptimize(int argc, VALUE *argv, VALUE self) {
         
     | 
| 
       807 
     | 
    
         
            -
                Encoder e 
     | 
| 
      
 819 
     | 
    
         
            +
                Encoder e;
         
     | 
| 
      
 820 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _encoder, &oj_encoder_type, e);
         
     | 
| 
       808 
821 
     | 
    
         | 
| 
       809 
822 
     | 
    
         
             
                optimize(argc, argv, &e->ropts, false);
         
     | 
| 
       810 
823 
     | 
    
         | 
| 
         @@ -833,8 +846,11 @@ static VALUE rails_deoptimize(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       833 
846 
     | 
    
         
             
             * @return true if the class is being optimized for rails and false otherwise
         
     | 
| 
       834 
847 
     | 
    
         
             
             */
         
     | 
| 
       835 
848 
     | 
    
         
             
            static VALUE encoder_optimized(VALUE self, VALUE clas) {
         
     | 
| 
       836 
     | 
    
         
            -
                Encoder e 
     | 
| 
       837 
     | 
    
         
            -
                ROpt    ro 
     | 
| 
      
 849 
     | 
    
         
            +
                Encoder e;
         
     | 
| 
      
 850 
     | 
    
         
            +
                ROpt    ro;
         
     | 
| 
      
 851 
     | 
    
         
            +
             
     | 
| 
      
 852 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _encoder, &oj_encoder_type, e);
         
     | 
| 
      
 853 
     | 
    
         
            +
                ro = oj_rails_get_opt(&e->ropts, clas);
         
     | 
| 
       838 
854 
     | 
    
         | 
| 
       839 
855 
     | 
    
         
             
                if (NULL == ro) {
         
     | 
| 
       840 
856 
     | 
    
         
             
                    return Qfalse;
         
     | 
| 
         @@ -890,7 +906,6 @@ static VALUE encode(VALUE obj, ROptTable ropts, Options opts, int argc, VALUE *a 
     | 
|
| 
       890 
906 
     | 
    
         
             
                oj_out_init(&out);
         
     | 
| 
       891 
907 
     | 
    
         | 
| 
       892 
908 
     | 
    
         
             
                out.omit_nil = copts.dump_opts.omit_nil;
         
     | 
| 
       893 
     | 
    
         
            -
                out.caller   = 0;
         
     | 
| 
       894 
909 
     | 
    
         
             
                out.cur      = out.buf;
         
     | 
| 
       895 
910 
     | 
    
         
             
                out.circ_cnt = 0;
         
     | 
| 
       896 
911 
     | 
    
         
             
                out.opts     = &copts;
         
     | 
| 
         @@ -941,7 +956,8 @@ static VALUE encode(VALUE obj, ROptTable ropts, Options opts, int argc, VALUE *a 
     | 
|
| 
       941 
956 
     | 
    
         
             
             * Returns encoded object as a JSON string.
         
     | 
| 
       942 
957 
     | 
    
         
             
             */
         
     | 
| 
       943 
958 
     | 
    
         
             
            static VALUE encoder_encode(VALUE self, VALUE obj) {
         
     | 
| 
       944 
     | 
    
         
            -
                Encoder e 
     | 
| 
      
 959 
     | 
    
         
            +
                Encoder e;
         
     | 
| 
      
 960 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _encoder, &oj_encoder_type, e);
         
     | 
| 
       945 
961 
     | 
    
         | 
| 
       946 
962 
     | 
    
         
             
                if (Qnil != e->arg) {
         
     | 
| 
       947 
963 
     | 
    
         
             
                    VALUE argv[1] = {e->arg};
         
     | 
    
        data/ext/oj/reader.c
    CHANGED
    
    | 
         @@ -101,7 +101,7 @@ int oj_reader_read(Reader reader) { 
     | 
|
| 
       101 
101 
     | 
    
         
             
                    } else {
         
     | 
| 
       102 
102 
     | 
    
         
             
                        shift = reader->pro - reader->head - 1;  // leave one character so we can backup one
         
     | 
| 
       103 
103 
     | 
    
         
             
                    }
         
     | 
| 
       104 
     | 
    
         
            -
                    if (0 >= shift) { 
     | 
| 
      
 104 
     | 
    
         
            +
                    if (0 >= shift) {                            /* no space left so allocate more */
         
     | 
| 
       105 
105 
     | 
    
         
             
                        const char *old  = reader->head;
         
     | 
| 
       106 
106 
     | 
    
         
             
                        size_t      size = reader->end - reader->head + BUF_PAD;
         
     | 
| 
       107 
107 
     | 
    
         | 
| 
         @@ -164,7 +164,6 @@ static VALUE partial_io_cb(VALUE rbuf) { 
     | 
|
| 
       164 
164 
     | 
    
         
             
                }
         
     | 
| 
       165 
165 
     | 
    
         
             
                str = StringValuePtr(rstr);
         
     | 
| 
       166 
166 
     | 
    
         
             
                cnt = RSTRING_LEN(rstr);
         
     | 
| 
       167 
     | 
    
         
            -
                // printf("*** partial read %lu bytes, str: '%s'\n", cnt, str);
         
     | 
| 
       168 
167 
     | 
    
         
             
                strcpy(reader->tail, str);
         
     | 
| 
       169 
168 
     | 
    
         
             
                reader->read_end = reader->tail + cnt;
         
     | 
| 
       170 
169 
     | 
    
         | 
| 
         @@ -185,7 +184,6 @@ static VALUE io_cb(VALUE rbuf) { 
     | 
|
| 
       185 
184 
     | 
    
         
             
                }
         
     | 
| 
       186 
185 
     | 
    
         
             
                str = StringValuePtr(rstr);
         
     | 
| 
       187 
186 
     | 
    
         
             
                cnt = RSTRING_LEN(rstr);
         
     | 
| 
       188 
     | 
    
         
            -
                // printf("*** read %lu bytes, str: '%s'\n", cnt, str);
         
     | 
| 
       189 
187 
     | 
    
         
             
                strcpy(reader->tail, str);
         
     | 
| 
       190 
188 
     | 
    
         
             
                reader->read_end = reader->tail + cnt;
         
     | 
| 
       191 
189 
     | 
    
         | 
    
        data/ext/oj/saj.c
    CHANGED
    
    | 
         @@ -587,7 +587,7 @@ static void saj_parse(VALUE handler, char *json) { 
     | 
|
| 
       587 
587 
     | 
    
         
             
                    if (0 == getrlimit(RLIMIT_STACK, &lim) && RLIM_INFINITY != lim.rlim_cur) {
         
     | 
| 
       588 
588 
     | 
    
         
             
                        pi.stack_min = (void *)((char *)&obj - (lim.rlim_cur / 4 * 3)); /* let 3/4ths of the stack be used only */
         
     | 
| 
       589 
589 
     | 
    
         
             
                    } else {
         
     | 
| 
       590 
     | 
    
         
            -
                        pi.stack_min = 0; 
     | 
| 
      
 590 
     | 
    
         
            +
                        pi.stack_min = 0;                                               /* indicates not to check stack limit */
         
     | 
| 
       591 
591 
     | 
    
         
             
                    }
         
     | 
| 
       592 
592 
     | 
    
         
             
                }
         
     | 
| 
       593 
593 
     | 
    
         
             
            #endif
         
     | 
    
        data/ext/oj/stream_writer.c
    CHANGED
    
    | 
         @@ -21,6 +21,17 @@ static void stream_writer_free(void *ptr) { 
     | 
|
| 
       21 
21 
     | 
    
         
             
                OJ_R_FREE(ptr);
         
     | 
| 
       22 
22 
     | 
    
         
             
            }
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
      
 24 
     | 
    
         
            +
            static const rb_data_type_t oj_stream_writer_type = {
         
     | 
| 
      
 25 
     | 
    
         
            +
                "Oj/stream_writer",
         
     | 
| 
      
 26 
     | 
    
         
            +
                {
         
     | 
| 
      
 27 
     | 
    
         
            +
                    NULL,
         
     | 
| 
      
 28 
     | 
    
         
            +
                    stream_writer_free,
         
     | 
| 
      
 29 
     | 
    
         
            +
                    NULL,
         
     | 
| 
      
 30 
     | 
    
         
            +
                },
         
     | 
| 
      
 31 
     | 
    
         
            +
                0,
         
     | 
| 
      
 32 
     | 
    
         
            +
                0,
         
     | 
| 
      
 33 
     | 
    
         
            +
            };
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       24 
35 
     | 
    
         
             
            static void stream_writer_reset_buf(StreamWriter sw) {
         
     | 
| 
       25 
36 
     | 
    
         
             
                sw->sw.out.cur  = sw->sw.out.buf;
         
     | 
| 
       26 
37 
     | 
    
         
             
                *sw->sw.out.cur = '\0';
         
     | 
| 
         @@ -120,7 +131,7 @@ static VALUE stream_writer_new(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       120 
131 
     | 
    
         
             
                sw->type          = type;
         
     | 
| 
       121 
132 
     | 
    
         
             
                sw->fd            = fd;
         
     | 
| 
       122 
133 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
                return  
     | 
| 
      
 134 
     | 
    
         
            +
                return TypedData_Wrap_Struct(oj_stream_writer_class, &oj_stream_writer_type, sw);
         
     | 
| 
       124 
135 
     | 
    
         
             
            }
         
     | 
| 
       125 
136 
     | 
    
         | 
| 
       126 
137 
     | 
    
         
             
            /* Document-method: push_key
         
     | 
| 
         @@ -133,7 +144,8 @@ static VALUE stream_writer_new(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       133 
144 
     | 
    
         
             
             * - *key* [_String_] the key pending for the next push
         
     | 
| 
       134 
145 
     | 
    
         
             
             */
         
     | 
| 
       135 
146 
     | 
    
         
             
            static VALUE stream_writer_push_key(VALUE self, VALUE key) {
         
     | 
| 
       136 
     | 
    
         
            -
                StreamWriter sw 
     | 
| 
      
 147 
     | 
    
         
            +
                StreamWriter sw;
         
     | 
| 
      
 148 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);
         
     | 
| 
       137 
149 
     | 
    
         | 
| 
       138 
150 
     | 
    
         
             
                oj_str_writer_push_key(&sw->sw, StringValuePtr(key));
         
     | 
| 
       139 
151 
     | 
    
         
             
                if (sw->flush_limit < sw->sw.out.cur - sw->sw.out.buf) {
         
     | 
| 
         @@ -151,7 +163,8 @@ static VALUE stream_writer_push_key(VALUE self, VALUE key) { 
     | 
|
| 
       151 
163 
     | 
    
         
             
             * - *key* [_String_] the key if adding to an object in the JSON document
         
     | 
| 
       152 
164 
     | 
    
         
             
             */
         
     | 
| 
       153 
165 
     | 
    
         
             
            static VALUE stream_writer_push_object(int argc, VALUE *argv, VALUE self) {
         
     | 
| 
       154 
     | 
    
         
            -
                StreamWriter sw 
     | 
| 
      
 166 
     | 
    
         
            +
                StreamWriter sw;
         
     | 
| 
      
 167 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);
         
     | 
| 
       155 
168 
     | 
    
         | 
| 
       156 
169 
     | 
    
         
             
                switch (argc) {
         
     | 
| 
       157 
170 
     | 
    
         
             
                case 0: oj_str_writer_push_object(&sw->sw, 0); break;
         
     | 
| 
         @@ -179,7 +192,8 @@ static VALUE stream_writer_push_object(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       179 
192 
     | 
    
         
             
             * - *key* [_String_] the key if adding to an object in the JSON document
         
     | 
| 
       180 
193 
     | 
    
         
             
             */
         
     | 
| 
       181 
194 
     | 
    
         
             
            static VALUE stream_writer_push_array(int argc, VALUE *argv, VALUE self) {
         
     | 
| 
       182 
     | 
    
         
            -
                StreamWriter sw 
     | 
| 
      
 195 
     | 
    
         
            +
                StreamWriter sw;
         
     | 
| 
      
 196 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);
         
     | 
| 
       183 
197 
     | 
    
         | 
| 
       184 
198 
     | 
    
         
             
                switch (argc) {
         
     | 
| 
       185 
199 
     | 
    
         
             
                case 0: oj_str_writer_push_array(&sw->sw, 0); break;
         
     | 
| 
         @@ -206,15 +220,16 @@ static VALUE stream_writer_push_array(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       206 
220 
     | 
    
         
             
             * - *key* [_String_] the key if adding to an object in the JSON document
         
     | 
| 
       207 
221 
     | 
    
         
             
             */
         
     | 
| 
       208 
222 
     | 
    
         
             
            static VALUE stream_writer_push_value(int argc, VALUE *argv, VALUE self) {
         
     | 
| 
       209 
     | 
    
         
            -
                StreamWriter sw 
     | 
| 
      
 223 
     | 
    
         
            +
                StreamWriter sw;
         
     | 
| 
      
 224 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);
         
     | 
| 
       210 
225 
     | 
    
         | 
| 
       211 
226 
     | 
    
         
             
                switch (argc) {
         
     | 
| 
       212 
     | 
    
         
            -
                case 1: oj_str_writer_push_value((StrWriter) 
     | 
| 
      
 227 
     | 
    
         
            +
                case 1: oj_str_writer_push_value((StrWriter)sw, *argv, 0); break;
         
     | 
| 
       213 
228 
     | 
    
         
             
                case 2:
         
     | 
| 
       214 
229 
     | 
    
         
             
                    if (Qnil == argv[1]) {
         
     | 
| 
       215 
     | 
    
         
            -
                        oj_str_writer_push_value((StrWriter) 
     | 
| 
      
 230 
     | 
    
         
            +
                        oj_str_writer_push_value((StrWriter)sw, *argv, 0);
         
     | 
| 
       216 
231 
     | 
    
         
             
                    } else {
         
     | 
| 
       217 
     | 
    
         
            -
                        oj_str_writer_push_value((StrWriter) 
     | 
| 
      
 232 
     | 
    
         
            +
                        oj_str_writer_push_value((StrWriter)sw, *argv, StringValuePtr(argv[1]));
         
     | 
| 
       218 
233 
     | 
    
         
             
                    }
         
     | 
| 
       219 
234 
     | 
    
         
             
                    break;
         
     | 
| 
       220 
235 
     | 
    
         
             
                default: rb_raise(rb_eArgError, "Wrong number of argument to 'push_value'."); break;
         
     | 
| 
         @@ -235,15 +250,16 @@ static VALUE stream_writer_push_value(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       235 
250 
     | 
    
         
             
             * - *key* [_String_] the key if adding to an object in the JSON document
         
     | 
| 
       236 
251 
     | 
    
         
             
             */
         
     | 
| 
       237 
252 
     | 
    
         
             
            static VALUE stream_writer_push_json(int argc, VALUE *argv, VALUE self) {
         
     | 
| 
       238 
     | 
    
         
            -
                StreamWriter sw 
     | 
| 
      
 253 
     | 
    
         
            +
                StreamWriter sw;
         
     | 
| 
      
 254 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);
         
     | 
| 
       239 
255 
     | 
    
         | 
| 
       240 
256 
     | 
    
         
             
                switch (argc) {
         
     | 
| 
       241 
     | 
    
         
            -
                case 1: oj_str_writer_push_json((StrWriter) 
     | 
| 
      
 257 
     | 
    
         
            +
                case 1: oj_str_writer_push_json((StrWriter)sw, StringValuePtr(*argv), 0); break;
         
     | 
| 
       242 
258 
     | 
    
         
             
                case 2:
         
     | 
| 
       243 
259 
     | 
    
         
             
                    if (Qnil == argv[1]) {
         
     | 
| 
       244 
     | 
    
         
            -
                        oj_str_writer_push_json((StrWriter) 
     | 
| 
      
 260 
     | 
    
         
            +
                        oj_str_writer_push_json((StrWriter)sw, StringValuePtr(*argv), 0);
         
     | 
| 
       245 
261 
     | 
    
         
             
                    } else {
         
     | 
| 
       246 
     | 
    
         
            -
                        oj_str_writer_push_json((StrWriter) 
     | 
| 
      
 262 
     | 
    
         
            +
                        oj_str_writer_push_json((StrWriter)sw, StringValuePtr(*argv), StringValuePtr(argv[1]));
         
     | 
| 
       247 
263 
     | 
    
         
             
                    }
         
     | 
| 
       248 
264 
     | 
    
         
             
                    break;
         
     | 
| 
       249 
265 
     | 
    
         
             
                default: rb_raise(rb_eArgError, "Wrong number of argument to 'push_json'."); break;
         
     | 
| 
         @@ -261,7 +277,8 @@ static VALUE stream_writer_push_json(int argc, VALUE *argv, VALUE self) { 
     | 
|
| 
       261 
277 
     | 
    
         
             
             * currently open.
         
     | 
| 
       262 
278 
     | 
    
         
             
             */
         
     | 
| 
       263 
279 
     | 
    
         
             
            static VALUE stream_writer_pop(VALUE self) {
         
     | 
| 
       264 
     | 
    
         
            -
                StreamWriter sw 
     | 
| 
      
 280 
     | 
    
         
            +
                StreamWriter sw;
         
     | 
| 
      
 281 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);
         
     | 
| 
       265 
282 
     | 
    
         | 
| 
       266 
283 
     | 
    
         
             
                oj_str_writer_pop(&sw->sw);
         
     | 
| 
       267 
284 
     | 
    
         
             
                if (sw->flush_limit < sw->sw.out.cur - sw->sw.out.buf) {
         
     | 
| 
         @@ -277,7 +294,8 @@ static VALUE stream_writer_pop(VALUE self) { 
     | 
|
| 
       277 
294 
     | 
    
         
             
             * currently open.
         
     | 
| 
       278 
295 
     | 
    
         
             
             */
         
     | 
| 
       279 
296 
     | 
    
         
             
            static VALUE stream_writer_pop_all(VALUE self) {
         
     | 
| 
       280 
     | 
    
         
            -
                StreamWriter sw 
     | 
| 
      
 297 
     | 
    
         
            +
                StreamWriter sw;
         
     | 
| 
      
 298 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);
         
     | 
| 
       281 
299 
     | 
    
         | 
| 
       282 
300 
     | 
    
         
             
                oj_str_writer_pop_all(&sw->sw);
         
     | 
| 
       283 
301 
     | 
    
         
             
                stream_writer_write(sw);
         
     | 
| 
         @@ -291,7 +309,9 @@ static VALUE stream_writer_pop_all(VALUE self) { 
     | 
|
| 
       291 
309 
     | 
    
         
             
             * Flush any remaining characters in the buffer.
         
     | 
| 
       292 
310 
     | 
    
         
             
             */
         
     | 
| 
       293 
311 
     | 
    
         
             
            static VALUE stream_writer_flush(VALUE self) {
         
     | 
| 
       294 
     | 
    
         
            -
                 
     | 
| 
      
 312 
     | 
    
         
            +
                StreamWriter sw;
         
     | 
| 
      
 313 
     | 
    
         
            +
                TypedData_Get_Struct(self, struct _streamWriter, &oj_stream_writer_type, sw);
         
     | 
| 
      
 314 
     | 
    
         
            +
                stream_writer_write(sw);
         
     | 
| 
       295 
315 
     | 
    
         | 
| 
       296 
316 
     | 
    
         
             
                return Qnil;
         
     | 
| 
       297 
317 
     | 
    
         
             
            }
         
     |