| 644 | } |
| 645 | |
| 646 | void xs_jsonparser_receive(xsMachine *the) |
| 647 | { |
| 648 | struct jsonparser *fsm = xsmcGetHostData(xsThis); |
| 649 | |
| 650 | if (fsm == C_NULL) |
| 651 | xsUnknownError((char *)execute_on_closed); |
| 652 | |
| 653 | int count = 0; |
| 654 | if (fsm->cs != JSON_error) { |
| 655 | |
| 656 | xsmcVars(XS_COUNT); |
| 657 | xsmcGet(xsVar(XS_KEYS), xsThis, xsID_keys); |
| 658 | xsmcGet(xsVar(XS_VPT), xsThis, xsID_vpt); |
| 659 | |
| 660 | // be careful with XS macros between here and copying our string into the buffer |
| 661 | char *string = xsmcToString(xsArg(0)); // required string |
| 662 | int length = c_strlen(string); |
| 663 | int start = arg_to_index(the, 1, 0, length); // optional string slice start (default value is 0) |
| 664 | int end = arg_to_index(the, 2, length, length); // optional string slice end (default value is length) |
| 665 | string = xsmcToString(xsArg(0)); // reset the string after evaluating the start/end args |
| 666 | if (start < end) { |
| 667 | int offset = start; |
| 668 | int size = end - start; |
| 669 | if (offset >= 0 && size > 0) { |
| 670 | char *buffer = C_NULL; |
| 671 | xsTry { |
| 672 | buffer = c_malloc(size); |
| 673 | if (buffer == C_NULL) |
| 674 | xsUnknownError((char *)not_enough_memory); |
| 675 | c_memcpy(buffer, string + offset, size); |
| 676 | |
| 677 | const char *p = buffer; |
| 678 | const char *pe = buffer + size; |
| 679 | |
| 680 | |
| 681 | #line 682 "jsonparser.c" |
| 682 | { |
| 683 | int _klen; |
| 684 | const char *_keys; |
| 685 | int _trans; |
| 686 | |
| 687 | if ( p == pe ) |
| 688 | goto _test_eof; |
| 689 | if ( fsm->cs == 0 ) |
| 690 | goto _out; |
| 691 | _resume: |
| 692 | _keys = _JSON_trans_keys + c_read16( &_JSON_key_offsets[ fsm->cs] ); |
| 693 | _trans = c_read16( &_JSON_index_offsets[ fsm->cs] ); |
| 694 | |
| 695 | _klen = c_read8( &_JSON_single_lengths[ fsm->cs] ); |
| 696 | if ( _klen > 0 ) { |
| 697 | const char *_lower = _keys; |
| 698 | const char *_mid; |
| 699 | const char *_upper = _keys + _klen - 1; |
| 700 | while (1) { |
| 701 | if ( _upper < _lower ) |
| 702 | break; |
| 703 |
nothing calls this directly
no test coverage detected