Line | Branch | Exec | Source |
---|---|---|---|
1 | #include <export.h> | ||
2 | |||
3 | #include <interface.h> | ||
4 | #include <utils.h> | ||
5 | |||
6 | napi_ref btreeConstructorRef; | ||
7 | |||
8 | 1 | napi_property_descriptor btree_export(napi_env env) { | |
9 | napi_value esBTreeClass; | ||
10 | |||
11 | #ifdef HAS_GTREE_NODE | ||
12 | napi_value symbolIterator; | ||
13 |
3/18✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
1 | NAPI_GLOBAL_SYM(env, "iterator", symbolIterator); |
14 | #endif | ||
15 | |||
16 | // Instance props | ||
17 | 28 | napi_property_descriptor esBTreeProps[] = { | |
18 | // specific | ||
19 | 1 | DEF_PROP("height", esHeight), | |
20 | |||
21 | // map | ||
22 | 1 | DEF_PROP("size", esSize), | |
23 | 1 | DEF_METHOD("set", esSet), | |
24 | 1 | DEF_METHOD("get", esGet), | |
25 | 1 | DEF_METHOD("delete", esDelete), | |
26 | 1 | DEF_METHOD("clear", esClear), | |
27 | 1 | DEF_METHOD("has", esHas), | |
28 | |||
29 | // array | ||
30 | 1 | DEF_METHOD("map", esMap), | |
31 | 1 | DEF_METHOD("reduce", esReduce), | |
32 | 1 | DEF_METHOD("filter", esFilter), | |
33 | |||
34 | // iterators | ||
35 | 1 | DEF_METHOD("forEach", esForeach), | |
36 | 1 | DEF_METHOD("forEachReverse", esForeachReverse), | |
37 | // Iterators are possible with GLib version >= 2.68 only | ||
38 | #ifdef HAS_GTREE_NODE | ||
39 | 1 | DEF_METHOD_V_WITH_DATA(symbolIterator, esGenerator, (void *) iteratorResultDefaultCb), | |
40 | 1 | DEF_METHOD_WITH_DATA("entries", esGenerator, (void *) iteratorResultDefaultCb), | |
41 | 1 | DEF_METHOD_WITH_DATA("values", esGenerator, (void *) iteratorResultValueCb), | |
42 | 1 | DEF_METHOD_WITH_DATA("keys", esGenerator, (void *) iteratorResultKeyCb), | |
43 | #endif | ||
44 | |||
45 | // Extra methods | ||
46 | #ifdef HAS_GTREE_NODE | ||
47 | 1 | DEF_METHOD("toMap", esToMap), | |
48 | 1 | DEF_METHOD("toSet", esToSet), | |
49 | 1 | DEF_METHOD("toArrays", esToArrays), | |
50 | 1 | DEF_METHOD("toArray", esToArray), | |
51 | 1 | DEF_METHOD("flatten", esFlatten), | |
52 | 1 | DEF_METHOD("getKeys", esKeys), | |
53 | 1 | DEF_METHOD("getValues", esValues), | |
54 | 1 | DEF_METHOD("first", esFirst), | |
55 | 1 | DEF_METHOD("last", esLast), | |
56 | 1 | DEF_METHOD("before", esBefore), | |
57 | 1 | DEF_METHOD("after", esAfter), | |
58 | 1 | DEF_METHOD("between", esBetween), | |
59 | #endif | ||
60 | }; | ||
61 | |||
62 | // Static props | ||
63 | 1 | napi_property_descriptor staticProps[] = { | |
64 | DEF_METHOD("from", esStaticFrom) | ||
65 | }; | ||
66 | |||
67 |
1/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1 | NAPI_CALL(env, false, |
68 | napi_define_class(env, "BTree", NAPI_AUTO_LENGTH, esConstructor, NULL, (sizeof(esBTreeProps) / sizeof(esBTreeProps[0])), esBTreeProps, &esBTreeClass)); | ||
69 | |||
70 |
1/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1 | NAPI_CALL(env, false, |
71 | napi_create_reference(env, esBTreeClass, 1, &btreeConstructorRef)); | ||
72 | |||
73 |
1/6✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
1 | NAPI_CALL(env, false, |
74 | napi_define_properties(env, esBTreeClass, (sizeof(staticProps) / sizeof(staticProps)), staticProps)); | ||
75 | |||
76 | 2 | napi_property_descriptor descriptor = { | |
77 | "BTree", | ||
78 | NULL, | ||
79 | NULL, | ||
80 | NULL, | ||
81 | NULL, | ||
82 | 1 | esBTreeClass, | |
83 | napi_default, | ||
84 | NULL | ||
85 | }; | ||
86 | |||
87 | 1 | return descriptor ; | |
88 | } | ||
89 |