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

Method make

valdi/src/valdi/android/ValdiMarshallableObjectDescriptorJavaClass.cpp:16–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 : cls(std::move(cls)) {}
15
16ValdiMarshallableObjectDescriptorJavaClass ValdiMarshallableObjectDescriptorJavaClass::make() {
17 auto className = STRING_LITERAL("com/snap/valdi/schema/ValdiMarshallableObjectDescriptor");
18 auto cls = JavaClass::resolveOrAbort(JavaEnv(), className.getCStr());
19
20 ValdiMarshallableObjectDescriptorJavaClass out(std::move(cls));
21
22 auto expectedReturnType = Valdi::ValueSchema::typeReference(Valdi::ValueSchemaTypeReference::named(className));
23
24 auto classType =
25 Valdi::ValueSchema::typeReference(Valdi::ValueSchemaTypeReference::named(STRING_LITERAL("java/lang/Class")));
26
27 out.getDescriptorForClassMethod =
28 out.cls.getStaticMethod("getDescriptorForClass", expectedReturnType, &classType, 1, false);
29
30 auto byteBufferType = Valdi::ValueSchema::typeReference(
31 Valdi::ValueSchemaTypeReference::named(STRING_LITERAL("java/nio/ByteBuffer")));
32 std::initializer_list<Valdi::ValueSchema> getDescriptorClosureParams = {classType, Valdi::ValueSchema::boolean()};
33 out.getDescriptorClosureMethod = out.cls.getStaticMethod("getDescriptorClosure",
34 byteBufferType,
35 getDescriptorClosureParams.begin(),
36 getDescriptorClosureParams.size(),
37 false);
38
39 std::initializer_list<Valdi::ValueSchema> objectImplementsMethodParameters = {
40 Valdi::ValueSchema::typeReference(Valdi::ValueSchemaTypeReference::named(STRING_LITERAL("java/lang/Object"))),
41 Valdi::ValueSchema::typeReference(
42 Valdi::ValueSchemaTypeReference::named(STRING_LITERAL("java/lang/reflect/Method")))};
43
44 out.objectImplementsMethodMethod = out.cls.getStaticMethod("objectImplementsMethod",
45 Valdi::ValueSchema::boolean(),
46 objectImplementsMethodParameters.begin(),
47 objectImplementsMethodParameters.size(),
48 false);
49
50 out.typeField = out.cls.getField("type", Valdi::ValueSchema::integer(), false);
51 out.schemaField = out.cls.getField("schema", Valdi::ValueSchema::string(), false);
52 out.proxyClassField = out.cls.getField("proxyClass", classType, false);
53 out.typeReferencesField =
54 out.cls.getField("typeReferences", Valdi::ValueSchema::array(Valdi::ValueSchema::string()), false);
55 out.propertyReplacementsField = out.cls.getField("propertyReplacements", Valdi::ValueSchema::string(), false);
56
57 return out;
58}
59
60const ValdiMarshallableObjectDescriptorJavaClass& ValdiMarshallableObjectDescriptorJavaClass::get() {
61 static auto kInstance = make();

Callers

nothing calls this directly

Calls 6

JavaEnvClass · 0.50
getCStrMethod · 0.45
getStaticMethodMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45
getFieldMethod · 0.45

Tested by

no test coverage detected