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

remove support for reference-type structs, improve support for non-GObject

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

	* vala/valaclass.vala, vala/valainterfacewriter.vala,
	  vala/valastruct.vala: remove support for reference-type structs,
	  improve support for non-GObject classes

	* vapigen/valagidlparser.vala, vapi/cairo.vala, vapi/curses.vala,
	  vapi/dbus-glib-1.vala, vapi/enchant.vala, vapi/hal.vala,
	  vapi/libxml-2.0.vala, vapi/sqlite3.vala,
	  vapi/packages/libsoup-2.2/libsoup-2.2-custom.vala,
	  vapi/packages/pango/pango-custom.vala: replace reference-type structs
	  by classes

	* vapi/atk.vala, vapi/gconf-2.0.vala, vapi/gdk-2.0.vala,
	  vapi/gio-standalone.vala, vapi/gnome-desktop-2.0.vala,
	  vapi/gnome-vfs-2.0.vala, vapi/gstreamer-0.10.vala, vapi/gtk+-2.0.vala,
	  vapi/gtksourceview-2.0.vala, vapi/hildon-1.vala,
	  vapi/libglade-2.0.vala, vapi/libgnome-2.0.vala,
	  vapi/libgnomeui-2.0.vala, vapi/libsoup-2.2.vala,
	  vapi/libwnck-1.0.vala, vapi/pango.vala, vapi/poppler-glib.vala,
	  vapi/vte.vala: regenerated

