Commit af384685 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

write cprefix and lower_case_cprefix of namespaces and write

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

	* vala/valainterfacewriter.vala: write cprefix and lower_case_cprefix
	  of namespaces and write cheader_filename of interfaces
	* vala/valanamespace.vala: make set_cprefix and set_lower_case_cprefix
	  methods public
	* ccode/valaccodewriter.vala, vala/valainterfacewriter.vala,
	  gobject/valaccodecompiler.vala, compiler/valacompiler.vala,
	  vapi/glib-2.0.vala, vapigen/valagidlparser.vala,
	  vapigen/valavapigen.vala: split GLib.File into GLib.FileStream and
	  GLib.FileUtils to not conflict with GVFS
	* vala/valagidlparser.vala: improve support for GVFS
	* vapi/atk.vala, vapi/gdk-2.0.vala, vapi/gtk+-2.0.vala, vapi/pango.vala:
	  regenerated
	* vapi/gio-standalone.vala, vapi/packages/gio-standalone/: add
	  experimental VAPI for GVFS
	* vapi/Makefile.am: update

svn path=/trunk/; revision=328
parent a831e537
2007-07-03 Jürg Billeter <j@bitron.ch>
* vala/valainterfacewriter.vala: write cprefix and lower_case_cprefix
of namespaces and write cheader_filename of interfaces
* vala/valanamespace.vala: make set_cprefix and set_lower_case_cprefix
methods public
* ccode/valaccodewriter.vala, vala/valainterfacewriter.vala,
gobject/valaccodecompiler.vala, compiler/valacompiler.vala,
vapi/glib-2.0.vala, vapigen/valagidlparser.vala,
vapigen/valavapigen.vala: split GLib.File into GLib.FileStream and
GLib.FileUtils to not conflict with GVFS
* vala/valagidlparser.vala: improve support for GVFS
* vapi/atk.vala, vapi/gdk-2.0.vala, vapi/gtk+-2.0.vala, vapi/pango.vala:
regenerated
* vapi/gio-standalone.vala, vapi/packages/gio-standalone/: add
experimental VAPI for GVFS
* vapi/Makefile.am: update
2007-07-01 Jürg Billeter <j@bitron.ch>
* vapi/glib-2.0.vala: add more string utility functions and GDate
......
/* valaccodewriter.vala
*
* Copyright (C) 2006 Jürg Billeter
* Copyright (C) 2006-2007 Jürg Billeter
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -35,12 +35,12 @@ public class Vala.CCodeWriter {
}
construct {
_filename = value;
file_exists = File.test (_filename, FileTest.EXISTS);
file_exists = FileUtils.test (_filename, FileTest.EXISTS);
if (file_exists) {
temp_filename = "%s.valatmp".printf (_filename);
stream = File.open (temp_filename, "w");
stream = FileStream.open (temp_filename, "w");
} else {
stream = File.open (_filename, "w");
stream = FileStream.open (_filename, "w");
}
}
}
......@@ -58,7 +58,7 @@ public class Vala.CCodeWriter {
private string temp_filename;
private bool file_exists;
private File stream;
private FileStream stream;
private int indent;
......@@ -90,9 +90,9 @@ public class Vala.CCodeWriter {
new_file = null;
if (changed) {
File.rename (temp_filename, _filename);
FileUtils.rename (temp_filename, _filename);
} else {
File.unlink (temp_filename);
FileUtils.unlink (temp_filename);
}
}
}
......
......@@ -78,24 +78,24 @@ class Vala.Compiler {
if (vapi_directories != null) {
foreach (string vapidir in vapi_directories) {
var filename = Path.build_filename (vapidir, basename);
if (File.test (filename, FileTest.EXISTS)) {
if (FileUtils.test (filename, FileTest.EXISTS)) {
return filename;
}
}
}
string filename = Path.build_filename (Config.PACKAGE_DATADIR, "vapi", basename);
if (File.test (filename, FileTest.EXISTS)) {
if (FileUtils.test (filename, FileTest.EXISTS)) {
return filename;
}
filename = Path.build_filename ("/usr/local/share/vala/vapi", basename);
if (File.test (filename, FileTest.EXISTS)) {
if (FileUtils.test (filename, FileTest.EXISTS)) {
return filename;
}
filename = Path.build_filename ("/usr/share/vala/vapi", basename);
if (File.test (filename, FileTest.EXISTS)) {
if (FileUtils.test (filename, FileTest.EXISTS)) {
return filename;
}
......@@ -119,9 +119,9 @@ class Vala.Compiler {
context.add_source_file (new SourceFile (context, package_path, true));
var deps_filename = Path.build_filename (Path.get_dirname (package_path), "%s.deps".printf (pkg));
if (File.test (deps_filename, FileTest.EXISTS)) {
if (FileUtils.test (deps_filename, FileTest.EXISTS)) {
string deps_content;
File.get_contents (deps_filename, out deps_content, null, null);
FileUtils.get_contents (deps_filename, out deps_content, null, null);
foreach (string dep in deps_content.split ("\n")) {
if (dep != "") {
if (!add_package (context, dep)) {
......@@ -172,7 +172,7 @@ class Vala.Compiler {
}
foreach (string source in sources) {
if (File.test (source, FileTest.EXISTS)) {
if (FileUtils.test (source, FileTest.EXISTS)) {
context.add_source_file (new SourceFile (context, source));
} else {
Report.error (null, "%s not found".printf (source));
......
......@@ -81,8 +81,8 @@ public class Vala.CCodeCompiler {
/* remove generated C source and header files */
foreach (SourceFile file in source_files) {
if (!file.pkg) {
File.unlink (file.get_csource_filename ());
File.unlink (file.get_cheader_filename ());
FileUtils.unlink (file.get_csource_filename ());
FileUtils.unlink (file.get_cheader_filename ());
}
}
......
......@@ -29,7 +29,7 @@ using GLib;
public class Vala.InterfaceWriter : CodeVisitor {
private CodeContext context;
File stream;
FileStream stream;
int indent;
/* at begin of line */
......@@ -47,7 +47,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
public void write_file (CodeContext! context, string! filename) {
this.context = context;
stream = File.open (filename, "w");
stream = FileStream.open (filename, "w");
/* we're only interested in non-pkg source files */
foreach (SourceFile file in context.get_source_files ()) {
......@@ -72,7 +72,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
current_cheader_filename = ns.get_cheader_filename ();
write_indent ();
write_string ("[CCode (cheader_filename = \"%s\")]".printf (current_cheader_filename));
write_string ("[CCode (cprefix = \"%s\", lower_case_cprefix = \"%s\", cheader_filename = \"%s\")]".printf (ns.get_cprefix (), ns.get_lower_case_cprefix (), current_cheader_filename));
write_newline ();
write_indent ();
......@@ -161,7 +161,22 @@ public class Vala.InterfaceWriter : CodeVisitor {
if (iface.access == MemberAccessibility.PRIVATE) {
return;
}
write_indent ();
var first = true;
string cheaders;
foreach (string cheader in iface.get_cheader_filenames ()) {
if (first) {
cheaders = cheader;
first = false;
} else {
cheaders = "%s, %s".printf (cheaders, cheader);
}
}
write_string ("[CCode (cheader_filename = \"%s\")]".printf (cheaders));
write_newline ();
write_indent ();
write_string ("public ");
write_string ("interface ");
......
......@@ -282,11 +282,17 @@ public class Vala.Namespace : CodeNode {
}
return cprefix;
}
private void set_cprefix (string cprefix) {
/**
* Sets the camel case string to be prepended to the name of members of
* this namespace when used in C code.
*
* @param cprefix the camel case prefix to be used in C code
*/
public void set_cprefix (string cprefix) {
this.cprefix = cprefix;
}
/**
* Returns the lower case string to be prepended to the name of members
* of this namespace when used in C code.
......@@ -303,11 +309,17 @@ public class Vala.Namespace : CodeNode {
}
return lower_case_cprefix;
}
private void set_lower_case_cprefix (string cprefix) {
/**
* Sets the lower case string to be prepended to the name of members of
* this namespace when used in C code.
*
* @param cprefix the lower case prefix to be used in C code
*/
public void set_lower_case_cprefix (string cprefix) {
this.lower_case_cprefix = cprefix;
}
/**
* Returns a list of C header filenames users of this namespace must
* include.
......
......@@ -11,6 +11,7 @@ dist_vapi_DATA = \
glib-2.0.vala \
gdk-2.0.deps \
gdk-2.0.vala \
gio-standalone.vala \
gtk+-2.0.deps \
gtk+-2.0.vala \
libxml-2.0.vala \
......
[CCode (cheader_filename = "atk/atk.h")]
[CCode (cprefix = "Atk", lower_case_cprefix = "atk_", cheader_filename = "atk/atk.h")]
namespace Atk {
[CCode (cprefix = "ATK_XY_")]
public enum CoordType {
......@@ -397,6 +397,7 @@ namespace Atk {
public class Util : GLib.Object {
public static GLib.Type get_type ();
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Action {
public virtual bool do_action (int i);
public virtual weak string get_description (int i);
......@@ -407,6 +408,7 @@ namespace Atk {
public static GLib.Type get_type ();
public virtual bool set_description (int i, string desc);
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Component {
public virtual uint add_focus_handler (Atk.FocusHandler handler);
public virtual bool contains (int x, int y, Atk.CoordType coord_type);
......@@ -425,6 +427,7 @@ namespace Atk {
public virtual bool set_size (int width, int height);
public signal void bounds_changed (ref Atk.Rectangle bounds);
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Document {
public weak string get_attribute_value (string attribute_name);
public weak GLib.SList get_attributes ();
......@@ -437,6 +440,7 @@ namespace Atk {
public signal void reload ();
public signal void load_stopped ();
}
[CCode (cheader_filename = "atk/atk.h")]
public interface EditableText {
public virtual void copy_text (int start_pos, int end_pos);
public virtual void cut_text (int start_pos, int end_pos);
......@@ -447,10 +451,12 @@ namespace Atk {
public virtual bool set_run_attributes (GLib.SList attrib_set, int start_offset, int end_offset);
public virtual void set_text_contents (string string);
}
[CCode (cheader_filename = "atk/atk.h")]
public interface HyperlinkImpl {
public virtual weak Atk.Hyperlink get_hyperlink ();
public static GLib.Type get_type ();
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Hypertext {
public virtual weak Atk.Hyperlink get_link (int link_index);
public virtual int get_link_index (int char_index);
......@@ -458,6 +464,7 @@ namespace Atk {
public static GLib.Type get_type ();
public signal void link_selected (int link_index);
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Image {
public virtual weak string get_image_description ();
public virtual weak string get_image_locale ();
......@@ -466,10 +473,12 @@ namespace Atk {
public static GLib.Type get_type ();
public virtual bool set_image_description (string description);
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Implementor {
public static GLib.Type get_type ();
public virtual weak Atk.Object ref_accessible ();
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Selection {
public virtual bool add_selection (int i);
public virtual bool clear_selection ();
......@@ -481,6 +490,7 @@ namespace Atk {
public virtual bool select_all_selection ();
public signal void selection_changed ();
}
[CCode (cheader_filename = "atk/atk.h")]
public interface StreamableContent {
public virtual weak string get_mime_type (int i);
public virtual int get_n_mime_types ();
......@@ -488,6 +498,7 @@ namespace Atk {
public static GLib.Type get_type ();
public virtual weak string get_uri (string mime_type);
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Table {
public virtual bool add_column_selection (int column);
public virtual bool add_row_selection (int row);
......@@ -527,6 +538,7 @@ namespace Atk {
public signal void column_reordered ();
public signal void model_changed ();
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Text {
public virtual bool add_selection (int start_offset, int end_offset);
public static Atk.TextAttribute attribute_for_name (string name);
......@@ -558,6 +570,7 @@ namespace Atk {
public signal void text_selection_changed ();
public signal void text_attributes_changed ();
}
[CCode (cheader_filename = "atk/atk.h")]
public interface Value {
public virtual void get_current_value (GLib.Value value);
public virtual void get_maximum_value (GLib.Value value);
......
[CCode (cheader_filename = "gdk/gdk.h")]
[CCode (cprefix = "Gdk", lower_case_cprefix = "gdk_", cheader_filename = "gdk/gdk.h")]
namespace Gdk {
[CCode (cprefix = "GDK_AXIS_")]
public enum AxisUse {
......
This diff is collapsed.
......@@ -1285,14 +1285,14 @@ namespace GLib {
IS_EXECUTABLE,
EXISTS
}
[ReferenceType (free_function = "fclose")]
[CCode (cname = "FILE", cheader_filename = "stdio.h,glib/gstdio.h")]
public struct File {
[CCode (cname = "FILE", cheader_filename = "stdio.h")]
public struct FileStream {
[CCode (cname = "fopen")]
public static ref File open (string path, string mode);
public static FileStream open (string path, string mode);
[CCode (cname = "fdopen")]
public static ref File fdopen (int fildes, string mode);
public static FileStream fdopen (int fildes, string mode);
[CCode (cname = "fprintf")]
[PrintfFormat ()]
public void printf (string format, ...);
......@@ -1304,7 +1304,10 @@ namespace GLib {
public void puts (string s);
[CCode (cname = "fclose")]
public void close ();
}
[CCode (cprefix = "g_file_", cheader_filename = "glib/gstdio.h")]
public struct FileUtils {
public static bool get_contents (string! filename, out string contents, ref long length, out Error error);
public static bool set_contents (string! filename, string contents, long length, out Error error);
public static bool test (string filename, FileTest test);
......@@ -1319,7 +1322,7 @@ namespace GLib {
[CCode (cname = "symlink")]
public static int symlink (string! oldpath, string! newpath);
}
[ReferenceType (free_function = "g_dir_close")]
public struct Dir {
public static ref Dir open (string filename, uint _flags, out Error error);
......@@ -1349,10 +1352,10 @@ namespace GLib {
}
[CCode (cname = "stdout", cheader_filename = "stdio.h")]
public static File stdout;
public static FileStream stdout;
[CCode (cname = "stderr", cheader_filename = "stdio.h")]
public static File stderr;
public static FileStream stderr;
/* Shell-related Utilities */
......
[CCode (cheader_filename = "gtk/gtk.h")]
[CCode (cprefix = "Gtk", lower_case_cprefix = "gtk_", cheader_filename = "gtk/gtk.h")]
namespace Gtk {
[CCode (cprefix = "GTK_ACCEL_")]
public enum AccelFlags {
......@@ -4915,6 +4915,7 @@ namespace Gtk {
public WindowGroup ();
public void remove_window (Gtk.Window window);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface Buildable {
public virtual void add_child (Gtk.Builder builder, GLib.Object child, string type);
public virtual weak GLib.Object construct_child (Gtk.Builder builder, string name);
......@@ -4928,6 +4929,7 @@ namespace Gtk {
public virtual void set_buildable_property (Gtk.Builder builder, string name, GLib.Value value);
public virtual void set_name (string name);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface CellEditable {
public static GLib.Type get_type ();
[HasEmitter]
......@@ -4935,6 +4937,7 @@ namespace Gtk {
[HasEmitter]
public signal void remove_widget ();
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface CellLayout {
public virtual void add_attribute (Gtk.CellRenderer cell, string attribute, int column);
public virtual void clear ();
......@@ -4947,6 +4950,7 @@ namespace Gtk {
public void set_attributes (Gtk.CellRenderer cell);
public virtual void set_cell_data_func (Gtk.CellRenderer cell, Gtk.CellLayoutDataFunc func, pointer func_data, GLib.DestroyNotify destroy);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface Editable {
public void copy_clipboard ();
public void cut_clipboard ();
......@@ -4966,6 +4970,7 @@ namespace Gtk {
public signal void delete_text (int start_pos, int end_pos);
public signal void changed ();
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface FileChooser {
public void add_filter (Gtk.FileFilter filter);
public bool add_shortcut_folder (string folder, GLib.Error error);
......@@ -5018,6 +5023,7 @@ namespace Gtk {
public void unselect_filename (string filename);
public void unselect_uri (string uri);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface PrintOperationPreview {
public virtual void end_preview ();
public static GLib.Type get_type ();
......@@ -5026,6 +5032,7 @@ namespace Gtk {
public signal void ready (Gtk.PrintContext context);
public signal void got_page_size (Gtk.PrintContext context, Gtk.PageSetup page_setup);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface RecentChooser {
public virtual void add_filter (Gtk.RecentFilter filter);
public static GLib.Quark error_quark ();
......@@ -5065,17 +5072,20 @@ namespace Gtk {
public signal void selection_changed ();
public signal void item_activated ();
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface TreeDragDest {
public virtual bool drag_data_received (Gtk.TreePath dest, Gtk.SelectionData selection_data);
public static GLib.Type get_type ();
public virtual bool row_drop_possible (Gtk.TreePath dest_path, Gtk.SelectionData selection_data);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface TreeDragSource {
public virtual bool drag_data_delete (Gtk.TreePath path);
public virtual bool drag_data_get (Gtk.TreePath path, Gtk.SelectionData selection_data);
public static GLib.Type get_type ();
public virtual bool row_draggable (Gtk.TreePath path);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface TreeModel {
public void @foreach (Gtk.TreeModelForeachFunc func, pointer user_data);
public void get (ref Gtk.TreeIter iter, ...);
......@@ -5109,6 +5119,7 @@ namespace Gtk {
[HasEmitter]
public signal void rows_reordered (Gtk.TreePath path, ref Gtk.TreeIter iter, int new_order);
}
[CCode (cheader_filename = "gtk/gtk.h")]
public interface TreeSortable {
public virtual bool get_sort_column_id (int sort_column_id, Gtk.SortType order);
public static GLib.Type get_type ();
......@@ -6316,7 +6327,7 @@ namespace Gtk {
public static void show_about_dialog (Gtk.Window parent, string first_property_name, ...);
public static void text_layout_draw (pointer layout, Gtk.Widget widget, Gdk.Drawable drawable, Gdk.GC cursor_gc, int x_offset, int y_offset, int x, int y, int width, int height, GLib.List widgets);
}
[CCode (cheader_filename = "gtk/gtk.h")]
[CCode (cprefix = "Gtk", lower_case_cprefix = "gtk_", cheader_filename = "gtk/gtk.h")]
namespace Gtk {
public struct Allocation {
public int x;
......
This diff is collapsed.
GLib cprefix="G" lower_case_cprefix="g_" cheader_filename="gio/gvfs.h"
GFile cheader_filename="gio/gfile.h"
GMountOperation::reply has_emitter="1"
[CCode (cheader_filename = "pango/pango.h")]
[CCode (cprefix = "Pango", lower_case_cprefix = "pango_", cheader_filename = "pango/pango.h")]
namespace Pango {
[CCode (cprefix = "PANGO_ALIGN_")]
public enum Alignment {
......@@ -806,7 +806,7 @@ namespace Pango {
public static bool parse_variant (string str, Pango.Variant variant, bool warn);
public static bool parse_weight (string str, Pango.Weight weight, bool warn);
public static void quantize_line_geometry (int thickness, int position);
public static int read_line (GLib.File stream, GLib.String str);
public static int read_line (GLib.FileStream stream, GLib.String str);
public static weak GLib.List reorder_items (GLib.List logical_items);
public static bool scan_int (string pos, int @out);
public static bool scan_string (string pos, GLib.String @out);
......
......@@ -56,9 +56,9 @@ public class Vala.GIdlParser : CodeVisitor {
codenode_attributes_map = new HashTable.full (str_hash, str_equal, g_free, g_free);
if (File.test (metadata_filename, FileTest.EXISTS)) {
if (FileUtils.test (metadata_filename, FileTest.EXISTS)) {
string metadata;
File.get_contents (metadata_filename, out metadata, null, out error);
FileUtils.get_contents (metadata_filename, out metadata, null, out error);
foreach (string line in metadata.split ("\n")) {
var line_parts = line.split (" ", 2);
......@@ -83,8 +83,26 @@ public class Vala.GIdlParser : CodeVisitor {
source_file.add_namespace (ns);
}
}
private ref Namespace parse_module (IdlModule! module) {
private string! fix_type_name (string! type_name, IdlModule! module) {
if (type_name.has_prefix (module.name)) {
return type_name.offset (module.name.len ());
} else if (module.name == "GLib" && type_name.has_prefix ("G")) {
return type_name.offset (1);
}
return type_name;
}
private string! fix_const_name (string! const_name, IdlModule! module) {
if (const_name.has_prefix (module.name.up () + "_")) {
return const_name.offset (module.name.len () + 1);
} else if (module.name == "GLib" && const_name.has_prefix ("G_")) {
return const_name.offset (2);
}
return const_name;
}
private Namespace parse_module (IdlModule! module) {
var ns = new Namespace (module.name, current_source_reference);
var attributes = get_attributes (ns.name);
......@@ -93,6 +111,10 @@ public class Vala.GIdlParser : CodeVisitor {
var nv = attr.split ("=", 2);
if (nv[0] == "cheader_filename") {
ns.set_cheader_filename (eval (nv[1]));
} else if (nv[0] == "cprefix") {
ns.set_cprefix (eval (nv[1]));
} else if (nv[0] == "lower_case_cprefix") {
ns.set_lower_case_cprefix (eval (nv[1]));
}
}
}
......@@ -103,49 +125,35 @@ public class Vala.GIdlParser : CodeVisitor {
if (cb == null) {
continue;
}
if (cb.name.has_prefix (module.name)) {
cb.name = cb.name.offset (module.name.len ());
}
cb.name = fix_type_name (cb.name, module);
ns.add_callback (cb);
} else if (node.type == IdlNodeTypeId.STRUCT) {
var st = parse_struct ((IdlNodeStruct) node);
if (st == null) {
continue;
}
if (st.name.has_prefix (module.name)) {
st.name = st.name.offset (module.name.len ());
}
st.name = fix_type_name (st.name, module);
ns.add_struct (st);
} else if (node.type == IdlNodeTypeId.BOXED) {
var st = parse_boxed ((IdlNodeBoxed) node);
if (st.name.has_prefix (module.name)) {
st.name = st.name.offset (module.name.len ());
}
st.name = fix_type_name (st.name, module);
ns.add_struct (st);
st.set_type_id (st.get_upper_case_cname ("TYPE_"));
} else if (node.type == IdlNodeTypeId.ENUM) {
var en = parse_enum ((IdlNodeEnum) node);
if (en.name.has_prefix (module.name)) {
en.name = en.name.offset (module.name.len ());
}
en.name = fix_type_name (en.name, module);
ns.add_enum (en);
} else if (node.type == IdlNodeTypeId.OBJECT) {
var cl = parse_object ((IdlNodeInterface) node);
if (cl.name.has_prefix (module.name)) {
cl.name = cl.name.offset (module.name.len ());
}
cl.name = fix_type_name (cl.name, module);
ns.add_class (cl);
} else if (node.type == IdlNodeTypeId.INTERFACE) {
var iface = parse_interface ((IdlNodeInterface) node);
if (iface.name.has_prefix (module.name)) {
iface.name = iface.name.offset (module.name.len ());
}
iface.name = fix_type_name (iface.name, module);
ns.add_interface (iface);
} else if (node.type == IdlNodeTypeId.CONSTANT) {
var c = parse_constant ((IdlNodeConstant) node);
if (c.name.has_prefix (module.name.up ())) {
c.name = c.name.offset (module.name.len () + 1);
}
c.name = fix_const_name (c.name, module);
ns.add_constant (c);
} else if (node.type == IdlNodeTypeId.FUNCTION) {
var m = parse_function ((IdlNodeFunction) node);
......@@ -389,11 +397,21 @@ public class Vala.GIdlParser : CodeVisitor {
return cl;
}
private ref Interface parse_interface (IdlNodeInterface! node) {
private Interface parse_interface (IdlNodeInterface! node) {
var iface = new Interface (node.gtype_name, current_source_reference);
iface.access = MemberAccessibility.PUBLIC;
var attributes = get_attributes (iface.name);
if (attributes != null) {
foreach (string attr in attributes) {
var nv = attr.split ("=", 2);
if (nv[0] == "cheader_filename") {
iface.add_cheader_filename (eval (nv[1]));
}
}
}
foreach (string prereq_name in node.prerequisites) {
var prereq = new TypeReference ();
parse_type_string (prereq, prereq_name);
......@@ -518,8 +536,10 @@ public class Vala.GIdlParser : CodeVisitor {
type.type_name = "ushort";
} else if (n == "gshort") {
type.type_name = "short";
} else if (n == "gconstpointer") {
} else if (n == "gconstpointer" || n == "void") {
type.type_name = "pointer";
} else if (n == "goffset") {
type.type_name = "int64";
} else if (n == "value_array") {
type.namespace_name = "GLib";
type.type_name = "ValueArray";
......@@ -529,7 +549,7 @@ public class Vala.GIdlParser : CodeVisitor {
type.type_name = "int";
} else if (n == "FILE") {
type.namespace_name = "GLib";
type.type_name = "File";
type.type_name = "FileStream";
} else {
parse_type_string (type, n);
if (type_node.is_pointer && is_value_type (n)) {
......
......@@ -61,19 +61,19 @@ class Vala.VAPIGen {
if (vapi_directories != null) {
foreach (string vapidir in vapi_directories) {
var filename = Path.build_filename (vapidir, basename, null);
if (File.test (filename, FileTest.EXISTS)) {
if (FileUtils.test (filename, FileTest.EXISTS)) {
return filename;
}
}
}
var filename = Path.build_filename ("/usr/local/share/vala/vapi", basename, null);
if (File.test (filename, FileTest.EXISTS)) {
if (FileUtils.test (filename, FileTest.EXISTS)) {
return filename;
}
filename = Path.build_filename ("/usr/share/vala/vapi", basename, null);
if (File.test (filename, FileTest.EXISTS)) {
if (FileUtils.test (filename, FileTest.EXISTS)) {
return filename;
}
......@@ -114,7 +114,7 @@ class Vala.VAPIGen {
}
foreach (string source in sources) {
if (File.test (source, FileTest.EXISTS)) {
if (FileUtils.test (source, FileTest.EXISTS)) {
context.add_source_file (new SourceFile (context, source));
} else {
Report.error (null, "%s not found".printf (source));
......
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