forked from focus-creative-games/il2cpp_plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParameter.cpp
More file actions
46 lines (41 loc) · 1.84 KB
/
Parameter.cpp
File metadata and controls
46 lines (41 loc) · 1.84 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
#include "il2cpp-config.h"
#include "il2cpp-runtime-metadata.h"
#include "il2cpp-class-internals.h"
#include "il2cpp-object-internals.h"
#include "Parameter.h"
#include "vm-utils/BlobReader.h"
#include "vm/Class.h"
#include "vm/Object.h"
#include "vm/Method.h"
#include "hybridclr/metadata/MetadataUtil.h"
namespace il2cpp
{
namespace vm
{
Il2CppObject* Parameter::GetDefaultParameterValueObject(const MethodInfo* method, int32_t parameterPosition, bool* isExplicitySetNullDefaultValue)
{
const Il2CppType* typeOfDefaultValue;
const char* data = Method::GetParameterDefaultValue(method, parameterPosition, &typeOfDefaultValue, isExplicitySetNullDefaultValue);
if (data == NULL)
return NULL;
Il2CppClass* parameterType = Class::FromIl2CppType(method->parameters[parameterPosition]);
bool useInterpFormat = hybridclr::metadata::IsInterpreterType(method->klass);
if (il2cpp::vm::Class::IsValuetype(parameterType))
{
if (il2cpp::vm::Class::IsNullable(parameterType))
{
parameterType = il2cpp::vm::Class::GetNullableArgument(parameterType);
typeOfDefaultValue = il2cpp::vm::Class::IsEnum(parameterType) ? il2cpp::vm::Class::GetEnumBaseType(parameterType) : ¶meterType->byval_arg;
}
Class::SetupFields(parameterType);
IL2CPP_ASSERT(parameterType->size_inited);
void* value = alloca(parameterType->instance_size - sizeof(Il2CppObject));
utils::BlobReader::GetConstantValueFromBlob(method->klass->image, typeOfDefaultValue->type, data, value);
return Object::Box(parameterType, value);
}
Il2CppObject* value = NULL;
utils::BlobReader::GetConstantValueFromBlob(method->klass->image, typeOfDefaultValue->type, data, &value);
return value;
}
}
}