MCPcopy Create free account
hub / github.com/NativeScript/android / GetType

Method GetType

test-app/runtime/src/main/cpp/MethodCache.cpp:117–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117string MethodCache::GetType(Isolate* isolate, const v8::Local<v8::Value>& value) {
118 string type;
119
120 if (value->IsObject()) {
121 auto context = isolate->GetCurrentContext();
122 auto objVal = value->ToObject(context).ToLocalChecked();
123 Local<Value> nullNode; //out
124 V8GetPrivateValue(isolate, objVal, V8StringConstants::GetNullNodeName(isolate), nullNode);
125
126 if (!nullNode.IsEmpty()) {
127 auto treeNode = reinterpret_cast<MetadataNode*>(nullNode.As<External>()->Value());
128
129 type = (treeNode != nullptr) ? treeNode->GetName() : "<unknown>";
130
131 DEBUG_WRITE("Parameter of type %s with NULL value is passed to the method.", type.c_str());
132 return type;
133 }
134 }
135
136 if (value->IsArray()) {
137 type = "array";
138 } else if (value->IsArrayBuffer() || value->IsInt8Array() || value->IsUint8Array() || value->IsUint8ClampedArray()) {
139 type = "bytebuffer";
140 } else if (value->IsInt16Array() || value->IsUint16Array()) {
141 type = "shortbuffer";
142 } else if (value->IsInt32Array() || value->IsUint32Array()) {
143 type = "intbuffer";
144 } else if (value->IsBigUint64Array() || value->IsBigInt64Array()) {
145 type = "longbuffer";
146 } else if (value->IsFloat32Array()) {
147 type = "floatbuffer";
148 } else if (value->IsFloat64Array()) {
149 type = "doublebuffer";
150 } else if (value->IsBoolean() || value->IsBooleanObject() || value->IsFalse() || value->IsTrue()) {
151 type = "bool";
152 } else if (value->IsDataView()) {
153 type = "view";
154 } else if (value->IsDate()) {
155 type = "date";
156 } else if (value->IsFunction()) {
157 type = "function";
158 } else if (value->IsInt32() || value->IsUint32()) {
159 type = "int";
160 } else if (value->IsNull() || value->IsUndefined()) {
161 type = "null";
162 } else if (value->IsString() || value->IsStringObject()) {
163 type = "string";
164 } else if (value->IsNumber() || value->IsNumberObject()) {
165 auto context = isolate->GetCurrentContext();
166 double d = value->NumberValue(context).ToChecked();
167 int64_t i = (int64_t) d;
168 bool isInteger = d == i;
169
170 type = isInteger ? "intnumber" : "doublenumber";
171 } else if (value->IsObject()) {
172 auto context = isolate->GetCurrentContext();
173 auto object = value->ToObject(context).ToLocalChecked();
174 auto castType = NumericCasts::GetCastType(isolate, object);

Callers

nothing calls this directly

Calls 10

GetCastTypeFunction · 0.85
ToLocalCheckedMethod · 0.80
IsUndefinedMethod · 0.80
IsStringMethod · 0.80
ToCheckedMethod · 0.80
IsEmptyMethod · 0.45
ValueMethod · 0.45
GetNameMethod · 0.45
IsNullMethod · 0.45

Tested by

no test coverage detected