-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathAnon.cpp
More file actions
158 lines (114 loc) · 3.47 KB
/
Anon.cpp
File metadata and controls
158 lines (114 loc) · 3.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#include <hxcpp.h>
namespace hx
{
Dynamic FieldMapCreate() { return Dynamic(); }
bool FieldMapGet(FieldMap *inMap, const String &inName, Dynamic &outValue)
{
if (!inMap || !inMap->mPtr)
return false;
if (!__string_hash_exists(*inMap,inName))
return false;
outValue = __string_hash_get(*inMap, inName);
return true;
}
bool FieldMapGet(FieldMap *inMap, int inId, Dynamic &outValue)
{
if (!inMap || !inMap->mPtr)
return false;
const String &key = __hxcpp_field_from_id(inId);
if (!__string_hash_exists(*inMap,key))
return false;
outValue = __string_hash_get(*inMap, key);
return true;
}
bool FieldMapHas(FieldMap *inMap, const String &inName)
{
return inMap && inMap->mPtr && __string_hash_exists(*inMap,inName);
}
void FieldMapSet(FieldMap *inMap, const String &inName, const Dynamic &inValue)
{
__string_hash_set(*inMap, inName, inValue,true);
}
void FieldMapAppendFields(FieldMap *inMap,Array<String> &outFields)
{
Array<String> keys = __string_hash_keys(*inMap);
if (outFields->length==0)
outFields = keys;
else
outFields = outFields->concat(keys);
}
// -- Anon_obj -------------------------------------------------
Anon_obj::Anon_obj()
{
mFields = hx::FieldMapCreate();
}
void Anon_obj::__Mark(hx::MarkContext *__inCtx)
{
HX_MARK_MEMBER(mFields);
}
#ifdef HXCPP_VISIT_ALLOCS
void Anon_obj::__Visit(hx::VisitContext *__inCtx)
{
HX_VISIT_MEMBER(mFields);
}
#endif
Dynamic Anon_obj::__Field(const String &inName, hx::PropertyAccess inCallProp)
{
return __string_hash_get(mFields,inName);
}
bool Anon_obj::__HasField(const String &inName)
{
return __string_hash_exists(mFields,inName);
}
bool Anon_obj::__Remove(String inKey)
{
return __string_hash_remove(mFields,inKey);
}
Dynamic Anon_obj::__SetField(const String &inName,const Dynamic &inValue, hx::PropertyAccess inCallProp)
{
__string_hash_set(mFields,inName,inValue,true);
return inValue;
}
Anon_obj *Anon_obj::Add(const String &inName,const Dynamic &inValue,bool inSetThisPointer)
{
__string_hash_set(mFields,inName,inValue,true);
if (inSetThisPointer && inValue.GetPtr())
inValue.GetPtr()->__SetThis(this);
return this;
}
String Anon_obj::toString()
{
Dynamic func;
if (FieldMapGet(&mFields, HX_CSTRING("toString"), func))
return func();
return __string_hash_to_string(mFields);
}
void Anon_obj::__GetFields(Array<String> &outFields)
{
outFields = __string_hash_keys(mFields);
}
String Anon_obj::__ToString() const { return HX_CSTRING("Anon"); }
Dynamic Anon_obj::__Create(DynamicArray inArgs) { return Anon(new Anon_obj); }
hx::Class Anon_obj::__mClass;
void Anon_obj::__boot()
{
Static(__mClass) = hx::RegisterClass(HX_CSTRING("__Anon"),TCanCast<Anon_obj>,sNone,sNone,0,0,0,0);
}
Anon SourceInfo(String inFile, int inLine, String inClass, String inMethod)
{
Anon result = Anon_obj::Create();
result->Add(HX_CSTRING("fileName"),inFile);
result->Add(HX_CSTRING("lineNumber"),inLine);
//CS116 result->Add(HX_CSTRING("columnNumber"),inColumn);
result->Add(HX_CSTRING("className"),inClass);
result->Add(HX_CSTRING("methodName"),inMethod);
return result;
}
}
bool __hxcpp_anon_remove(Dynamic inObj,String inKey)
{
Dynamic *map = inObj->__GetFieldMap();
if (map)
return __string_hash_remove(*map,inKey);
return false;
}