Commit 7023590e authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

Replace [Import] attribute by `extern' keyword, rename `is_imported'

2008-04-20  Juerg Billeter  <j@bitron.ch>

	* vala/valacfgbuilder.vala, vala/valaclass.vala,
	  vala/valacodecontext.vala, vala/valainterfacewriter.vala,
	  vala/valamember.vala, vala/valamemorymanager.vala,
	  vala/valamethod.vala, vala/valanamespace.vala,
	  vala/valaparser.vala, vala/valascanner.vala,
	  vala/valasemanticanalyzer.vala, vala/valasourcefile.vala,
	  vala/valasymbol.vala, vala/valatokentype.vala,
	  vala/valatypesymbol.vala, gobject/valaccodecompiler.vala,
	  gobject/valaccodegenerator.vala, gobject/valagidlwriter.vala,
	  vapigen/valagidlparser.vala, vapi/packages/gnome-keyring-1/,
	  vapi/packages/gstreamer-0.10/, vapi/packages/gtk+-2.0/,
	  vapi/packages/libgnome-menu/, vapi/packages/pango/:

	  Replace [Import] attribute by `extern' keyword, rename
	  `is_imported' property to `external' and `pkg' property to
	  `external_package' to harmonize used terms, fixes bug 480253

svn path=/trunk/; revision=1286
parent a6f64383
2008-04-20 Jürg Billeter <j@bitron.ch>
* vala/valacfgbuilder.vala, vala/valaclass.vala,
vala/valacodecontext.vala, vala/valainterfacewriter.vala,
vala/valamember.vala, vala/valamemorymanager.vala,
vala/valamethod.vala, vala/valanamespace.vala,
vala/valaparser.vala, vala/valascanner.vala,
vala/valasemanticanalyzer.vala, vala/valasourcefile.vala,
vala/valasymbol.vala, vala/valatokentype.vala,
vala/valatypesymbol.vala, gobject/valaccodecompiler.vala,
gobject/valaccodegenerator.vala, gobject/valagidlwriter.vala,
vapigen/valagidlparser.vala, vapi/packages/gnome-keyring-1/,
vapi/packages/gstreamer-0.10/, vapi/packages/gtk+-2.0/,
vapi/packages/libgnome-menu/, vapi/packages/pango/:
Replace [Import] attribute by `extern' keyword, rename
`is_imported' property to `external' and `pkg' property to
`external_package' to harmonize used terms, fixes bug 480253
2008-04-20 Jürg Billeter <j@bitron.ch>
* vapi/packages/gtk+-2.0/: fix GtkBuilderError binding
......
......@@ -59,7 +59,7 @@ public class Vala.CCodeCompiler : Object {
pc += " gthread-2.0";
}
foreach (string pkg in context.get_packages ()) {
if (package_exists(pkg))
if (package_exists (pkg))
pc += " " + pkg;
}
string pkgflags;
......@@ -106,7 +106,7 @@ public class Vala.CCodeCompiler : Object {
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
foreach (SourceFile file in source_files) {
if (!file.pkg) {
if (!file.external_package) {
cmdline += " " + Shell.quote (file.get_csource_filename ());
}
}
......@@ -126,7 +126,7 @@ public class Vala.CCodeCompiler : Object {
/* remove generated C source and header files */
foreach (SourceFile file in source_files) {
if (!file.pkg) {
if (!file.external_package) {
if (!context.save_csources)
FileUtils.unlink (file.get_csource_filename ());
if (!context.save_cheaders)
......
......@@ -263,7 +263,7 @@ public class Vala.CCodeGenerator : CodeGenerator {
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
foreach (SourceFile file in source_files) {
if (!file.pkg) {
if (!file.external_package) {
file.accept (this);
}
}
......
......@@ -63,7 +63,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_namespace (Namespace ns) {
if (ns.pkg) {
if (ns.external_package) {
return;
}
......@@ -85,7 +85,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_class (Class cl) {
if (cl.source_reference != null && cl.source_reference.file.pkg) {
if (cl.external_package) {
return;
}
......@@ -143,7 +143,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_struct (Struct st) {
if (st.source_reference != null && st.source_reference.file.pkg) {
if (st.external_package) {
return;
}
......@@ -164,7 +164,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_interface (Interface iface) {
if (iface.source_reference != null && iface.source_reference.file.pkg) {
if (iface.external_package) {
return;
}
......@@ -211,7 +211,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_enum (Enum en) {
if (en.source_reference != null && en.source_reference.file.pkg) {
if (en.external_package) {
return;
}
......@@ -238,7 +238,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_error_domain (ErrorDomain edomain) {
if (edomain.source_reference != null && edomain.source_reference.file.pkg) {
if (edomain.external_package) {
return;
}
......@@ -264,7 +264,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_constant (Constant c) {
if (c.source_reference != null && c.source_reference.file.pkg) {
if (c.external_package) {
return;
}
......@@ -277,7 +277,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_field (Field f) {
if (f.source_reference != null && f.source_reference.file.pkg) {
if (f.external_package) {
return;
}
......@@ -347,7 +347,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_delegate (Delegate cb) {
if (cb.source_reference != null && cb.source_reference.file.pkg) {
if (cb.external_package) {
return;
}
......@@ -370,7 +370,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_method (Method m) {
if (m.source_reference != null && m.source_reference.file.pkg) {
if (m.external_package) {
return;
}
......@@ -399,7 +399,7 @@ public class Vala.GIdlWriter : CodeVisitor {
}
public override void visit_creation_method (CreationMethod m) {
if (m.source_reference != null && m.source_reference.file.pkg) {
if (m.external_package) {
return;
}
......
......@@ -88,7 +88,7 @@ public class Vala.CFGBuilder : CodeVisitor {
/* we're only interested in non-pkg source files */
var source_files = context.get_source_files ();
foreach (SourceFile file in source_files) {
if (!file.pkg) {
if (!file.external_package) {
file.accept (this);
}
}
......
......@@ -264,7 +264,7 @@ public class Vala.Class : Typesymbol {
prop.this_parameter = new FormalParameter ("this", new ClassType (this));
prop.scope.add (prop.this_parameter.name, prop.this_parameter);
if (!no_field && source_reference != null && !source_reference.file.pkg) {
if (!no_field && !external_package) {
bool empty_get = (prop.get_accessor != null && prop.get_accessor.body == null);
bool empty_set = (prop.set_accessor != null && prop.set_accessor.body == null);
......
......@@ -233,7 +233,7 @@ public class Vala.CodeContext : Object {
/* find cycles in dependencies between source files */
foreach (SourceFile file in source_files) {
/* we're only interested in internal source files */
if (file.pkg) {
if (file.external_package) {
continue;
}
......@@ -255,7 +255,7 @@ public class Vala.CodeContext : Object {
*/
foreach (SourceFile file2 in source_files) {
/* we're only interested in internal source files */
if (file2.pkg) {
if (file2.external_package) {
continue;
}
......
......@@ -60,7 +60,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_namespace (Namespace ns) {
if (ns.pkg) {
if (ns.external_package) {
return;
}
......@@ -85,7 +85,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_class (Class cl) {
if (cl.source_reference != null && cl.source_reference.file.pkg) {
if (cl.external_package) {
return;
}
......@@ -178,7 +178,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_struct (Struct st) {
if (st.source_reference != null && st.source_reference.file.pkg) {
if (st.external_package) {
return;
}
......@@ -220,7 +220,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_interface (Interface iface) {
if (iface.source_reference != null && iface.source_reference.file.pkg) {
if (iface.external_package) {
return;
}
......@@ -290,7 +290,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_enum (Enum en) {
if (en.source_reference != null && en.source_reference.file.pkg) {
if (en.external_package) {
return;
}
......@@ -359,7 +359,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_error_domain (ErrorDomain edomain) {
if (edomain.source_reference != null && edomain.source_reference.file.pkg) {
if (edomain.external_package) {
return;
}
......@@ -401,7 +401,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_constant (Constant c) {
if (c.source_reference != null && c.source_reference.file.pkg) {
if (c.external_package) {
return;
}
......@@ -422,7 +422,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_field (Field f) {
if (f.source_reference != null && f.source_reference.file.pkg) {
if (f.external_package) {
return;
}
......@@ -542,7 +542,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_delegate (Delegate cb) {
if (cb.source_reference != null && cb.source_reference.file.pkg) {
if (cb.external_package) {
return;
}
......@@ -587,7 +587,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_method (Method m) {
if (m.source_reference != null && m.source_reference.file.pkg) {
if (m.external_package) {
return;
}
......
......@@ -40,7 +40,7 @@ public class Vala.Member : Symbol {
add_cheader_filename (filename);
}
if (cheader_filenames.size == 0 && source_reference != null && !source_reference.file.pkg) {
if (cheader_filenames.size == 0 && source_reference != null && !external_package) {
// don't add default include directives for VAPI files
cheader_filenames.add (source_reference.file.get_cinclude_filename ());
}
......
......@@ -58,7 +58,7 @@ public class Vala.MemoryManager : CodeVisitor {
}
public override void visit_source_file (SourceFile source_file) {
if (!source_file.pkg) {
if (!source_file.external_package) {
source_file.accept_children (this);
}
}
......
......@@ -374,8 +374,6 @@ public class Vala.Method : Member {
no_array_length = true;
} else if (a.name == "PrintfFormat") {
printf_format = true;
} else if (a.name == "Import") {
is_imported = true;
}
}
}
......
......@@ -27,11 +27,6 @@ using Gee;
* Represents a namespace declaration in the source code.
*/
public class Vala.Namespace : Symbol {
/**
* Specifies whether this namespace is only used in a VAPI package file.
*/
public bool pkg { get; set; }
private Gee.List<Class> classes = new ArrayList<Class> ();
private Gee.List<Interface> interfaces = new ArrayList<Interface> ();
private Gee.List<Struct> structs = new ArrayList<Struct> ();
......
......@@ -52,10 +52,11 @@ public class Vala.Parser : CodeVisitor {
NONE,
ABSTRACT = 1 << 0,
CLASS = 1 << 1,
INLINE = 1 << 2,
OVERRIDE = 1 << 3,
STATIC = 1 << 4,
VIRTUAL = 1 << 5
EXTERN = 1 << 2,
INLINE = 1 << 3,
OVERRIDE = 1 << 4,
STATIC = 1 << 5,
VIRTUAL = 1 << 6
}
construct {
......@@ -186,6 +187,7 @@ public class Vala.Parser : CodeVisitor {
case TokenType.ENUM:
case TokenType.ENSURES:
case TokenType.ERRORDOMAIN:
case TokenType.EXTERN:
case TokenType.FALSE:
case TokenType.FINALLY:
case TokenType.FOR:
......@@ -1751,6 +1753,7 @@ public class Vala.Parser : CodeVisitor {
case TokenType.DELEGATE:
case TokenType.ENUM:
case TokenType.ERRORDOMAIN:
case TokenType.EXTERN:
case TokenType.INLINE:
case TokenType.INTERFACE:
case TokenType.NAMESPACE:
......@@ -1792,7 +1795,6 @@ public class Vala.Parser : CodeVisitor {
expect (TokenType.NAMESPACE);
var sym = parse_symbol_name ();
var ns = new Namespace (sym.name, get_src_com (begin));
ns.pkg = scanner.source_file.pkg;
set_attributes (ns, attrs);
parse_declarations (ns);
return ns;
......@@ -1805,8 +1807,8 @@ public class Vala.Parser : CodeVisitor {
// merge if namespace already exists
var old_ns = (Namespace) ns.scope.lookup (sym.name);
var new_ns = (Namespace) sym;
if (!new_ns.pkg) {
old_ns.pkg = false;
if (old_ns.external_package && !new_ns.external_package) {
old_ns.source_reference = new_ns.source_reference;
}
foreach (Class cl in new_ns.get_classes ()) {
if (old_ns.scope.lookup (cl.name) is Class) {
......@@ -1938,7 +1940,7 @@ public class Vala.Parser : CodeVisitor {
parse_declarations (cl);
// ensure there is always a default construction method
if (!scanner.source_file.pkg
if (!scanner.source_file.external_package
&& !cl.is_static
&& cl.default_construction_method == null) {
var m = new CreationMethod (cl.name, null, cl.source_reference);
......@@ -1952,7 +1954,6 @@ public class Vala.Parser : CodeVisitor {
while (sym.inner != null) {
sym = sym.inner;
var ns = new Namespace (sym.name, cl.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
} else {
......@@ -2094,6 +2095,9 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.INLINE in flags) {
method.is_inline = true;
}
if (ModifierFlags.EXTERN in flags) {
method.external = true;
}
expect (TokenType.OPEN_PARENS);
if (current () != TokenType.CLOSE_PARENS) {
do {
......@@ -2265,7 +2269,6 @@ public class Vala.Parser : CodeVisitor {
while (sym.inner != null) {
sym = sym.inner;
var ns = new Namespace (sym.name, st.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
} else {
......@@ -2317,7 +2320,7 @@ public class Vala.Parser : CodeVisitor {
}
if (accept (TokenType.SEMICOLON)) {
iface.is_imported = true;
iface.external = true;
iface.declaration_only = true;
} else {
parse_declarations (iface);
......@@ -2327,7 +2330,6 @@ public class Vala.Parser : CodeVisitor {
while (sym.inner != null) {
sym = sym.inner;
var ns = new Namespace (sym.name, iface.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
} else {
......@@ -2408,7 +2410,6 @@ public class Vala.Parser : CodeVisitor {
while (sym.inner != null) {
sym = sym.inner;
var ns = new Namespace (sym.name, en.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
} else {
......@@ -2463,7 +2464,6 @@ public class Vala.Parser : CodeVisitor {
while (sym.inner != null) {
sym = sym.inner;
var ns = new Namespace (sym.name, ed.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
} else {
......@@ -2499,6 +2499,10 @@ public class Vala.Parser : CodeVisitor {
next ();
flags |= ModifierFlags.ABSTRACT;
break;
case TokenType.EXTERN:
next ();
flags |= ModifierFlags.EXTERN;
break;
case TokenType.STATIC:
next ();
flags |= ModifierFlags.STATIC;
......@@ -2522,6 +2526,10 @@ public class Vala.Parser : CodeVisitor {
next ();
flags |= ModifierFlags.CLASS;
break;
case TokenType.EXTERN:
next ();
flags |= ModifierFlags.EXTERN;
break;
case TokenType.INLINE:
next ();
flags |= ModifierFlags.INLINE;
......@@ -2659,7 +2667,6 @@ public class Vala.Parser : CodeVisitor {
while (sym.inner != null) {
sym = sym.inner;
var ns = new Namespace (sym.name, d.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
} else {
......@@ -2769,6 +2776,7 @@ public class Vala.Parser : CodeVisitor {
case TokenType.DELEGATE:
case TokenType.ENUM:
case TokenType.ERRORDOMAIN:
case TokenType.EXTERN:
case TokenType.INLINE:
case TokenType.INTERFACE:
case TokenType.NAMESPACE:
......
......@@ -185,6 +185,9 @@ public class Vala.Scanner : Object {
case 'd':
if (matches (begin, "delete")) return TokenType.DELETE;
break;
case 'e':
if (matches (begin, "extern")) return TokenType.EXTERN;
break;
case 'i':
if (matches (begin, "inline")) return TokenType.INLINE;
break;
......
......@@ -174,7 +174,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
/* VAPI classes don't have to specify overridden methods */
if (!cl.source_reference.file.pkg) {
if (!cl.external_package) {
/* all abstract symbols defined in base types have to be at least defined (or implemented) also in this type */
foreach (DataType base_type in cl.get_base_types ()) {
if (base_type.data_type is Interface) {
......@@ -323,7 +323,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
public override void visit_constant (Constant c) {
c.type_reference.accept (this);
if (!current_source_file.pkg) {
if (!c.external_package) {
if (c.initializer == null) {
c.error = true;
Report.error (c.source_reference, "A const field requires a initializer to be provided");
......@@ -413,7 +413,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
if (current_symbol is Class) {
/* VAPI classes don't specify overridden methods */
if (!current_symbol.source_reference.file.pkg) {
if (!current_symbol.external_package) {
if (!(m is CreationMethod)) {
find_base_interface_method (m, (Class) current_symbol);
if (m.is_virtual || m.overrides) {
......@@ -689,7 +689,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
var cl = (Class) prop.parent_symbol;
/* VAPI classes don't specify overridden properties */
if (!cl.source_reference.file.pkg) {
if (!cl.external_package) {
find_base_interface_property (prop, cl);
if (prop.is_virtual || prop.overrides) {
find_base_class_property (prop, cl);
......@@ -720,7 +720,7 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
current_return_type = new VoidType ();
}
if (!acc.source_reference.file.pkg) {
if (!acc.prop.external_package) {
if (acc.body == null && !acc.prop.interface_only && !acc.prop.is_abstract) {
/* no accessor body specified, insert default body */
......
......@@ -40,7 +40,7 @@ public class Vala.SourceFile : Object {
/**
* Specifies whether this file is a VAPI package file.
*/
public bool pkg { get; set; }
public bool external_package { get; set; }
/**
* Specifies the dependency cycle this source file is member of. If this
......@@ -98,7 +98,7 @@ public class Vala.SourceFile : Object {
*/
public SourceFile (CodeContext context, string filename, bool pkg = false) {
this.filename = filename;
this.pkg = pkg;
this.external_package = pkg;
this.context = context;
}
......@@ -231,7 +231,7 @@ public class Vala.SourceFile : Object {
* @param dep_type type of dependency
*/
public void add_symbol_dependency (Symbol? sym, SourceFileDependencyType dep_type) {
if (pkg) {
if (external_package) {
return;
}
......@@ -255,7 +255,7 @@ public class Vala.SourceFile : Object {
}
if (dep_type == SourceFileDependencyType.SOURCE) {
if (s.source_reference.file.pkg) {
if (s.external_package) {
foreach (string fn in s.get_cheader_filenames ()) {
source_external_includes.add (fn);
}
......@@ -267,7 +267,7 @@ public class Vala.SourceFile : Object {
return;
}
if (s.source_reference.file.pkg) {
if (s.external_package) {
/* external package */
foreach (string fn in s.get_cheader_filenames ()) {
header_external_includes.add (fn);
......
......@@ -94,16 +94,33 @@ public abstract class Vala.Symbol : CodeNode {
public Scope scope {
get { return _scope; }
}
/**
* Specifies whether the implementation is external, for example in
* a separate C source file or in an external library.
*/
public bool external {
get {
return _external || (parent_symbol != null && parent_symbol.external)
|| external_package;
}
set { _external = value; }
}
/**
* Specifies whether this is an imported symbol e.g. the Import
* attribute has been set.
* Specifies whether the implementation is in an external library.
*/
public bool is_imported { get; set; }
public bool external_package {
get {
return (source_reference != null && source_reference.file.external_package);
}
}
private weak Scope _owner;
private Scope _scope;
private bool _external;
construct {
_scope = new Scope (this);
active = true;
......
......@@ -65,6 +65,7 @@ public enum Vala.TokenType {
ENSURES,
ERRORDOMAIN,
EOF,
EXTERN,
FALSE,
FINALLY,
FOR,
......
......@@ -198,7 +198,7 @@ public abstract class Vala.Typesymbol : Symbol {
add_cheader_filename (filename);
}
if (cheader_filenames.size == 0 && source_reference != null && !source_reference.file.pkg) {
if (cheader_filenames.size == 0 && source_reference != null && !external_package) {
// don't add default include directives for VAPI files
cheader_filenames.add (source_reference.file.get_cinclude_filename ());
}
......
......@@ -5,8 +5,7 @@ namespace GnomeKeyring
[CCode (free_function = "gnome_keyring_attribute_list_free")]
public class AttributeList {
[Import]
public Attribute index (int i);
public extern Attribute index (int i);
[NoArrayLength]
public Attribute[] data;
......
......@@ -21,6 +21,5 @@
*/
namespace Gst {
[Import]
public void init ([CCode (array_length_pos = 0.9)] ref string[] args);
public extern void init ([CCode (array_length_pos = 0.9)] ref string[] args);
}
......@@ -29,20 +29,16 @@ namespace Gtk {
}
public class Widget {
[Import]
public Widget (GLib.Type type, ...);
public extern Widget (GLib.Type type, ...);
[Import]
[CCode (cname = "GTK_WIDGET_FLAGS")]
public WidgetFlags get_flags ();
public extern WidgetFlags get_flags ();
[Import]
[CCode (cname = "GTK_WIDGET_SET_FLAGS")]
public void set_flags (WidgetFlags flags);
public extern void set_flags (WidgetFlags flags);
[Import]
[CCode (cname = "GTK_WIDGET_UNSET_FLAGS")]
public void unset_flags (WidgetFlags flags);
public extern void unset_flags (WidgetFlags flags);
}
public interface FileChooserEmbed {
......
......@@ -22,8 +22,7 @@
namespace GMenu {
public class TreeItem {
[Import]
public TreeItemType get_type ();
public extern TreeItemType get_type ();
}
}
......@@ -22,7 +22,6 @@
namespace Pango {
public class Language {
[Import]
public weak string to_string ();
public extern weak string to_string ();
}
}
......@@ -193,7 +193,9 @@ public class Vala.GIdlParser : CodeVisitor {
Namespace ns;
if (sym is Namespace) {
ns = (Namespace) sym;
ns.pkg = false;
if (ns.external_package) {
ns.source_reference = current_source_reference;
}
} else {
ns = new Namespace (module.name, current_source_reference);
}
......
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