public virtual void Generate(GenerationInfo gen_info, string indent) { if (Ignored || Hidden) { return; } CheckGlue(); if ((getterName != null || setterName != null || getOffsetName != null) && gen_info.GlueWriter == null) { Console.WriteLine("No glue-filename specified, can't create glue for {0}.{1}", container_type.Name, Name); return; } GenerateImports(gen_info, indent); SymbolTable table = SymbolTable.Table; StreamWriter sw = gen_info.Writer; string modifiers = elem.HasAttribute("new_flag") ? "new " : ""; bool is_struct = table.IsStruct(CType) || table.IsBoxed(CType); sw.WriteLine(indent + "public " + modifiers + CSType + " " + Name + " {"); if (Getter != null) { sw.Write(indent + "\tget "); Getter.GenerateBody(gen_info, container_type, "\t"); sw.WriteLine(""); } else if (getterName != null) { sw.WriteLine(indent + "\tget {"); container_type.Prepare(sw, indent + "\t\t"); sw.WriteLine(indent + "\t\t" + CSType + " result = " + table.FromNativeReturn(ctype, getterName + " (" + container_type.CallByName() + ")") + ";"); container_type.Finish(sw, indent + "\t\t"); sw.WriteLine(indent + "\t\treturn result;"); sw.WriteLine(indent + "\t}"); } else if (Readable && offsetName != null) { sw.WriteLine(indent + "\tget {"); sw.WriteLine(indent + "\t\tunsafe {"); if (is_struct) { sw.WriteLine(indent + "\t\t\t" + CSType + "* raw_ptr = (" + CSType + "*)(((byte*)" + container_type.CallByName() + ") + " + offsetName + ");"); sw.WriteLine(indent + "\t\t\treturn *raw_ptr;"); } else { sw.WriteLine(indent + "\t\t\t" + table.GetMarshalReturnType(CType) + "* raw_ptr = (" + table.GetMarshalReturnType(CType) + "*)(((byte*)" + container_type.CallByName() + ") + " + offsetName + ");"); sw.WriteLine(indent + "\t\t\treturn " + table.FromNativeReturn(ctype, "(*raw_ptr)") + ";"); } sw.WriteLine(indent + "\t\t}"); sw.WriteLine(indent + "\t}"); } if (Setter != null) { sw.Write(indent + "\tset "); Setter.GenerateBody(gen_info, container_type, "\t"); sw.WriteLine(""); } else if (setterName != null) { sw.WriteLine(indent + "\tset {"); container_type.Prepare(sw, indent + "\t\t"); sw.WriteLine(indent + "\t\t" + setterName + " (" + container_type.CallByName() + ", " + table.CallByName(ctype, "value") + ");"); container_type.Finish(sw, indent + "\t\t"); sw.WriteLine(indent + "\t}"); } else if (Writable && offsetName != null) { sw.WriteLine(indent + "\tset {"); sw.WriteLine(indent + "\t\tunsafe {"); if (is_struct) { sw.WriteLine(indent + "\t\t\t" + CSType + "* raw_ptr = (" + CSType + "*)(((byte*)" + container_type.CallByName() + ") + " + offsetName + ");"); sw.WriteLine(indent + "\t\t\t*raw_ptr = value;"); } else { sw.WriteLine(indent + "\t\t\t" + table.GetMarshalReturnType(CType) + "* raw_ptr = (" + table.GetMarshalReturnType(CType) + "*)(((byte*)" + container_type.CallByName() + ") + " + offsetName + ");"); sw.WriteLine(indent + "\t\t\t*raw_ptr = " + table.ToNativeReturn(ctype, "value") + ";"); } sw.WriteLine(indent + "\t\t}"); sw.WriteLine(indent + "\t}"); } sw.WriteLine(indent + "}"); sw.WriteLine(""); if (getterName != null || setterName != null || getOffsetName != null) { GenerateGlue(gen_info); } }