From 9aa99048d5abe45412651f4ba7fcf50bfa2173b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrg=20Billeter?= Date: Fri, 30 Jun 2006 15:59:33 +0000 Subject: [PATCH] use implicit namespace specification, reformat code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 2006-06-30 Jürg Billeter * vala/valacodenode.vala, vala/valadatatype.vala, vala/valaexpression.vala: use implicit namespace specification, reformat code svn path=/trunk/; revision=59 --- vala/ChangeLog | 6 + vala/vala/valacodenode.vala | 78 +++++------ vala/vala/valadatatype.vala | 317 ++++++++++++++++++++---------------------- vala/vala/valaexpression.vala | 93 ++++++------- 4 files changed, 241 insertions(+), 253 deletions(-) diff --git a/vala/ChangeLog b/vala/ChangeLog index 6f0e2a9..19df051 100644 --- a/vala/ChangeLog +++ b/vala/ChangeLog @@ -1,5 +1,11 @@ 2006-06-30 Jürg Billeter + * vala/valacodenode.vala, vala/valadatatype.vala, + vala/valaexpression.vala: use implicit namespace specification, + reformat code + +2006-06-30 Jürg Billeter + * vala/parser.y: support implicit namespace specification in class declaration diff --git a/vala/vala/valacodenode.vala b/vala/vala/valacodenode.vala index 900a9cb..c26973e 100644 --- a/vala/vala/valacodenode.vala +++ b/vala/vala/valacodenode.vala @@ -22,48 +22,44 @@ using GLib; -namespace Vala { +/** + * Represents a part of the parsed source code. + * + * Code nodes get created by the parser and are used throughout the whole + * compilation process. + */ +public abstract class Vala.CodeNode { /** - * Represents a part of the parsed source code. - * - * Code nodes get created by the parser and are used throughout the - * whole compilation process. + * Symbol that corresponds to this code node. + */ + public Symbol symbol { get; set; } + + /** + * References the location in the source file where this code node has + * been written. + */ + public SourceReference source_reference { get; set; } + + /** + * Contains all attributes that have been specified for this code node. */ - public abstract class CodeNode { - /** - * Symbol that corresponds to this code node. - */ - public Symbol symbol { get; set; } - - /** - * References the location in the source file where this code - * node has been written. - */ - public SourceReference source_reference { get; set; } - - /** - * Contains all attributes that have been specified for this - * code node. - */ - public List attributes; - - /** - * Generated CCodeNode that corresponds to this code node. - */ - public CCodeNode ccodenode { get; set; } - - /** - * Specifies whether a fatal error has been detected in this - * code node. - */ - public bool error { get; set; } + public List attributes; + + /** + * Generated CCodeNode that corresponds to this code node. + */ + public CCodeNode ccodenode { get; set; } + + /** + * Specifies whether a fatal error has been detected in this code node. + */ + public bool error { get; set; } - /** - * Visits this code node and all children with the specified - * CodeVisitor. - * - * @param visitor the visitor to be called while traversing - */ - public abstract void accept (CodeVisitor! visitor); - } + /** + * Visits this code node and all children with the specified + * CodeVisitor. + * + * @param visitor the visitor to be called while traversing + */ + public abstract void accept (CodeVisitor! visitor); } diff --git a/vala/vala/valadatatype.vala b/vala/vala/valadatatype.vala index 47b822e..44d6c19 100644 --- a/vala/vala/valadatatype.vala +++ b/vala/vala/valadatatype.vala @@ -22,174 +22,165 @@ using GLib; -namespace Vala { +/** + * Represents a runtime data type. This data type may be defined in Vala source + * code or imported from an external library with a Vala API file. + */ +public abstract class Vala.DataType : CodeNode { + /** + * The symbol name of this data type. + */ + public string! name { get; set construct; } + /** - * Represents a runtime data type. This data type may be defined in Vala - * source code or imported from an external library with a Vala API - * file. + * Specifies the accessibility of the class. Public accessibility + * doesn't limit access. Default accessibility limits access to this + * program or library. Protected and private accessibility is not + * supported for types. */ - public abstract class DataType : CodeNode { - /** - * The symbol name of this data type. - */ - public string! name { get; set construct; } - - /** - * Specifies the accessibility of the class. Public - * accessibility doesn't limit access. Default accessibility - * limits access to this program or library. Protected and - * private accessibility is not supported for types. - */ - public MemberAccessibility access; - - /** - * The namespace containing this data type. - */ - public weak Namespace @namespace; + public MemberAccessibility access; + + /** + * The namespace containing this data type. + */ + public weak Namespace @namespace; - /** - * Returns the name of this data type as it is used in C code. - * - * @return the name to be used in C code - */ - public abstract string get_cname (); - - /** - * Checks whether this data type has value or reference type - * semantics. - * - * @return true if this data type has reference type semantics - */ - public virtual bool is_reference_type () { - return false; - } - - /** - * Returns the C function name that duplicates instances of this - * data type. The specified C function must accept one argument - * referencing the instance of this data type and return a - * reference to the duplicate. - * - * @return the name of the C function if supported or null - * otherwise - */ - public virtual string get_dup_function () { - return null; - } - - /** - * Returns the C function name that frees instances of this - * data type. This is only valid for data types with reference - * type semantics that do not support reference counting. The - * specified C function must accept one argument pointing to the - * instance to be freed. - * - * @return the name of the C function or null if this data type - * is not a reference type or if it supports reference - * counting - */ - public virtual string get_free_function () { - return null; - } - - /** - * Checks whether this data type supports reference counting. - * This is only valid for reference types. - * - * @return true if this data type supports reference counting - */ - public virtual bool is_reference_counting () { - return false; - } - - /** - * Returns the C function name that increments the reference - * count of instances of this data type. This is only valid for - * data types supporting reference counting. The specified C - * function must accept one argument referencing the instance of - * this data type and return the reference. - * - * @return the name of the C function or null if this data type - * does not support reference counting - */ - public virtual string get_ref_function () { - return null; - } - - /** - * Returns the C function name that decrements the reference - * count of instances of this data type. This is only valid for - * data types supporting reference counting. The specified C - * function must accept one argument referencing the instance of - * this data type. - * - * @return the name of the C function or null if this data type - * does not support reference counting - */ - public virtual string get_unref_function () { - return null; - } - - /** - * Returns the C symbol representing the runtime type id for - * this data type. The specified symbol must express a - * registered GType. - * - * @return the name of the GType name in C code or null if this - * data type is not registered with GType - */ - public virtual string get_type_id () { - return null; - } - - /** - * Returns the C name of this data type in upper case. Words are - * separated by underscores. The upper case C name of the - * namespace is prefix of the result. - * - * @param infix a string to be placed between namespace and - * data type name or null - * @return the upper case name to be used in C code - */ - public abstract ref string! get_upper_case_cname (string infix); - - /** - * Returns the C name of this data type in lower case. Words are - * separated by underscores. The lower case C name of the - * namespace is prefix of the result. - * - * @param infix a string to be placed between namespace and - * data type name or null - * @return the lower case name to be used in C code - */ - public abstract ref string! get_lower_case_cname (string infix); - - /** - * Returns a list of C header filenames users of this data type - * must include. - * - * @return list of C header filenames for this data type - */ - public ref List get_cheader_filenames () { - if (cheader_filenames == null) { - /* default to header filenames of the namespace */ - foreach (string filename in @namespace.get_cheader_filenames ()) { - add_cheader_filename (filename); - } + /** + * Returns the name of this data type as it is used in C code. + * + * @return the name to be used in C code + */ + public abstract string get_cname (); + + /** + * Checks whether this data type has value or reference type semantics. + * + * @return true if this data type has reference type semantics + */ + public virtual bool is_reference_type () { + return false; + } + + /** + * Returns the C function name that duplicates instances of this data + * type. The specified C function must accept one argument referencing + * the instance of this data type and return a reference to the + * duplicate. + * + * @return the name of the C function if supported or null otherwise + */ + public virtual string get_dup_function () { + return null; + } + + /** + * Returns the C function name that frees instances of this data type. + * This is only valid for data types with reference type semantics that + * do not support reference counting. The specified C function must + * accept one argument pointing to the instance to be freed. + * + * @return the name of the C function or null if this data type is not a + * reference type or if it supports reference counting + */ + public virtual string get_free_function () { + return null; + } + + /** + * Checks whether this data type supports reference counting. This is + * only valid for reference types. + * + * @return true if this data type supports reference counting + */ + public virtual bool is_reference_counting () { + return false; + } + + /** + * Returns the C function name that increments the reference count of + * instances of this data type. This is only valid for data types + * supporting reference counting. The specified C function must accept + * one argument referencing the instance of this data type and return + * the reference. + * + * @return the name of the C function or null if this data type does not + * support reference counting + */ + public virtual string get_ref_function () { + return null; + } + + /** + * Returns the C function name that decrements the reference count of + * instances of this data type. This is only valid for data types + * supporting reference counting. The specified C function must accept + * one argument referencing the instance of this data type. + * + * @return the name of the C function or null if this data type does not + * support reference counting + */ + public virtual string get_unref_function () { + return null; + } + + /** + * Returns the C symbol representing the runtime type id for this data + * type. The specified symbol must express a registered GType. + * + * @return the name of the GType name in C code or null if this data + * type is not registered with GType + */ + public virtual string get_type_id () { + return null; + } + + /** + * Returns the C name of this data type in upper case. Words are + * separated by underscores. The upper case C name of the namespace is + * prefix of the result. + * + * @param infix a string to be placed between namespace and data type + * name or null + * @return the upper case name to be used in C code + */ + public abstract ref string! get_upper_case_cname (string infix); + + /** + * Returns the C name of this data type in lower case. Words are + * separated by underscores. The lower case C name of the namespace is + * prefix of the result. + * + * @param infix a string to be placed between namespace and data type + * name or null + * @return the lower case name to be used in C code + */ + public abstract ref string! get_lower_case_cname (string infix); + + /** + * Returns a list of C header filenames users of this data type must + * include. + * + * @return list of C header filenames for this data type + */ + public ref List get_cheader_filenames () { + if (cheader_filenames == null) { + /* default to header filenames of the namespace */ + foreach (string filename in @namespace.get_cheader_filenames ()) { + add_cheader_filename (filename); } - return cheader_filenames.copy (); - } - - /** - * Adds a filename to the list of C header filenames users of - * this data type must include. - * - * @param filename a C header filename - */ - public void add_cheader_filename (string! filename) { - cheader_filenames.append (filename); } + return cheader_filenames.copy (); + } - private List cheader_filenames; + /** + * Adds a filename to the list of C header filenames users of this data + * type must include. + * + * @param filename a C header filename + */ + public void add_cheader_filename (string! filename) { + cheader_filenames.append (filename); } + + private List cheader_filenames; } diff --git a/vala/vala/valaexpression.vala b/vala/vala/valaexpression.vala index f3dd96f..6fe357b 100644 --- a/vala/vala/valaexpression.vala +++ b/vala/vala/valaexpression.vala @@ -22,55 +22,50 @@ using GLib; -namespace Vala { +/** + * Base class for all code nodes that might be used as an expression. + */ +public abstract class Vala.Expression : CodeNode { + /** + * The static type of this expression. + * + * The semantic analyzer computes this value. + */ + public TypeReference static_type { get; set; } + + /* + * The static type this expression is expected to have. + * + * The semantic analyzer computes this value, lambda expressions use it. + */ + public TypeReference expected_type { get; set; } + + /** + * The symbol this expression refers to. + */ + public Symbol symbol_reference { get; set; } + + /** + * Specifies that this expression transfers ownership without a receiver + * being present. + * + * The memory manager computes this value, the code generator uses it. + */ + public bool ref_leaked { get; set; } + + /** + * Specifies that this expression is expected to transfer ownership but + * doesn't. + * + * The memory manager computes this value, the code generator uses it. + */ + public bool ref_missing { get; set; } + /** - * Base class for all code nodes that might be used as an expression. + * Contains all temporary variables this expression requires for + * execution. + * + * The code generator sets and uses them for memory management. */ - public abstract class Expression : CodeNode { - /** - * The static type of this expression. - * - * The semantic analyzer computes this value. - */ - public TypeReference static_type { get; set; } - - /* - * The static type this expression is expected to have. - * - * The semantic analyzer computes this value, lambda expressions - * use it. - */ - public TypeReference expected_type { get; set; } - - /** - * The symbol this expression refers to. - */ - public Symbol symbol_reference { get; set; } - - /** - * Specifies that this expression transfers ownership without a - * receiver being present. - * - * The memory manager computes this value, the code generator - * uses it. - */ - public bool ref_leaked { get; set; } - - /** - * Specifies that this expression is expected to transfer - * ownership but doesn't. - * - * The memory manager computes this value, the code generator - * uses it. - */ - public bool ref_missing { get; set; } - - /** - * Contains all temporary variables this expression requires - * for execution. - * - * The code generator sets and uses them for memory management. - */ - public List temp_vars; - } + public List temp_vars; } -- 2.7.4