MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getClassHierarchy

Method getClassHierarchy

valdi/src/valdi/android/ViewManager.cpp:149–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149std::vector<Valdi::StringBox> ViewManager::getClassHierarchy(const Valdi::StringBox& className) {
150 std::vector<Valdi::StringBox> out;
151 out.emplace_back(className);
152
153#ifdef VALDI_DEBUG_JNI_CALLS
154 __android_log_print(ANDROID_LOG_INFO, "[valdi_jni]", "Resolving classHierarchy for %s", className.getCStr());
155#endif
156
157 auto* jclass = getClassForName(className).javaClass.getClass();
158
159 while (true) {
160 jclass = JavaEnv::accessEnvRet([&](JNIEnv& env) -> auto { return env.GetSuperclass(jclass); });
161 if (jclass == nullptr) {
162 break;
163 }
164
165 auto name = JavaEnv::getCache().getClassGetNameMethod().call(jclass);
166 auto cppName = ValdiAndroid::toInternedString(getEnv(), name);
167
168#ifdef VALDI_DEBUG_JNI_CALLS
169 __android_log_print(
170 ANDROID_LOG_INFO, "[valdi_jni]", "Parent class of %s -> %s", className.getCStr(), cppName.getCStr());
171#endif
172
173 out.emplace_back(std::move(cppName));
174 }
175
176 return out;
177}
178
179void ViewManager::bindAttributes(const Valdi::StringBox& className, Valdi::AttributesBindingContext& binder) {
180 static auto kObjectClass = STRING_LITERAL("java.lang.Object");

Callers 1

Calls 5

toInternedStringFunction · 0.85
callMethod · 0.65
getEnvFunction · 0.50
getCStrMethod · 0.45
getClassMethod · 0.45

Tested by

no test coverage detected