svn path=/trunk/; revision=545
parent 159ab187
2007-08-30 Jürg Billeter <j@bitron.ch>
* vala/valaclass.vala, vala/valainterfacewriter.vala,
vala/valastruct.vala: remove support for reference-type structs,
improve support for non-GObject classes
* vapigen/valagidlparser.vala, vapi/cairo.vala, vapi/curses.vala,
vapi/dbus-glib-1.vala, vapi/enchant.vala, vapi/hal.vala,
vapi/libxml-2.0.vala, vapi/sqlite3.vala,
vapi/packages/libsoup-2.2/libsoup-2.2-custom.vala,
vapi/packages/pango/pango-custom.vala: replace reference-type structs
by classes
* vapi/atk.vala, vapi/gconf-2.0.vala, vapi/gdk-2.0.vala,
vapi/gio-standalone.vala, vapi/gnome-desktop-2.0.vala,
vapi/gnome-vfs-2.0.vala, vapi/gstreamer-0.10.vala, vapi/gtk+-2.0.vala,
vapi/gtksourceview-2.0.vala, vapi/hildon-1.vala,
vapi/libglade-2.0.vala, vapi/libgnome-2.0.vala,
vapi/libgnomeui-2.0.vala, vapi/libsoup-2.2.vala,
vapi/libwnck-1.0.vala, vapi/pango.vala, vapi/poppler-glib.vala,
vapi/vte.vala: regenerated
2007-08-30 Jürg Billeter <j@bitron.ch>
* vala/parser.y: fix internal warnings on syntax errors
......
......@@ -449,6 +449,10 @@ public class Vala.Class : DataType {
return type_id;
}
public void set_type_id (string! type_id) {
this.type_id = type_id;
}
public override string get_marshaller_type_name () {
if (marshaller_type_name == null) {
if (base_class != null) {
......@@ -522,10 +526,7 @@ public class Vala.Class : DataType {
}
public string get_default_free_function () {
if (default_construction_method != null) {
return get_lower_case_cprefix () + "free";
}
return null;
return get_lower_case_cprefix () + "free";
}
public override string get_free_function () {
......
......@@ -105,7 +105,25 @@ public class Vala.InterfaceWriter : CodeVisitor {
cheaders = "%s,%s".printf (cheaders, cheader);
}
}
write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders));
write_string ("[CCode (");
if (cl.is_reference_counting ()) {
if (cl.base_class == null || cl.base_class.get_ref_function () == null || cl.base_class.get_ref_function () != cl.get_ref_function ()) {
write_string ("ref_function = \"%s\", ".printf (cl.get_ref_function ()));
}
if (cl.base_class == null || cl.base_class.get_unref_function () == null || cl.base_class.get_unref_function () != cl.get_unref_function ()) {
write_string ("unref_function = \"%s\", ".printf (cl.get_unref_function ()));
}
} else {
if (cl.get_dup_function () != null) {
write_string ("copy_function = \"%s\", ".printf (cl.get_dup_function ()));
}
if (cl.get_free_function () != cl.get_default_free_function ()) {
write_string ("free_function = \"%s\", ".printf (cl.get_free_function ()));
}
}
write_string ("cheader_filename = \"%s\")]".printf (cheaders));
write_newline ();
write_indent ();
......@@ -162,28 +180,6 @@ public class Vala.InterfaceWriter : CodeVisitor {
return;
}
if (st.is_reference_type ()) {
write_indent ();
write_string ("[ReferenceType");
string copy_func = st.get_dup_function ();
string free_func = st.get_free_function ();
string default_free_func = st.get_default_free_function ();
if (copy_func != null || (free_func != null && (default_free_func == null || default_free_func != free_func))) {
write_string (" (");
if (copy_func != null) {
write_string ("dup_function = \"%s\"".printf (copy_func));
if (free_func != null) {
write_string (", ");
}
}
if (free_func != null) {
write_string ("free_function = \"%s\"".printf (free_func));
}
write_string (")");
}
write_string ("]");
}
write_indent ();
var first = true;
......
......@@ -41,7 +41,6 @@ public class Vala.Struct : DataType {
private string type_id;
private string lower_case_cprefix;
private string lower_case_csuffix;
private bool reference_type;
private bool integer_type;
private bool floating_type;
private int rank;
......@@ -200,11 +199,7 @@ public class Vala.Struct : DataType {
public override string get_upper_case_cname (string infix) {
return get_lower_case_cname (infix).up ();
}
public override bool is_reference_type () {
return reference_type;
}
/**
* Returns whether this is an integer type.
*
......@@ -231,16 +226,7 @@ public class Vala.Struct : DataType {
public int get_rank () {
return rank;
}
/**
* Sets whether this data type has value or reference type semantics.
*
* @param ref_type true if this data type has reference type semantics
*/
public void set_is_reference_type (bool ref_type) {
reference_type = ref_type;
}
private void process_ccode_attribute (Attribute! a) {
if (a.has_argument ("cname")) {
set_cname (a.get_string ("cname"));
......@@ -273,17 +259,7 @@ public class Vala.Struct : DataType {
set_default_value (a.get_string ("default_value"));
}
}
private void process_ref_type_attribute (Attribute! a) {
reference_type = true;
if (a.has_argument ("dup_function")) {
set_dup_function (a.get_string ("dup_function"));
}
if (a.has_argument ("free_function")) {
set_free_function (a.get_string ("free_function"));
}
}
private void process_integer_type_attribute (Attribute! a) {
integer_type = true;
if (a.has_argument ("rank")) {
......@@ -305,8 +281,6 @@ public class Vala.Struct : DataType {
foreach (Attribute a in attributes) {
if (a.name == "CCode") {
process_ccode_attribute (a);
} else if (a.name == "ReferenceType") {
process_ref_type_attribute (a);
} else if (a.name == "IntegerType") {
process_integer_type_attribute (a);
} else if (a.name == "FloatingType") {
......@@ -315,36 +289,6 @@ public class Vala.Struct : DataType {
}
}
public override bool is_reference_counting () {
return false;
}
public override string get_dup_function () {
return dup_function;
}
public void set_dup_function (string! name) {
this.dup_function = name;
}
public string get_default_free_function () {
if (default_construction_method != null) {
return get_lower_case_cprefix () + "free";
}
return null;
}
public override string get_free_function () {
if (free_function == null) {
free_function = get_default_free_function ();
}
return free_function;
}
public void set_free_function (string! name) {
this.free_function = name;
}
public override string get_type_id () {
if (type_id == null) {
if (is_reference_type ()) {
......@@ -362,11 +306,7 @@ public class Vala.Struct : DataType {
public override string get_marshaller_type_name () {
if (marshaller_type_name == null) {
if (is_reference_type ()) {
marshaller_type_name = "POINTER";
} else {
Report.error (source_reference, "The type `%s` doesn't declare a marshaller type name".printf (get_full_name ()));
}
Report.error (source_reference, "The type `%s` doesn't declare a marshaller type name".printf (get_full_name ()));
}
return marshaller_type_name;
}
......@@ -377,12 +317,8 @@ public class Vala.Struct : DataType {
public override string get_get_value_function () {
if (get_value_function == null) {
if (is_reference_type ()) {
return "g_value_get_pointer";
} else {
Report.error (source_reference, "The value type `%s` doesn't declare a GValue get function".printf (get_full_name ()));
return null;
}
Report.error (source_reference, "The value type `%s` doesn't declare a GValue get function".printf (get_full_name ()));
return null;
} else {
return get_value_function;
}
......@@ -390,12 +326,8 @@ public class Vala.Struct : DataType {
public override string get_set_value_function () {
if (set_value_function == null) {
if (is_reference_type ()) {
return "g_value_set_pointer";
} else {
Report.error (source_reference, "The value type `%s` doesn't declare a GValue set function".printf (get_full_name ()));
return null;
}
Report.error (source_reference, "The value type `%s` doesn't declare a GValue set function".printf (get_full_name ()));
return null;
} else {
return set_value_function;
}
......
......@@ -400,6 +400,53 @@ namespace Atk {
public static GLib.Type get_type ();
}
[CCode (cheader_filename = "atk/atk.h")]
public class Attribute {
public weak string name;
public weak string value;
public static void set_free (GLib.SList attrib_set);
}
[CCode (cheader_filename = "atk/atk.h")]
public class KeyEventStruct {
public int type;
public uint state;
public uint keyval;
public int length;
public weak string string;
public ushort keycode;
public uint timestamp;
}
[CCode (cheader_filename = "atk/atk.h")]
public class PropertyValues {
public weak string property_name;
public weak GLib.Value old_value;
public weak GLib.Value new_value;
}
[CCode (cheader_filename = "atk/atk.h")]
public class TextRange {
public weak Atk.TextRectangle bounds;
public int start_offset;
public int end_offset;
public weak string content;
}
[CCode (cheader_filename = "atk/atk.h")]
public class TextRectangle {
public int x;
public int y;
public int width;
public int height;
}
[CCode (cheader_filename = "atk/atk.h")]
public class Focus {
public static void tracker_init (Atk.EventListenerInit init);
public static void tracker_notify (Atk.Object object);
}
[CCode (cheader_filename = "atk/atk.h")]
public class State {
public static Atk.StateType type_for_name (string name);
public static weak string type_get_name (Atk.StateType type);
public static Atk.StateType type_register (string name);
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Action {
public abstract bool do_action (int i);
public abstract weak string get_description (int i);
......@@ -581,31 +628,6 @@ namespace Atk {
public static GLib.Type get_type ();
public abstract bool set_current_value (GLib.Value value);
}
[ReferenceType]
[CCode (cheader_filename = "atk/atk.h")]
public struct Attribute {
public weak string name;
public weak string value;
public static void set_free (GLib.SList attrib_set);
}
[ReferenceType]
[CCode (cheader_filename = "atk/atk.h")]
public struct KeyEventStruct {
public int type;
public uint state;
public uint keyval;
public int length;
public weak string string;
public ushort keycode;
public uint timestamp;
}
[ReferenceType]
[CCode (cheader_filename = "atk/atk.h")]
public struct PropertyValues {
public weak string property_name;
public weak GLib.Value old_value;
public weak GLib.Value new_value;
}
[CCode (cheader_filename = "atk/atk.h")]
public struct Rectangle {
public int x;
......@@ -614,35 +636,6 @@ namespace Atk {
public int height;
public static GLib.Type get_type ();
}
[ReferenceType]
[CCode (cheader_filename = "atk/atk.h")]
public struct TextRange {
public weak Atk.TextRectangle bounds;
public int start_offset;
public int end_offset;
public weak string content;
}
[ReferenceType]
[CCode (cheader_filename = "atk/atk.h")]
public struct TextRectangle {
public int x;
public int y;
public int width;
public int height;
}
[ReferenceType]
[CCode (cheader_filename = "atk/atk.h")]
public struct Focus {
public static void tracker_init (Atk.EventListenerInit init);
public static void tracker_notify (Atk.Object object);
}
[ReferenceType]
[CCode (cheader_filename = "atk/atk.h")]
public struct State {
public static Atk.StateType type_for_name (string name);
public static weak string type_get_name (Atk.StateType type);
public static Atk.StateType type_register (string name);
}
public static delegate void EventListener (Atk.Object obj);
public static delegate void EventListenerInit ();
public static delegate void FocusHandler (Atk.Object arg1, bool arg2);
......
......@@ -22,9 +22,8 @@
[CCode (cheader_filename = "cairo.h")]
namespace Cairo {
[ReferenceType (dup_function = "cairo_reference", free_function = "cairo_destroy")]
[CCode (cname = "cairo_t", cprefix = "cairo_", cheader_filename = "cairo.h")]
public struct Context {
[CCode (ref_function = "cairo_reference", unref_function = "cairo_destroy", cname = "cairo_t", cprefix = "cairo_", cheader_filename = "cairo.h")]
public class Context {
[CCode (cname = "cairo_create")]
public Context (Surface target);
public Status status ();
......@@ -197,9 +196,8 @@ namespace Cairo {
SATURATE
}
[ReferenceType (free_function = "cairo_path_destroy")]
[CCode (cname = "cairo_path_t")]
public struct Path {
[CCode (free_function = "cairo_path_destroy", cname = "cairo_path_t")]
public class Path {
public Status status;
[NoArrayLength ()]
public PathData[] data;
......@@ -230,9 +228,8 @@ namespace Cairo {
CLOSE_PATH
}
[ReferenceType (dup_function = "cairo_pattern_reference", free_function = "cairo_pattern_destroy")]
[CCode (cname = "cairo_pattern_t")]
public struct Pattern {
[CCode (ref_function = "cairo_pattern_reference", unref_function = "cairo_pattern_destroy", cname = "cairo_pattern_t")]
public class Pattern {
public void add_color_stop_rgb (double offset, double red, double green, double blue);
public void add_color_stop_rgba (double offset, double red, double green, double blue, double alpha);
......@@ -287,9 +284,8 @@ namespace Cairo {
RADIAL
}
[ReferenceType ()]
[CCode (cname = "cairo_glyph_t")]
public struct Glyph {
public class Glyph {
}
[CCode (cname = "cairo_font_slant_t")]
......@@ -305,9 +301,8 @@ namespace Cairo {
BOLD
}
[ReferenceType (dup_function = "cairo_font_face_reference", free_function = "cairo_font_face_destroy")]
[CCode (cname = "cairo_font_face_t")]
public struct FontFace {
[CCode (ref_function = "cairo_font_face_reference", unref_function = "cairo_font_face_destroy", cname = "cairo_font_face_t")]
public class FontFace {
public Status status ();
public FontType get_type ();
}
......@@ -320,9 +315,8 @@ namespace Cairo {
ATSUI
}
[ReferenceType (dup_function = "cairo_scaled_font_reference", free_function = "cairo_scaled_font_destroy")]
[CCode (cname = "cairo_scaled_font_t")]
public struct ScaledFont {
[CCode (ref_function = "cairo_scaled_font_reference", unref_function = "cairo_scaled_font_destroy", cname = "cairo_scaled_font_t")]
public class ScaledFont {
[CCode (cname = "cairo_scaled_font_create")]
public ScaledFont (Matrix font_matrix, Matrix ctm, ref FontOptions options);
public Status status ();
......@@ -356,9 +350,8 @@ namespace Cairo {
public double y_advance;
}
[ReferenceType (dup_function = "cairo_font_options_copy", free_function = "cairo_font_options_destroy")]
[CCode (cname = "cairo_font_options_t")]
public struct FontOptions {
[CCode (copy_function = "cairo_font_options_copy", free_function = "cairo_font_options_destroy", cname = "cairo_font_options_t")]
public class FontOptions {
[CCode (cname = "cairo_font_options_create")]
public FontOptions ();
public Status status ();
......@@ -400,9 +393,8 @@ namespace Cairo {
ON
}
[ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo.h")]
public struct Surface {
[CCode (ref_function = "cairo_surface_reference", unref_function = "cairo_surface_destroy", cname = "cairo_surface_t", cheader_filename = "cairo.h")]
public class Surface {
[CCode (cname = "cairo_surface_create_similar")]
public Surface.similar (Surface! other, Content content, int width, int height);
public void finish ();
......@@ -449,9 +441,8 @@ namespace Cairo {
RGB16_565
}
[ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
[CCode (cname = "cairo_surface_t")]
public struct ImageSurface : Surface {
public class ImageSurface : Surface {
[CCode (cname = "cairo_image_surface_create")]
public ImageSurface (Format format, int width, int height);
[CCode (cname = "cairo_image_surface_create_for_data")]
......@@ -469,9 +460,8 @@ namespace Cairo {
public ImageSurface.from_png_stream (ReadFunc read_func, pointer closure);
}
[ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo-pdf.h")]
public struct PdfSurface : Surface {
public class PdfSurface : Surface {
[CCode (cname = "cairo_pdf_surface_create")]
public PdfSurface (string! filename, double width_in_points, double height_in_points);
[CCode (cname = "cairo_pdf_surface_create_for_stream")]
......@@ -484,9 +474,8 @@ namespace Cairo {
[NoArrayLength ()]
public static delegate Status WriteFunc (pointer closure, uchar[] data, uint length);
[ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo-ps.h")]
public struct PsSurface : Surface {
public class PsSurface : Surface {
[CCode (cname = "cairo_ps_surface_create")]
public PsSurface (string! filename, double width_in_points, double height_in_points);
[CCode (cname = "cairo_ps_surface_create_for_stream")]
......@@ -497,9 +486,8 @@ namespace Cairo {
public void dsc_comment (string! comment);
}
[ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo-svg.h")]
public struct SvgSurface : Surface {
public class SvgSurface : Surface {
[CCode (cname = "cairo_svg_surface_create")]
public SvgSurface (string! filename, double width_in_points, double height_in_points);
[CCode (cname = "cairo_svg_surface_create_for_stream")]
......@@ -515,9 +503,8 @@ namespace Cairo {
VERSION_1_2
}
[ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
[CCode (cname = "cairo_surface_t", cheader_filename = "cairo-xlib.h")]
public struct XlibSurface : Surface {
public class XlibSurface : Surface {
[CCode (cname = "cairo_xlib_surface_create")]
public XlibSurface (pointer dpy, int drawable, pointer visual, int width, int height);
[CCode (cname = "cairo_xlib_surface_create_for_bitmap")]
......@@ -533,9 +520,8 @@ namespace Cairo {
public int get_depth ();
}
[ReferenceType (free_function = "g_free")]
[CCode (cname = "cairo_matrix_t")]
public struct Matrix {
[CCode (free_function = "g_free", cname = "cairo_matrix_t")]
public class Matrix {
public void init (double xx, double yx, double xy, double yy, double x0, double y0);
public void init_identity ();
public void init_translate (double tx, double ty);
......
......@@ -55,9 +55,8 @@ namespace Curses {
public const int ESCDELAY;
[ReferenceType (free_function = "delwin", dup_function = "dupwin")]
[CCode (cname = "WINDOW", cprefix = "")]
public struct Window {
[CCode (copy_function = "dupwin", free_function = "delwin", cname = "WINDOW", cprefix = "")]
public class Window {
public int box(ulong verch, ulong horch);
public int clearok(bool bf);
public int copywin(Window dstwin, int sminrow, int smincol, int dminrow, int dmincol, int dmaxrow, int dmaxcol, int overlay);
......@@ -259,9 +258,8 @@ namespace Curses {
public int vline(ulong ch, int n);
}
[ReferenceType (free_function = "delscreen")]
[CCode (cname = "SCREEN", cprefix = "")]
public struct Screen {
[CCode (free_function = "delscreen", cname = "SCREEN", cprefix = "")]
public class Screen {
public void delscreen();
public static Screen newterm(string str, FileStream outfd, FileStream infd);
public weak Screen set_term();
......
......@@ -34,9 +34,8 @@ namespace DBus {
public static RawConnection get (BusType type, ref Error error);
}
[ReferenceType (dup_function = "dbus_connection_ref", free_function = "dbus_connection_unref")]
[CCode (cname = "DBusConnection")]
public struct RawConnection {
[CCode (ref_function = "dbus_connection_ref", unref_function = "dbus_connection_unref", cname = "DBusConnection")]
public class RawConnection {
[CCode (cname = "dbus_connection_setup_with_g_main")]
public void setup_with_main (GLib.MainContext context = null);
}
......@@ -98,9 +97,8 @@ namespace DBus {
}
[ReferenceType (dup_function = "dbus_g_connection_ref", free_function = "dbus_g_connection_unref")]
[CCode (cname = "DBusGConnection")]
public struct Connection {
[CCode (ref_function = "dbus_g_connection_ref", unref_function = "dbus_g_connection_unref", cname = "DBusGConnection")]
public class Connection {
}
[CCode (cname = "DBusGProxy", lower_case_csuffix = "g_proxy")]
......@@ -115,7 +113,6 @@ namespace DBus {
[CCode (cname = "DBusGProxyCallNotify")]
public static delegate void ProxyCallNotify (Proxy proxy, ProxyCall call_id, pointer user_data);
[ReferenceType]
public struct ProxyCall {
public class ProxyCall {
}
}
......@@ -3,8 +3,8 @@ namespace Enchant {
public static delegate void BrokerDescribeFn (string provider_name, string provider_desc, string provider_dll_file, pointer user_data);
public static delegate void DictDescribeFn (string lang_tag, string provider_name, string provider_desc, string provider_file, pointer user_data);
[ReferenceType (unref_function = "enchant_broker_free")]
public struct Broker {
[CCode (free_function = "enchant_broker_free")]
public class Broker {
[CCode (cname = "enchant_broker_init")]
public Broker ();
......@@ -18,8 +18,7 @@ namespace Enchant {
public weak string! get_error ();
}
[ReferenceType ()]
public struct Dict {
public class Dict {
public int check (weak string! word, long len = -1);
public weak string[] suggest (weak string! word, long len = -1); // FIXME integrate with memory manager
[NoArrayLength ()]
......
......@@ -107,9 +107,8 @@ namespace GConf {
[HasEmitter]
public signal void error (GLib.Error error);
}
[ReferenceType (dup_function = "gconf_backend_ref", free_function = "gconf_backend_unref")]
[CCode (cheader_filename = "gconf/gconf.h")]
public struct Backend {
[CCode (ref_function = "gconf_backend_ref", unref_function = "gconf_backend_unref", cheader_filename = "gconf/gconf.h")]
public class Backend {
public weak string name;
public uint refcount;