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

Method SetMissingBaseMethods

test-app/runtime/src/main/cpp/MetadataNode.cpp:2088–2143  ·  view source on GitHub ↗

* This method handles scenrios like Bundle/BaseBundle class hierarchy change in API level 21. * See https://github.com/NativeScript/android-runtime/issues/628 */

Source from the content-addressed store, hash-verified

2086 * See https://github.com/NativeScript/android-runtime/issues/628
2087 */
2088void MetadataNode::SetMissingBaseMethods(
2089 Isolate* isolate, const vector<MetadataTreeNode*>& skippedBaseTypes,
2090 const vector<MethodCallbackData*>& instanceMethodData,
2091 PrototypeTemplateFiller& protoFiller) {
2092 for (auto treeNode: skippedBaseTypes) {
2093 uint8_t* curPtr = s_metadataReader.GetValueData() + treeNode->offsetValue + 1;
2094
2095 auto nodeType = s_metadataReader.GetNodeType(treeNode);
2096
2097 auto curType = s_metadataReader.ReadTypeName(treeNode);
2098
2099 curPtr += sizeof(uint16_t /* baseClassId */);
2100
2101 if (s_metadataReader.IsNodeTypeInterface(nodeType)) {
2102 curPtr += sizeof(uint8_t) + sizeof(uint32_t);
2103 }
2104
2105 //get candidates from instance methods metadata
2106 auto instanceMethodCount = *reinterpret_cast<uint16_t*>(curPtr);
2107 curPtr += sizeof(uint16_t);
2108 MethodCallbackData* callbackData = nullptr;
2109
2110 for (auto i = 0; i < instanceMethodCount; i++) {
2111 auto entry = MetadataReader::ReadInstanceMethodEntry(&curPtr);
2112
2113 auto isConstructor = entry.getName() == "<init>";
2114 if (isConstructor) {
2115 continue;
2116 }
2117
2118 for (auto data: instanceMethodData) {
2119 if (data->candidates.front().getName() == entry.getName()) {
2120 callbackData = data;
2121 break;
2122 }
2123 }
2124
2125 if (callbackData == nullptr) {
2126 callbackData = new MethodCallbackData(this);
2127 protoFiller.FillPrototypeMethod(isolate, entry.getName(), callbackData);
2128 }
2129
2130 bool foundSameSig = false;
2131 for (auto &m: callbackData->candidates) {
2132 foundSameSig = m.sig == entry.getSig();
2133 if (foundSameSig) {
2134 break;
2135 }
2136 }
2137
2138 if (!foundSameSig) {
2139 callbackData->candidates.push_back(std::move(entry));
2140 }
2141 }
2142 }
2143}
2144
2145void MetadataNode::RegisterSymbolHasInstanceCallback(Isolate* isolate, MetadataEntry& entry, Local<Value> interface) {

Callers 1

Calls 7

GetValueDataMethod · 0.80
GetNodeTypeMethod · 0.80
frontMethod · 0.80
FillPrototypeMethodMethod · 0.80
getNameMethod · 0.65
ReadTypeNameMethod · 0.45
IsNodeTypeInterfaceMethod · 0.45

Tested by

no test coverage detected