Commit 070036ac authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

update reference and property annotations switch string struct to utf-8

2006-05-18  Jürg Billeter  <j@bitron.ch>

	* update reference and property annotations
	* switch string struct to utf-8
	* valac/context.c: set source file in root namespace
	* valac/generator.c: don't include bindings stub header

svn path=/trunk/; revision=23
parent 0ed5c3ab
2006-05-18 Jürg Billeter <j@bitron.ch>
* update reference and property annotations
* switch string struct to utf-8
* valac/context.c: set source file in root namespace
* valac/generator.c: don't include bindings stub header
2006-05-17 Jürg Billeter <j@bitron.ch>
* vala/valanamespace.vala: implement camel_case_to_lower_case method
......
......@@ -97,54 +97,65 @@ public struct unichar {
[ReferenceType ()]
[AllowPointerArithmetic ()]
[CCode (cname = "char")]
public struct string {
public struct astring {
[CCode (cname = "g_str_has_suffix")]
public bool has_suffix (string suffix);
[CCode (cname = "g_strdup_printf")]
public ref string printf (string args);
public ref astring printf (string args);
[CCode (cname = "g_ascii_strup")]
public ref string up (long len /* = -1 */);
public ref astring up (long len /* = -1 */);
[CCode (cname = "g_ascii_strdown")]
public ref string down (long len /* = -1 */);
public ref astring down (long len /* = -1 */);
[CCode (cname = "g_strconcat")]
public ref string concat (string string2);
public ref astring concat (string string2);
[CCode (cname = "g_strdup")]
public ref string dup ();
public ref astring dup ();
[CCode (cname = "g_strndup")]
public ref string ndup (int n);
public ref astring ndup (int n);
[CCode (cname = "strlen")]
public int len ();
[CCode (cname = "g_strcompress")]
public string# compress ();
public ref astring compress ();
[CCode (cname = "strcmp")]
public int cmp ();
}
[ReferenceType ()]
[CCode (cname = "char")]
public struct ustring {
public struct string {
[CCode (cname = "g_str_has_suffix")]
public bool has_suffix (string suffix);
[CCode (cname = "g_strdup_printf")]
public ref string printf (string args);
[CCode (cname = "g_strconcat")]
public ref string concat (string string2);
[CCode (cname = "g_strndup")]
public ref ustring ndup (int n);
public ref string ndup (int n);
[CCode (cname = "g_strcompress")]
public ref ustring compress ();
public ref string compress ();
[CCode (cname = "g_utf8_next_char")]
public ustring next_char ();
public string next_char ();
[CCode (cname = "g_utf8_get_char")]
public unichar get_char ();
[CCode (cname = "g_utf8_offset_to_pointer")]
[PlusOperator ()]
public ustring offset (long offset);
public string offset (long offset);
[CCode (cname = "g_utf8_prev_char")]
public ustring prev_char ();
public string prev_char ();
[CCode (cname = "g_utf8_strlen")]
public long len (long max /*= -1*/);
[CCode (cname = "g_utf8_strup")]
public ref string up (long len /*= -1*/);
[CCode (cname = "g_utf8_collate")]
public int collate (string str2);
}
[Import ()]
[CCode (cname = "g", cprefix = "G", include_filename = "glib.h")]
namespace GLib {
public struct Path {
public static ref ustring get_basename (ustring file_name);
public static ref string get_basename (string file_name);
}
public struct Type {
......@@ -165,7 +176,7 @@ namespace GLib {
[CCode (cname = "FILE")]
public struct File {
[CCode (cname = "fopen")]
public static File# open (string path, string mode);
public static ref File open (string path, string mode);
[CCode (cname = "fprintf")]
public void printf (string format);
[InstanceLast ()]
......@@ -184,7 +195,7 @@ namespace GLib {
[Unknown (reference_type = true)]
[ReferenceType ()]
public struct OptionContext {
public static OptionContext# @new (string parameter_string);
public static ref OptionContext new (string parameter_string);
public bool parse (ref int argc, out string[] argv, out Error error);
public void set_help_enabled (bool help_enabled);
public void add_main_entries (OptionEntry[] entries, string translation_domain);
......@@ -241,11 +252,11 @@ namespace GLib {
public void free ();
public uint length ();
public List<G># copy ();
public ref List<G> copy ();
[ReturnsModifiedPointer ()]
public void reverse ();
[ReturnsModifiedPointer ()]
public void concat (List<G># list2);
public void concat (ref List<G> list2);
public List<G> first ();
public List<G> last ();
......@@ -264,7 +275,7 @@ namespace GLib {
[ReferenceType ()]
public struct HashTable<K,V> {
public static HashTable# new (HashFunc hash_func, EqualFunc key_equal_func);
public static ref HashTable new (HashFunc hash_func, EqualFunc key_equal_func);
public void insert (K key, V value);
public V lookup (K key);
}
......@@ -286,7 +297,7 @@ namespace GLib {
public void append_c (char c);
public void append_unichar (unichar wc);
public ref ustring str;
public string str;
public long len;
public long allocated_len;
}
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class CCodeAssignment : CCodeExpression {
public readonly ref CCodeExpression left;
public readonly ref CCodeExpression right;
public CCodeExpression left { get; construct; }
public CCodeExpression right { get; construct; }
public override void write (CCodeWriter writer) {
if (left != null) {
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class CCodeBinaryExpression : CCodeExpression {
public readonly ref CCodeExpression left;
public readonly ref CCodeExpression right;
public CCodeExpression left { get; construct; }
public CCodeExpression right { get; construct; }
public override void write (CCodeWriter writer) {
if (left != null) {
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeComment : CCodeNode {
public readonly string# text;
public string text { get; construct; }
public override void write (CCodeWriter writer) {
writer.write_comment (text);
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeConstant : CCodeExpression {
public readonly ref string name;
public string name { get; construct; }
public override void write (CCodeWriter writer) {
writer.write_string (name);
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class CCodeDeclarationStatement : CCodeStatement {
public readonly ref string type_name;
ref List<ref CCodeVariableDeclarator> variable_declarators;
public string type_name { get; construct; }
List<CCodeVariableDeclarator> variable_declarators;
public void add_declarator (CCodeVariableDeclarator decl) {
variable_declarators.append (decl);
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class CCodeEnum : CCodeNode {
public readonly ref string name;
ref List<ref string> values;
public string name { get; construct; }
List<string> values;
public void add_value (string name, string value) {
values.append ("%s = %s".printf (name, value));
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeExpressionStatement : CCodeStatement {
public readonly ref CCodeExpression expression;
public CCodeExpression expression { get; construct; }
public override void write (CCodeWriter writer) {
writer.write_indent ();
......
......@@ -24,11 +24,11 @@ using GLib;
namespace Vala {
public class CCodeForStatement : CCodeStatement {
public readonly ref CCodeExpression condition;
public readonly ref CCodeStatement body;
public CCodeExpression condition { get; construct; }
public CCodeStatement body { get; construct; }
ref List<ref CCodeExpression> initializer;
ref List<ref CCodeExpression> iterator;
List<CCodeExpression> initializer;
List<CCodeExpression> iterator;
public void add_initializer (CCodeExpression expr) {
initializer.append (expr);
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeFragment : CCodeNode {
public ref GLib.List<ref CCodeNode> children { get; construct; }
public GLib.List<CCodeNode> children { get; construct; }
public void append (CCodeNode node) {
_children.append (node);
......
......@@ -24,11 +24,11 @@ using GLib;
namespace Vala {
public class CCodeFunction : CCodeNode {
public readonly ref string name;
public string name { get; construct; }
public CCodeModifiers modifiers;
public readonly ref string return_type;
ref List<ref string> parameters;
public ref CCodeBlock block;
public string return_type { get; construct; }
List<string> parameters;
public CCodeBlock block;
public void add_parameter (string type, string name) {
parameters.append ("%s %s".printf (type, name));
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class CCodeFunctionCall : CCodeExpression {
public readonly ref CCodeExpression call;
ref List<ref CCodeExpression> arguments;
public CCodeExpression call { get; construct; }
List<CCodeExpression> arguments;
public void add_argument (CCodeExpression expr) {
arguments.append (expr);
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeIdentifier : CCodeExpression {
public readonly ref string name;
public string name { get; construct; }
public override void write (CCodeWriter writer) {
writer.write_string (name);
......
......@@ -24,9 +24,9 @@ using GLib;
namespace Vala {
public class CCodeIfStatement : CCodeStatement {
public readonly ref CCodeExpression condition;
public readonly ref CCodeStatement true_statement;
public readonly ref CCodeStatement false_statement;
public CCodeExpression condition { get; construct; }
public CCodeStatement true_statement { get; construct; }
public CCodeStatement false_statement { get; construct; }
public override void write (CCodeWriter writer) {
writer.write_indent ();
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeParenthesizedExpression : CCodeExpression {
public readonly ref CCodeExpression inner;
public CCodeExpression inner { get; construct; }
public override void write (CCodeWriter writer) {
writer.write_string ("(");
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeReturnStatement : CCodeStatement {
public readonly ref CCodeExpression return_expression;
public CCodeExpression return_expression { get; construct; }
public override void write (CCodeWriter writer) {
writer.write_indent ();
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class CCodeStruct : CCodeNode {
public readonly ref string name;
ref List<ref string> fields;
public string name { get; construct; }
List<string> fields;
public void add_field (string type, string name) {
fields.append ("%s %s".printf (type, name));
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class CCodeVariableDeclarator : CCodeNode {
public readonly ref string name;
public readonly ref CCodeExpression initializer;
public string name { get; construct; }
public CCodeExpression initializer { get; construct; }
public override void write (CCodeWriter writer) {
writer.write_string (name);
......
......@@ -24,7 +24,7 @@ using GLib;
namespace Vala {
public class CCodeWriter {
public readonly File# stream;
public File stream { get; construct; }
int indent;
/* at begin of line */
......
......@@ -150,7 +150,6 @@ static void yyerror (YYLTYPE *locp, ValaParser *parser, const char *msg);
%token OVERRIDE "override"
%token PUBLIC "public"
%token PRIVATE "private"
%token READONLY "readonly"
%token REF "ref"
%token SET "set"
%token STATIC "static"
......@@ -160,6 +159,7 @@ static void yyerror (YYLTYPE *locp, ValaParser *parser, const char *msg);
%token USING "using"
%token VAR "var"
%token VIRTUAL "virtual"
%token WEAK "weak"
%token WHILE "while"
%token <str> IDENTIFIER "identifier"
......@@ -173,7 +173,6 @@ static void yyerror (YYLTYPE *locp, ValaParser *parser, const char *msg);
%type <type_reference> type_name
%type <type_reference> type
%type <num> opt_ref
%type <num> opt_own_qualifier
%type <list> opt_argument_list
%type <list> argument_list
%type <expression> argument
......@@ -337,38 +336,29 @@ type_name
;
type
: type_name opt_own_qualifier
: type_name
{
$$ = $1;
vala_type_reference_set_own ($$, $2);
}
| type array_qualifier opt_own_qualifier
| type array_qualifier
{
$$ = $1;
vala_type_reference_set_array ($$, TRUE);
vala_type_reference_set_array_own ($$, $3);
}
;
opt_ref
: /* empty */
{
$$ = FALSE;
$$ = 0;
}
| REF
{
$$ = TRUE;
$$ = 1;
}
;
opt_own_qualifier
: /* empty */
| WEAK
{
$$ = FALSE;
}
| HASH
{
$$ = TRUE;
$$ = 2;
}
;
......@@ -730,16 +720,18 @@ local_variable_declaration
/* don't use type to prevent reduce/reduce conflict */
local_variable_type
: primary_expression opt_own_qualifier
: primary_expression
{
$$ = vala_type_reference_new_from_expression ($1, src(@1));
vala_type_reference_set_own ($$, $2);
}
| local_variable_type array_qualifier opt_own_qualifier
| REF primary_expression
{
$$ = vala_type_reference_new_from_expression ($2, src(@2));
}
| local_variable_type array_qualifier
{
$$ = $1;
vala_type_reference_set_array ($$, TRUE);
vala_type_reference_set_array_own ($$, $3);
}
;
......@@ -957,7 +949,6 @@ modifiers
modifier
: ABSTRACT
| OVERRIDE
| READONLY
| STATIC
| VIRTUAL
;
......
......@@ -129,7 +129,6 @@ literal ({literal_integer}|{literal_character}|{literal_string})
"override" { uploc; return OVERRIDE; }
"public" { uploc; return PUBLIC; }
"private" { uploc; return PRIVATE; }
"readonly" { uploc; return READONLY; }
"ref" { uploc; return REF; }
"set" { uploc; return SET; }
"static" { uploc; return STATIC; }
......@@ -139,6 +138,7 @@ literal ({literal_integer}|{literal_character}|{literal_string})
"using" { uploc; return USING; }
"var" { uploc; return VAR; }
"virtual" { uploc; return VIRTUAL; }
"weak" { uploc; return WEAK; }
"while" { uploc; return WHILE; }
{literal_integer} { uploc; yylval->str = g_strdup (yytext); return INTEGER_LITERAL; }
......
......@@ -24,9 +24,9 @@ using GLib;
namespace Vala {
public class Assignment : Expression {
public readonly ref Expression left;
public readonly ref Expression right;
public readonly ref SourceReference source_reference;
public Expression left { get; construct; }
public Expression right { get; construct; }
public SourceReference source_reference { get; construct; }
public static ref Assignment new (Expression left, Expression right, SourceReference source) {
return (new Assignment (left = left, right = right, source_reference = source));
......
......@@ -24,10 +24,10 @@ using GLib;
namespace Vala {
public class Attribute : CodeNode {
public readonly ref string name;
public readonly ref SourceReference source_reference;
public string name { get; construct; }
public SourceReference source_reference { get; construct; }
public ref List<ref NamedArgument> args;
public List<NamedArgument> args;
public static ref Attribute new (string name, SourceReference source) {
return (new Attribute (name = name, source_reference = source));
......
......@@ -24,10 +24,10 @@ using GLib;
namespace Vala {
public class BinaryExpression : Expression {
public readonly ref BinaryOperator operator;
public readonly ref Expression left;
public readonly ref Expression right;
public readonly ref SourceReference source_reference;
public BinaryOperator operator { get; construct; }
public Expression left { get; construct; }
public Expression right { get; construct; }
public SourceReference source_reference { get; construct; }
public static ref BinaryExpression new (BinaryOperator op, Expression left, Expression right, SourceReference source) {
return (new BinaryExpression (operator = op, left = left, right = right, source_reference = source));
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class Block : Statement {
public readonly ref List<ref Statement> statement_list;
public readonly ref SourceReference source_reference;
public List<Statement> statement_list { get; construct; }
public SourceReference source_reference { get; construct; }
public static ref Block new (List<Statement> statement_list, SourceReference source) {
return (new Block (statement_list = statement_list, source_reference = source));
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class BooleanLiteral : Literal {
public readonly bool value;
public readonly SourceReference# source_reference;
public bool value { get; construct; }
public SourceReference source_reference { get; construct; }
public static ref BooleanLiteral new (bool b, SourceReference source) {
return (new BooleanLiteral (value = b, source_reference = source));
......
......@@ -24,11 +24,11 @@ using GLib;
namespace Vala {
public class CastExpression : Expression {
public readonly Expression# inner;
public readonly TypeReference# type_reference;
public readonly SourceReference# source_reference;
public Expression inner { get; construct; }
public TypeReference type_reference { get; construct; }
public SourceReference source_reference { get; construct; }
public static CastExpression# @new (Expression inner, TypeReference type, SourceReference source) {
public static ref CastExpression new (Expression inner, TypeReference type, SourceReference source) {
return (new CastExpression (inner = inner, type_reference = type, source_reference = source));
}
......
......@@ -24,10 +24,10 @@ using GLib;
namespace Vala {
public class CharacterLiteral : Literal {
public readonly string# value;
public readonly SourceReference# source_reference;
public string value { get; construct; }
public SourceReference source_reference { get; construct; }
public static CharacterLiteral# @new (string c, SourceReference source) {
public static ref CharacterLiteral new (string c, SourceReference source) {
return (new CharacterLiteral (value = c, source_reference = source));
}
......
......@@ -24,11 +24,11 @@ using GLib;
namespace Vala {
public class Class : Struct {
public readonly ref SourceReference source_reference;
public ref List<ref TypeReference> base_types;
public ref Class base_class;
public SourceReference source_reference { get; construct; }
public List<TypeReference> base_types;
public Class base_class;
ref List<ref Property> properties;
List<Property> properties;
public void add_base_type (TypeReference type) {
base_types.append (type);
......
......@@ -24,8 +24,8 @@ using GLib;
namespace Vala {
public class CodeContext {
List<SourceFile#># source_files;
public Symbol# root = new Symbol ();
List<SourceFile> source_files;
public Symbol root = new Symbol ();
public void add_source_file (SourceFile file) {
source_files.append (file);
......
......@@ -24,19 +24,19 @@ using GLib;
namespace Vala {
public class CodeGenerator : CodeVisitor {
ref CCodeFragment header_begin;
ref CCodeFragment header_type_declaration;
ref CCodeFragment header_type_definition;
ref CCodeFragment header_type_member_declaration;
ref CCodeFragment source_begin;
ref CCodeFragment source_include_directives;
ref CCodeFragment source_type_member_declaration;
ref CCodeFragment source_type_member_definition;
CCodeFragment header_begin;
CCodeFragment header_type_declaration;
CCodeFragment header_type_definition;
CCodeFragment header_type_member_declaration;
CCodeFragment source_begin;
CCodeFragment source_include_directives;
CCodeFragment source_type_member_declaration;
CCodeFragment source_type_member_definition;
ref CCodeStruct instance_struct;
ref CCodeStruct class_struct;
ref CCodeFunction function;
ref CCodeBlock block;
CCodeStruct instance_struct;
CCodeStruct class_struct;
CCodeFunction function;
CCodeBlock block;
TypeReference reference; // dummy for dependency resolution
......
......@@ -24,9 +24,9 @@ using GLib;
namespace Vala {
public abstract class CodeNode {
public Symbol# symbol;
public ref List<ref Attribute> attributes;
public ref CCodeNode ccodenode;
public Symbol symbol;
public List<Attribute> attributes;
public CCodeNode ccodenode;
public abstract void accept (CodeVisitor visitor);
}
......
......@@ -24,10 +24,10 @@ using GLib;
namespace Vala {
public class ConditionalExpression : Expression {
public readonly ref Expression condition;
public readonly ref Expression true_expression;
public readonly ref Expression false_expression;
public readonly ref SourceReference source_reference;
public Expression condition { get; construct; }
public Expression true_expression { get; construct; }
public Expression false_expression { get; construct; }
public SourceReference source_reference { get; construct; }
public static ref ConditionalExpression new (Expression cond, Expression true_expr, Expression false_expr, SourceReference source) {
return (new ConditionalExpression (condition = cond, true_expression = true_expr, false_expression = false_expr, source_reference = source));
......
......@@ -24,11 +24,11 @@ using GLib;
namespace Vala {
public class Constant : CodeNode {
public readonly string# name;
public readonly TypeReference# type_reference;
public readonly Expression# initializer;
public readonly SourceReference# source_reference;
public CodeNode parent_type;
public string name { get; construct; }
public TypeReference type_reference { get; construct; }
public Expression initializer { get; construct; }
public SourceReference source_reference { get; construct; }
public weak CodeNode parent_type;
public static ref Constant new (string name, TypeReference type, Expression init, SourceReference source) {
return (new Constant (name = name, type_reference = type, initializer = init, source_reference = source));
......
......@@ -24,10 +24,10 @@ using GLib;
namespace Vala {
public class DeclarationStatement : Statement {