Commit 4b3d2c2e authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

remove most namespace detection workarounds, fixes bug 463171

2007-08-07  Juerg Billeter  <j@bitron.ch>

	* vapi/gdk-2.0.vala, vapi/gio-standalone.vala, vapi/gtk+-2.0.vala,
	  vapi/pango.vala, vapigen/valagidlparser.vala,
	  vapigen/valavapigen.vala: remove most namespace detection workarounds,
	  fixes bug 463171

svn path=/trunk/; revision=425
parent 64d55a77
2007-08-07 Jürg Billeter <j@bitron.ch>
* vapi/gdk-2.0.vala, vapi/gio-standalone.vala, vapi/gtk+-2.0.vala,
vapi/pango.vala, vapigen/valagidlparser.vala,
vapigen/valavapigen.vala: remove most namespace detection workarounds,
fixes bug 463171
2007-08-06 Jürg Billeter <j@bitron.ch>
* gobject/valacodegeneratorinvocationexpression.vala: support D-Bus
......
......@@ -970,7 +970,7 @@ namespace Gdk {
public static weak Gdk.Screen get_default ();
public weak Gdk.Colormap get_default_colormap ();
public weak Gdk.Display get_display ();
public pointer get_font_options ();
public weak Cairo.FontOptions get_font_options ();
public int get_height ();
public int get_height_mm ();
public int get_monitor_at_point (int x, int y);
......@@ -998,7 +998,7 @@ namespace Gdk {
public weak GLib.List list_visuals ();
public weak string make_display_name ();
public void set_default_colormap (Gdk.Colormap colormap);
public void set_font_options (pointer options);
public void set_font_options (Cairo.FontOptions options);
public void set_resolution (double dpi);
public static int width ();
public static int width_mm ();
......@@ -1240,7 +1240,7 @@ namespace Gdk {
public char send_event;
public Gdk.Atom message_type;
public ushort data_format;
public char b;
public weak string b;
}
[ReferenceType]
[CCode (cheader_filename = "gdk/gdk.h")]
......
This diff is collapsed.
......@@ -1732,9 +1732,9 @@ namespace Gtk {
public void child_set_property (Gtk.Widget child, string property_name, GLib.Value value);
public void child_set_valist (Gtk.Widget child, string first_property_name, pointer var_args);
public virtual GLib.Type child_type ();
public static weak GLib.ParamSpec class_find_child_property (pointer cclass, string property_name);
public static weak GLib.ParamSpec class_find_child_property (GLib.ObjectClass cclass, string property_name);
public static void class_install_child_property (pointer cclass, uint property_id, GLib.ParamSpec pspec);
public static weak GLib.ParamSpec class_list_child_properties (pointer cclass, uint n_properties);
public static weak GLib.ParamSpec class_list_child_properties (GLib.ObjectClass cclass, uint n_properties);
public virtual void forall (Gtk.Callback callback, pointer callback_data);
public void @foreach (Gtk.Callback callback, pointer callback_data);
public uint get_border_width ();
......@@ -2971,7 +2971,7 @@ namespace Gtk {
public weak Gtk.Printer get_printer ();
public weak Gtk.PrintSettings get_settings ();
public Gtk.PrintStatus get_status ();
public weak Cairo.Surface get_surface (GLib.Error error);
public weak Cairo.XlibSurface get_surface (GLib.Error error);
public weak string get_title ();
public bool get_track_print_status ();
public static GLib.Type get_type ();
......
......@@ -213,11 +213,11 @@ namespace Pango {
public class CairoFontMap : GLib.Object {
public weak Pango.Context create_context ();
public static weak Pango.FontMap get_default ();
public pointer get_font_type ();
public Cairo.FontType get_font_type ();
public double get_resolution ();
public static GLib.Type get_type ();
public CairoFontMap ();
public CairoFontMap.for_font_type (pointer fonttype);
public CairoFontMap.for_font_type (Cairo.FontType fonttype);
public void set_resolution (double dpi);
}
[CCode (cheader_filename = "pango/pango.h")]
......@@ -794,15 +794,15 @@ namespace Pango {
[ReferenceType]
[CCode (cheader_filename = "pango/pango.h")]
public struct Cairo {
public static pointer context_get_font_options (Pango.Context context);
public static weak Cairo.FontOptions context_get_font_options (Pango.Context context);
public static double context_get_resolution (Pango.Context context);
public static Pango.CairoShapeRendererFunc context_get_shape_renderer (Pango.Context context, pointer data);
public static void context_set_font_options (Pango.Context context, pointer options);
public static void context_set_font_options (Pango.Context context, Cairo.FontOptions options);
public static void context_set_resolution (Pango.Context context, double dpi);
public static void context_set_shape_renderer (Pango.Context context, Pango.CairoShapeRendererFunc func, pointer data, GLib.DestroyNotify dnotify);
public static weak Pango.Layout create_layout (Cairo.Context cr);
public static void error_underline_path (Cairo.Context cr, double x, double y, double width, double height);
public static pointer font_get_scaled_font (Pango.Font font);
public static weak Cairo.ScaledFont font_get_scaled_font (Pango.Font font);
public static void glyph_string_path (Cairo.Context cr, Pango.Font font, Pango.GlyphString glyphs);
public static void layout_line_path (Cairo.Context cr, Pango.LayoutLine line);
public static void layout_path (Cairo.Context cr, Pango.Layout layout);
......
......@@ -34,10 +34,13 @@ public class Vala.GIdlParser : CodeVisitor {
private SourceReference current_source_reference;
private Namespace current_namespace;
private DataType current_data_type;
private Map<string,string> codenode_attributes_map;
private Gee.Set<string> current_type_symbol_set;
private Map<string,DataType> cname_type_map;
/**
* Parse all source files in the specified code context and build a
* code tree.
......@@ -45,8 +48,42 @@ public class Vala.GIdlParser : CodeVisitor {
* @param context a code context
*/
public void parse (CodeContext! context) {
cname_type_map = new HashMap<string,DataType> (str_hash, str_equal);
this.context = context;
context.accept (this);
cname_type_map = null;
}
public override void visit_namespace (Namespace! ns) {
ns.accept_children (this);
}
public override void visit_class (Class! cl) {
visit_type (cl);
}
public override void visit_struct (Struct! st) {
visit_type (st);
}
public override void visit_interface (Interface! iface) {
visit_type (iface);
}
public override void visit_enum (Enum! en) {
visit_type (en);
}
public override void visit_callback (Callback! cb) {
visit_type (cb);
}
private void visit_type (DataType! t) {
if (!cname_type_map.contains (t.get_cname ())) {
cname_type_map[t.get_cname ()] = t;
}
}
public override void visit_source_file (SourceFile! source_file) {
......@@ -125,6 +162,8 @@ public class Vala.GIdlParser : CodeVisitor {
ns = new Namespace (module.name, current_source_reference);
}
current_namespace = ns;
var attributes = get_attributes (ns.name);
if (attributes != null) {
foreach (string attr in attributes) {
......@@ -192,6 +231,8 @@ public class Vala.GIdlParser : CodeVisitor {
}
}
current_namespace = null;
if (sym is Namespace) {
return null;
}
......@@ -609,9 +650,14 @@ public class Vala.GIdlParser : CodeVisitor {
}
private void parse_type_string (TypeReference! type, string! n) {
// Generated GIDL misses explicit namespace specifier,
// so try to guess namespace
if (n.has_prefix ("H") || n.has_suffix ("Class") || n == "va_list" || n.has_prefix ("LOGFONT") || n.has_prefix ("xml")) {
var dt = cname_type_map[n];
if (dt != null) {
type.namespace_name = dt.parent_symbol.name;
type.type_name = dt.name;
return;
}
if (n == "HFONT" || n == "HGLOBAL" || n == "GStaticRecMutex" || n.has_suffix ("Class") || n == "va_list" || n.has_prefix ("LOGFONT") || n.has_prefix ("xml") || n == "GdkNativeWindow" || n == "GdkXEvent" || n == "GtkTextLayout" || n == "GstClockID" || n.has_prefix ("GstXml")) {
// unsupported
type.type_name = "pointer";
} else if (n.has_prefix ("cairo")) {
......@@ -624,80 +670,28 @@ public class Vala.GIdlParser : CodeVisitor {
type.namespace_name = null;
type.type_name = "pointer";
}
} else if (n.has_prefix ("Atk")) {
type.namespace_name = "Atk";
type.type_name = n.offset ("Atk".len ());
if (type.type_name == "AttributeSet") {
} else if (n == "AtkAttributeSet") {
type.namespace_name = "GLib";
type.type_name = "SList";
}
} else if (n.has_prefix ("Gst")) {
type.namespace_name = "Gst";
type.type_name = n.offset ("Gst".len ());
if (type.type_name == "ClockTime") {
type.namespace_name = null;
} else if (n == "GstClockTime") {
type.type_name = "uint64";
} else if (type.type_name == "ClockTimeDiff") {
type.namespace_name = null;
} else if (n == "GstClockTimeDiff") {
type.type_name = "int64";
} else if (type.type_name == "ClockID" || type.type_name.has_prefix ("Xml")) {
type.namespace_name = null;
type.type_name = "pointer";
}
} else if (n.has_prefix ("Gtk")) {
type.namespace_name = "Gtk";
type.type_name = n.offset ("Gtk".len ());
if (type.type_name == "TextLayout") {
type.namespace_name = null;
type.type_name = "pointer";
}
} else if (n.has_prefix ("Gdk")) {
type.namespace_name = "Gdk";
type.type_name = n.offset ("Gdk".len ());
if (type.type_name == "NativeWindow" || type.type_name == "XEvent") {
type.namespace_name = null;
type.type_name = "pointer";
}
} else if (n.has_prefix ("Pango")) {
type.namespace_name = "Pango";
type.type_name = n.offset ("Pango".len ());
if (type.type_name == "Glyph") {
type.namespace_name = null;
} else if (n == "PangoGlyph") {
type.type_name = "uint";
} else if (type.type_name == "GlyphUnit") {
type.namespace_name = null;
} else if (n == "PangoGlyphUnit") {
type.type_name = "int";
}
} else if (n.has_prefix ("Vte")) {
type.namespace_name = "Vte";
type.type_name = n.offset ("Vte".len ());
} else if (n.has_prefix ("Clutter")) {
type.namespace_name = "Clutter";
type.type_name = n.offset ("Clutter".len ());
if (type.type_name == "Fixed") {
type.namespace_name = null;
} else if (n == "ClutterFixed" || n == "ClutterUnit" || n == "ClutterAngle") {
type.type_name = "int32";
} else if (type.type_name == "Unit") {
type.namespace_name = null;
type.type_name = "int32";
} else if (type.type_name == "Angle") {
type.namespace_name = null;
type.type_name = "int32";
}
} else if (n.has_prefix ("Goo")) {
type.namespace_name = "Goo";
type.type_name = n.offset ("Goo".len ());
} else if (n.has_prefix ("G")) {
type.namespace_name = "GLib";
type.type_name = n.offset ("G".len ());
if (type.type_name == "Strv") {
type.namespace_name = null;
} else if (n == "GStrv") {
type.type_name = "string";
type.array_rank = 1;
} else if (type.type_name == "StaticRecMutex") {
type.namespace_name = null;
type.type_name = "pointer";
}
} else if (n.has_prefix (current_namespace.name)) {
type.namespace_name = current_namespace.name;
type.type_name = n.offset (current_namespace.name.len ());
} else if (n.has_prefix ("G")) {
type.namespace_name = "GLib";
type.type_name = n.offset (1);
} else {
var name_parts = n.split (".", 2);
if (name_parts[1] == null) {
......
......@@ -132,15 +132,15 @@ class Vala.VAPIGen {
return quit ();
}
var gidlparser = new GIdlParser ();
gidlparser.parse (context);
var attributeprocessor = new AttributeProcessor ();
attributeprocessor.process (context);
if (Report.get_errors () > 0) {
return quit ();
}
var attributeprocessor = new AttributeProcessor ();
attributeprocessor.process (context);
var gidlparser = new GIdlParser ();
gidlparser.parse (context);
if (Report.get_errors () > 0) {
return quit ();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment