Example #1
0
 public void FinishAccessor(StreamWriter sw, Signature sig, string indent)
 {
     sw.WriteLine(indent + "\t\t\treturn " + sig.AccessorName + ";");
 }
Example #2
0
        public void Generate(GenerationInfo gen_info)
        {
            if (!Validate())
            {
                return;
            }

            StreamWriter sw = gen_info.Writer;

            gen_info.CurrentMember = CName;

            GenerateImport(sw);

            if (IsStatic)
            {
                GenerateStatic(gen_info);
            }
            else
            {
                sw.WriteLine("\t\t{0} {1}{2} ({3}) {4}", Protection, Safety, name, Signature.ToString(), needs_chaining ? ": base (IntPtr.Zero)" : "");
                sw.WriteLine("\t\t{");

                if (needs_chaining)
                {
                    sw.WriteLine("\t\t\tif (GetType () != typeof (" + name + ")) {");

                    if (Parameters.Count == 0)
                    {
                        sw.WriteLine("\t\t\t\tCreateNativeObject (new string [0], new GLib.Value[0]);");
                        sw.WriteLine("\t\t\t\treturn;");
                    }
                    else
                    {
                        ArrayList names  = new ArrayList();
                        ArrayList values = new ArrayList();
                        for (int i = 0; i < Parameters.Count; i++)
                        {
                            Parameter p = Parameters[i];
                            if (container_type.GetPropertyRecursively(p.StudlyName) != null)
                            {
                                names.Add(p.Name);
                                values.Add(p.Name);
                            }
                            else if (p.PropertyName != String.Empty)
                            {
                                names.Add(p.PropertyName);
                                values.Add(p.Name);
                            }
                        }

                        if (names.Count == Parameters.Count)
                        {
                            sw.WriteLine("\t\t\t\tArrayList vals = new ArrayList();");
                            sw.WriteLine("\t\t\t\tArrayList names = new ArrayList();");
                            for (int i = 0; i < names.Count; i++)
                            {
                                Parameter p      = Parameters [i];
                                string    indent = "\t\t\t\t";
                                if (p.Generatable is ClassBase && !(p.Generatable is StructBase))
                                {
                                    sw.WriteLine(indent + "if (" + p.Name + " != null) {");
                                    indent += "\t";
                                }
                                sw.WriteLine(indent + "names.Add (\"" + names [i] + "\");");
                                sw.WriteLine(indent + "vals.Add (new GLib.Value (" + values[i] + "));");

                                if (p.Generatable is ClassBase && !(p.Generatable is StructBase))
                                {
                                    sw.WriteLine("\t\t\t\t}");
                                }
                            }

                            sw.WriteLine("\t\t\t\tCreateNativeObject ((string[])names.ToArray (typeof (string)), (GLib.Value[])vals.ToArray (typeof (GLib.Value)));");
                            sw.WriteLine("\t\t\t\treturn;");
                        }
                        else
                        {
                            sw.WriteLine("\t\t\t\tthrow new InvalidOperationException (\"Can't override this constructor.\");");
                        }
                    }

                    sw.WriteLine("\t\t\t}");
                }

                Body.Initialize(gen_info, false, false, "");
                sw.WriteLine("\t\t\t{0} = {1}({2});", container_type.AssignToName, CName, Body.GetCallString(false));
                Body.Finish(sw, "");
                Body.HandleException(sw, "");
            }

            sw.WriteLine("\t\t}");
            sw.WriteLine();

            Statistics.CtorCount++;
        }
Example #3
0
 public void InitAccessor(StreamWriter sw, Signature sig, string indent)
 {
     sw.WriteLine(indent + "\t\t\t" + sig.AccessorType + " " + sig.AccessorName + ";");
 }