| 54 | } |
| 55 | |
| 56 | void Test262Context_getMetadata(xsMachine* the) |
| 57 | { |
| 58 | FILE* file = NULL; |
| 59 | size_t size; |
| 60 | char* buffer = NULL; |
| 61 | char* begin; |
| 62 | char* end; |
| 63 | yaml_parser_t _parser; |
| 64 | yaml_parser_t* parser = NULL; |
| 65 | yaml_document_t _document; |
| 66 | yaml_document_t* document = NULL; |
| 67 | yaml_node_t* root; |
| 68 | yaml_node_t* value; |
| 69 | int sloppy = 1; |
| 70 | int strict = 1; |
| 71 | int module = 0; |
| 72 | int async = 0; |
| 73 | int pending = 0; |
| 74 | xsVars(1); |
| 75 | xsResult = xsNewObject(); |
| 76 | xsVar(0) = xsNewArray(0); |
| 77 | |
| 78 | file = fopen(xsToString(xsArg(0)), "rb"); |
| 79 | if (!file) goto bail; |
| 80 | fseek(file, 0, SEEK_END); |
| 81 | size = ftell(file); |
| 82 | if (!size) goto bail; |
| 83 | fseek(file, 0, SEEK_SET); |
| 84 | buffer = malloc(size + 1); |
| 85 | if (!buffer) goto bail; |
| 86 | if (fread(buffer, 1, size, file) != size) goto bail; |
| 87 | buffer[size] = 0; |
| 88 | fclose(file); |
| 89 | file = NULL; |
| 90 | |
| 91 | begin = strstr(buffer, "/*---"); |
| 92 | if (!begin) goto bail; |
| 93 | begin += 5; |
| 94 | end = strstr(begin, "---*/"); |
| 95 | if (!end) goto bail; |
| 96 | |
| 97 | if (!yaml_parser_initialize(&_parser)) goto bail; |
| 98 | parser = &_parser; |
| 99 | yaml_parser_set_input_string(parser, (unsigned char *)begin, end - begin); |
| 100 | if (!yaml_parser_load(parser, &_document)) goto bail; |
| 101 | document = &_document; |
| 102 | root = yaml_document_get_root_node(document); |
| 103 | if (!root) goto bail; |
| 104 | |
| 105 | value = fxGetMappingValue(document, root, "includes"); |
| 106 | if (value) { |
| 107 | yaml_node_item_t* item = value->data.sequence.items.start; |
| 108 | while (item < value->data.sequence.items.top) { |
| 109 | yaml_node_t* node = yaml_document_get_node(document, *item); |
| 110 | xsCall1(xsVar(0), xsID_push, xsString((char*)node->data.scalar.value)); |
| 111 | item++; |
| 112 | } |
| 113 | } |
nothing calls this directly
no test coverage detected