|
| 1 | +/** |
| 2 | + * Enum value to identify/encode the different Troupe objects. |
| 3 | + */ |
1 | 4 | export const enum TroupeType { |
2 | | - UNIT=0, |
3 | | - BOOLEAN=1, |
4 | | - NUMBER=2, |
5 | | - STRING=3, |
6 | | - PROCESS_ID=4, |
7 | | - LEVEL=5, |
8 | | - AUTHORITY=6, |
9 | | - CAPABILITY=7, |
10 | | - ATOM=8, |
11 | | - /* up until this point only base types */ |
12 | | - |
13 | | - /* aggregate types */ |
14 | | - CLOSURE=100, |
15 | | - LVAL=101, // TODO: AA; 2020-03-03 ; this should be only used for transports; |
16 | | - TUPLE=102, |
17 | | - LIST=103, |
18 | | - RECORD=104, |
19 | | - /* meaningless to serialize */ |
20 | | - LOCALOBJECT=200 |
| 5 | + // -------------------------------------------------------------------------- |
| 6 | + // base types |
| 7 | + UNIT = 0, |
| 8 | + BOOLEAN = 1, |
| 9 | + NUMBER = 2, |
| 10 | + STRING = 3, |
| 11 | + PROCESS_ID = 4, |
| 12 | + LEVEL = 5, |
| 13 | + AUTHORITY = 6, |
| 14 | + CAPABILITY = 7, |
| 15 | + ATOM = 8, |
| 16 | + |
| 17 | + // -------------------------------------------------------------------------- |
| 18 | + // aggregate types |
| 19 | + CLOSURE = 100, |
| 20 | + LVAL = 101, // TODO (AA; 2020-03-03): should be only used for transports |
| 21 | + TUPLE = 102, |
| 22 | + LIST = 103, |
| 23 | + RECORD = 104, |
| 24 | + |
| 25 | + // -------------------------------------------------------------------------- |
| 26 | + // unserializable objects type |
| 27 | + LOCALOBJECT = 200 |
21 | 28 | } |
22 | 29 |
|
23 | | -export const enum ClosureType { |
24 | | - /* okay to serialize */ |
25 | | - REGULARFN = 0, |
| 30 | +/** |
| 31 | + * Enum value to identify the diffrent types of Troupe objects, i.e. Troupe |
| 32 | + * objects with `TroupeType.CLOSURE`. |
| 33 | + */ |
| 34 | +export const enum ClosureType { |
| 35 | + // okay to serialize |
| 36 | + REGULARFN = 0, |
26 | 37 |
|
27 | | - /* meaningless to serialize */ |
28 | | - BUILTINFN = 1, |
29 | | - SANDBOXKONT = 2 , |
30 | | - SERVICEFN = 3 |
| 38 | + // not to be serialized |
| 39 | + BUILTINFN = 1, |
| 40 | + SANDBOXKONT = 2, |
| 41 | + SERVICEFN = 3, |
31 | 42 | } |
32 | 43 |
|
33 | | -export function isSerializableClosure (ct: ClosureType) { |
| 44 | +/** |
| 45 | + * Identifies whether the given closure type, `ct`, is intended for |
| 46 | + * serialization. |
| 47 | + */ |
| 48 | +export function isSerializableClosure(ct: ClosureType) : boolean { |
34 | 49 | return (ct === ClosureType.REGULARFN); |
35 | 50 | } |
36 | 51 |
|
37 | | -export function getTroupeType (x: any) : TroupeType { |
| 52 | +/** |
| 53 | + * Infer the `TroupeType` of a given object. |
| 54 | + */ |
| 55 | +export function getTroupeType(x: any) : TroupeType { |
38 | 56 | // Troupe Types |
39 | 57 | if (x._troupeType !== undefined) { |
40 | 58 | return x._troupeType; |
|
0 commit comments