public Object GetWrapperType(Definition def) { var builder = new Builder(def); var ns = builder.Resolve(builder.Product.Assembly.Name); var baseType = (Object)builder.Resolve(typeof(Gluon.TaskBase)); if (Result.Type.IsVoid) { return(baseType); } var current = def.AllTypes.OfType <Object>().FirstOrDefault(o => o.Name == WrapperName && o.Namespace == ns); if (current != null) { return(current); } var t = new Object() { Name = WrapperName, //BaseType = baseType, Access = Access.Internal, Namespace = builder.Resolve(builder.Product.Assembly.Name), Origin = TypeOrigin.MappedIntermediary, }; t.Constructors.Add(new Constructor()); foreach (var m in baseType.Methods) { t.Methods.Add(m); } t.Properties.Add(new Property() { Name = "Result", Access = Access.Public, Nature = MemberNature.Instance, Type = Result.Type, IsArray = Result.IsArray, }); return(t); }
private void PreprocessDefinition() { Definition.ApplyTypeSubstitutions(Settings.TargetId); Definition.ApplyNamespaceSubsitutions(Settings.TargetId); foreach (var type in Definition.AllTypes) { if (type.Origin != TypeOrigin.Mapped) { if (type.IsObject && type.Origin != TypeOrigin.Managed && type.Assembly == Definition.Assembly) { AllGeneratedClasses.Add((AST.Object)type); } else if (type.IsStruct) { AllGeneratedStructs.Add((AST.Struct)type); } else if (type.IsEnum && type.Origin != TypeOrigin.Managed && type.Assembly == Definition.Assembly) { AllGeneratedEnums.Add((AST.Enum)type); } else if (type.IsDelegate && !((AST.Delegate)type).IsGeneric) { AllGeneratedDelegates.Add((AST.Delegate)type); } } } foreach (var type in Definition.AllTypes) { if (type.IsDelegate) { AllTranslatedDelegates.Add((AST.Delegate)type); } else if (type.IsStruct && CppRender.RequiresABITranslation(type.ToVariable())) { AllTranslatedStructs.Add((AST.Struct)type); } } Definition.StripAllGluonAttributes(); Definition.PutDefaultConstructorsFirst(); Definition.InsertDefaultConstructorsWhereNoneAreDefined(); var builder = new AST.Builder(Definition); _assemblyNS = builder.Resolve(Definition.Assembly.Name); _gluonNS = builder.Resolve("Gluon"); builder.Resolve(typeof(DllImportAttribute)); builder.Resolve(typeof(MarshalAsAttribute)); builder.Resolve(typeof(GluonObject)); builder.Resolve(typeof(DelegateBlob)); }