MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxRunContext

Function fxRunContext

xs/tools/xst262.c:1034–1217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1032}
1033
1034void fxRunContext(txPool* pool, txContext* context)
1035{
1036 txAgentCluster* agentCluster = &gxAgentCluster;
1037 char* path = context->path;
1038 FILE* file = NULL;
1039 size_t size;
1040 char* buffer = NULL;
1041 char* begin;
1042 char* end;
1043 yaml_parser_t _parser;
1044 yaml_parser_t* parser = NULL;
1045 yaml_document_t _document;
1046 yaml_document_t* document = NULL;
1047 yaml_node_t* root;
1048 yaml_node_t* value;
1049 int async = 0;
1050 int atomics = 0;
1051 int sloppy = 1;
1052 int strict = 1;
1053 int module = 0;
1054 int pending = 0;
1055 char message[1024];
1056
1057 file = fopen(path, "rb");
1058 if (!file) goto bail;
1059 fseek(file, 0, SEEK_END);
1060 size = ftell(file);
1061 if (!size) goto bail;
1062 fseek(file, 0, SEEK_SET);
1063 buffer = malloc(size + 1);
1064 if (!buffer) goto bail;
1065 if (fread(buffer, 1, size, file) != size) goto bail;
1066 buffer[size] = 0;
1067 fclose(file);
1068 file = NULL;
1069
1070 begin = strstr(buffer, "/*---");
1071 if (!begin) goto bail;
1072 begin += 5;
1073 end = strstr(begin, "---*/");
1074 if (!end) goto bail;
1075
1076 if (!yaml_parser_initialize(&_parser)) goto bail;
1077 parser = &_parser;
1078 yaml_parser_set_input_string(parser, (unsigned char *)begin, end - begin);
1079 if (!yaml_parser_load(parser, &_document)) goto bail;
1080 document = &_document;
1081 root = yaml_document_get_root_node(document);
1082 if (!root) goto bail;
1083
1084 context->document = document;
1085 context->includes = fxGetMappingValue(document, root, "includes");
1086 value = fxGetMappingValue(document, root, "negative");
1087 if (value)
1088 context->negative = fxGetMappingValue(document, value, "type");
1089 else
1090 context->negative = NULL;
1091

Callers 1

fxRunFileThreadFunction · 0.85

Calls 11

yaml_parser_initializeFunction · 0.85
yaml_parser_loadFunction · 0.85
yaml_document_get_nodeFunction · 0.85
fxRunTestCaseFunction · 0.85
fxPrintBusyFunction · 0.85
fxCountResultFunction · 0.85
yaml_document_deleteFunction · 0.85
yaml_parser_deleteFunction · 0.85
fxGetMappingValueFunction · 0.70

Tested by

no test coverage detected