| 14 | #include "../../graph/entities/graph_entity.h" |
| 15 | |
| 16 | SIValue AR_TOMAP(SIValue *argv, int argc, void *private_data) { |
| 17 | /* create a new SIMap object |
| 18 | * expecting an even number of arguments |
| 19 | * argv[even] = key |
| 20 | * argv[odd] = value */ |
| 21 | |
| 22 | // validate number of arguments |
| 23 | if(argc % 2 != 0) { |
| 24 | ErrorCtx_RaiseRuntimeException("map expects even number of elements"); |
| 25 | } |
| 26 | |
| 27 | SIValue map = SI_Map(argc / 2); |
| 28 | |
| 29 | for(int i = 0; i < argc; i += 2) { |
| 30 | SIValue key = argv[i]; |
| 31 | SIValue val = argv[i + 1]; |
| 32 | |
| 33 | // make sure key is a string |
| 34 | if(!(SI_TYPE(key) & T_STRING)) { |
| 35 | Error_SITypeMismatch(key, T_STRING); |
| 36 | break; |
| 37 | } |
| 38 | |
| 39 | Map_Add(&map, key, val); |
| 40 | } |
| 41 | |
| 42 | return map; |
| 43 | } |
| 44 | |
| 45 | SIValue AR_KEYS(SIValue *argv, int argc, void *private_data) { |
| 46 | ASSERT(argc == 1); |
nothing calls this directly
no test coverage detected