public CCWWriter(TypeDefinition type) { this._type = type; this._typeName = Naming.ForTypeNameOnly(type) + "CCW"; this._functionDeclaration = $"extern " C " Il2CppIManagedObjectHolder* {Naming.ForCreateComCallableWrapperFunction(type)}(Il2CppObject* obj)"; this._interfaceMethodMappings = new List <InterfaceMethodMapping>(); this._interfacesToImplement = new List <TypeReference>(); if (< > f__am$cache0 == null) {
public static string NewObj(TypeReference type, IRuntimeMetadataAccess metadataAccess) { string str = Call("il2cpp_codegen_object_new", metadataAccess.TypeInfoFor(type)); if (type.IsValueType()) { return(str); } return(Cast(Naming.ForTypeNameOnly(type) + "*", str)); }
public void WriteComInterfaceFor(TypeReference type) { this._writer.WriteCommentedLine(type.FullName); this.WriteForwardDeclarations(type); string str = !type.Resolve().IsWindowsRuntime ? "Il2CppIUnknown" : "Il2CppIInspectable"; object[] args = new object[] { Naming.ForTypeNameOnly(type), str }; this._writer.WriteLine("struct NOVTABLE {0} : {1}", args); using (new BlockWriter(this._writer, true)) { this._writer.WriteStatement("static const Il2CppGuid IID"); Unity.IL2CPP.ILPreProcessor.TypeResolver typeResolver = Unity.IL2CPP.ILPreProcessor.TypeResolver.For(type); foreach (MethodDefinition definition in type.Resolve().Methods) { MethodReference method = typeResolver.Resolve(definition); this._writer.Write(GetSignature(method, method, typeResolver, null)); this._writer.WriteLine(" = 0;"); } } }
private static string OffsetOf(FieldDefinition field) { if (field.IsLiteral) { return("0"); } if (field.IsThreadStatic()) { return("THREAD_STATIC_FIELD_OFFSET"); } if (field.DeclaringType.HasGenericParameters) { return("0"); } if (field.IsNormalStatic()) { return($"{Naming.ForStaticFieldsStruct(field.DeclaringType)}::{Naming.ForFieldOffsetGetter(field)}()"); } return($"{Naming.ForTypeNameOnly(field.DeclaringType)}::{Naming.ForFieldOffsetGetter(field)}(){(!field.DeclaringType.IsValueType() ? "" : (" + static_cast<int32_t>(sizeof(" + Naming.ForType(TypeProvider.SystemObject) + "))"))}"); }
public TableInfo WriteGuids(ICollection <TypeDefinition> types) => MetadataWriter.WriteTable <TypeDefinition>(this._writer, "extern const Il2CppGuid*", "g_Guids", types, delegate(TypeDefinition t) { this._writer.AddIncludeForTypeDefinition(t); return($"&{Naming.ForTypeNameOnly(t)}::IID"); });