Commit 3956d849 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

create code nodes with factory methods to support backend-specific code

2007-09-20  Juerg Billeter  <j@bitron.ch>

	* vala/parser.y, vala/vala.h, vala/valacodecontext.vala,
	  vala/valacodegenerator.vala, gobject/Makefile.am,
	  gobject/valaccodebinding.vala, gobject/valaccodegenerator.vala,
	  gobject/valadbusbindingprovider.vala: create code nodes with factory
	  methods to support backend-specific code bindings

svn path=/trunk/; revision=624
parent 3b909493
2007-09-20 Jürg Billeter <j@bitron.ch>
* vala/parser.y, vala/vala.h, vala/valacodecontext.vala,
vala/valacodegenerator.vala, gobject/Makefile.am,
gobject/valaccodebinding.vala, gobject/valaccodegenerator.vala,
gobject/valadbusbindingprovider.vala: create code nodes with factory
methods to support backend-specific code bindings
2007-09-20 Raffaele Sandrini <raffaele@sandrini.ch>
* vala/parser.y: Add support for ownership transfer with properties
......
......@@ -13,12 +13,12 @@ lib_LTLIBRARIES = \
libvala_la_SOURCES = \
gobject.vala.stamp \
valaccodebinding.c \
valaccodebinding.h \
valaccodebinding.vala \
valaccodecompiler.c \
valaccodecompiler.h \
valaccodecompiler.vala \
valaclassregisterfunction.c \
valaclassregisterfunction.h \
valaclassregisterfunction.vala \
valaccodegenerator.c \
valaccodegenerator.h \
valaccodegenerator.vala \
......@@ -49,6 +49,9 @@ libvala_la_SOURCES = \
valaccodegeneratorstruct.c \
valaccodegeneratorstruct.h \
valaccodegeneratorstruct.vala \
valaclassregisterfunction.c \
valaclassregisterfunction.h \
valaclassregisterfunction.vala \
valadbusbindingprovider.c \
valadbusbindingprovider.h \
valadbusbindingprovider.vala \
......@@ -69,8 +72,8 @@ libvala_la_SOURCES = \
gobjectincludedir = $(includedir)/vala-1.0/gobject
gobjectinclude_HEADERS = \
valaccodebinding.h \
valaccodecompiler.h \
valaclassregisterfunction.h \
valaccodegenerator.h \
valaccodegeneratorassignment.h \
valaccodegeneratorclass.h \
......@@ -81,6 +84,7 @@ gobjectinclude_HEADERS = \
valaccodegeneratorsignal.h \
valaccodegeneratorsourcefile.h \
valaccodegeneratorstruct.h \
valaclassregisterfunction.h \
valadbusbindingprovider.h \
valadbusmethod.h \
valadbussignal.h \
......
/* valaccodebinding.vala
*
* Copyright (C) 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
using GLib;
/**
* The link between a source code node and generated code.
*/
public abstract class Vala.CCodeBinding : CodeBinding {
/**
* The C Code generator.
*/
public CCodeGenerator codegen { get; set; }
}
......@@ -2808,4 +2808,279 @@ public class Vala.CCodeGenerator : CodeGenerator {
return cexpr;
}
}
public override CodeBinding create_namespace_binding (Namespace! node) {
return null;
}
public override CodeBinding create_class_binding (Class! node) {
return null;
}
public override CodeBinding create_struct_binding (Struct! node) {
return null;
}
public override CodeBinding create_interface_binding (Interface! node) {
return null;
}
public override CodeBinding create_enum_binding (Enum! node) {
return null;
}
public override CodeBinding create_enum_value_binding (EnumValue! node) {
return null;
}
public override CodeBinding create_callback_binding (Callback! node) {
return null;
}
public override CodeBinding create_constant_binding (Constant! node) {
return null;
}
public override CodeBinding create_field_binding (Field! node) {
return null;
}
public override CodeBinding create_method_binding (Method! node) {
return null;
}
public override CodeBinding create_creation_method_binding (CreationMethod! node) {
return null;
}
public override CodeBinding create_formal_parameter_binding (FormalParameter! node) {
return null;
}
public override CodeBinding create_property_binding (Property! node) {
return null;
}
public override CodeBinding create_property_accessor_binding (PropertyAccessor! node) {
return null;
}
public override CodeBinding create_signal_binding (Signal! node) {
return null;
}
public override CodeBinding create_constructor_binding (Constructor! node) {
return null;
}
public override CodeBinding create_destructor_binding (Destructor! node) {
return null;
}
public override CodeBinding create_type_parameter_binding (TypeParameter! node) {
return null;
}
public override CodeBinding create_block_binding (Block! node) {
return null;
}
public override CodeBinding create_empty_statement_binding (EmptyStatement! node) {
return null;
}
public override CodeBinding create_declaration_statement_binding (DeclarationStatement! node) {
return null;
}
public override CodeBinding create_local_variable_declaration_binding (LocalVariableDeclaration! node) {
return null;
}
public override CodeBinding create_variable_declarator_binding (VariableDeclarator! node) {
return null;
}
public override CodeBinding create_initializer_list_binding (InitializerList! node) {
return null;
}
public override CodeBinding create_expression_statement_binding (ExpressionStatement! node) {
return null;
}
public override CodeBinding create_if_statement_binding (IfStatement! node) {
return null;
}
public override CodeBinding create_switch_statement_binding (SwitchStatement! node) {
return null;
}
public override CodeBinding create_switch_section_binding (SwitchSection! node) {
return null;
}
public override CodeBinding create_switch_label_binding (SwitchLabel! node) {
return null;
}
public override CodeBinding create_while_statement_binding (WhileStatement! node) {
return null;
}
public override CodeBinding create_do_statement_binding (DoStatement! node) {
return null;
}
public override CodeBinding create_for_statement_binding (ForStatement! node) {
return null;
}
public override CodeBinding create_foreach_statement_binding (ForeachStatement! node) {
return null;
}
public override CodeBinding create_break_statement_binding (BreakStatement! node) {
return null;
}
public override CodeBinding create_continue_statement_binding (ContinueStatement! node) {
return null;
}
public override CodeBinding create_return_statement_binding (ReturnStatement! node) {
return null;
}
public override CodeBinding create_throw_statement_binding (ThrowStatement! node) {
return null;
}
public override CodeBinding create_try_statement_binding (TryStatement! node) {
return null;
}
public override CodeBinding create_catch_clause_binding (CatchClause! node) {
return null;
}
public override CodeBinding create_lock_statement_binding (LockStatement! node) {
return null;
}
public override CodeBinding create_array_creation_expression_binding (ArrayCreationExpression! node) {
return null;
}
public override CodeBinding create_boolean_literal_binding (BooleanLiteral! node) {
return null;
}
public override CodeBinding create_character_literal_binding (CharacterLiteral! node) {
return null;
}
public override CodeBinding create_integer_literal_binding (IntegerLiteral! node) {
return null;
}
public override CodeBinding create_real_literal_binding (RealLiteral! node) {
return null;
}
public override CodeBinding create_string_literal_binding (StringLiteral! node) {
return null;
}
public override CodeBinding create_null_literal_binding (NullLiteral! node) {
return null;
}
public override CodeBinding create_literal_expression_binding (LiteralExpression! node) {
return null;
}
public override CodeBinding create_parenthesized_expression_binding (ParenthesizedExpression! node) {
return null;
}
public override CodeBinding create_member_access_binding (MemberAccess! node) {
return null;
}
public override CodeBinding create_member_access_simple_binding (MemberAccess! node) {
return null;
}
public override CodeBinding create_invocation_expression_binding (InvocationExpression! node) {
return null;
}
public override CodeBinding create_element_access_binding (ElementAccess! node) {
return null;
}
public override CodeBinding create_base_access_binding (BaseAccess! node) {
return null;
}
public override CodeBinding create_postfix_expression_binding (PostfixExpression! node) {
return null;
}
public override CodeBinding create_object_creation_expression_binding (ObjectCreationExpression! node) {
return null;
}
public override CodeBinding create_sizeof_expression_binding (SizeofExpression! node) {
return null;
}
public override CodeBinding create_typeof_expression_binding (TypeofExpression! node) {
return null;
}
public override CodeBinding create_unary_expression_binding (UnaryExpression! node) {
return null;
}
public override CodeBinding create_cast_expression_binding (CastExpression! node) {
return null;
}
public override CodeBinding create_pointer_indirection_binding (PointerIndirection! node) {
return null;
}
public override CodeBinding create_addressof_expression_binding (AddressofExpression! node) {
return null;
}
public override CodeBinding create_reference_transfer_expression_binding (ReferenceTransferExpression! node) {
return null;
}
public override CodeBinding create_binary_expression_binding (BinaryExpression! node) {
return null;
}
public override CodeBinding create_type_check_binding (TypeCheck! node) {
return null;
}
public override CodeBinding create_conditional_expression_binding (ConditionalExpression! node) {
return null;
}
public override CodeBinding create_lambda_expression_binding (LambdaExpression! node) {
return null;
}
public override CodeBinding create_lambda_expression_with_statement_body_binding (LambdaExpression! node) {
return null;
}
public override CodeBinding create_assignment_binding (Assignment! node) {
return null;
}
}
......@@ -64,14 +64,14 @@ public class Vala.DBusBindingProvider : Object, BindingProvider {
if (!is_dbus_interface (ret_type.data_type)) {
return null;
}
var m = new Method ("get_object", ret_type, ma.source_reference);
var m = _context.create_method ("get_object", ret_type, ma.source_reference);
m.set_cname ("dbus_g_proxy_new_for_name");
m.add_cheader_filename ("dbus/dbus-glib.h");
m.access = SymbolAccessibility.PUBLIC;
var string_type_ref = new TypeReference ();
string_type_ref.data_type = string_type;
m.add_parameter (new FormalParameter ("name", string_type_ref));
m.add_parameter (new FormalParameter ("path", string_type_ref));
m.add_parameter (_context.create_formal_parameter ("name", string_type_ref));
m.add_parameter (_context.create_formal_parameter ("path", string_type_ref));
symbols.add (m);
return m;
} else if (ma.inner != null && ma.inner.static_type != null && is_dbus_interface (ma.inner.static_type.data_type)) {
......
This diff is collapsed.
......@@ -42,6 +42,7 @@
#include <vala/valalocalvariabledeclaration.h>
#include <vala/valalockstatement.h>
#include <vala/valamemberaccess.h>
#include <vala/valamemberinitializer.h>
#include <vala/valamethod.h>
#include <vala/valanamedargument.h>
#include <vala/valanamespace.h>
......
......@@ -338,4 +338,442 @@ public class Vala.CodeContext : Object {
/* mark file as successfully visited */
file.mark = 2;
}
public Namespace! create_namespace (string name, SourceReference source_reference = null) {
var node = new Namespace (name, source_reference);
node.code_binding = codegen.create_namespace_binding (node);
return node;
}
public Class! create_class (string! name, SourceReference source_reference = null) {
var node = new Class (name, source_reference);
node.code_binding = codegen.create_class_binding (node);
return node;
}
public Struct! create_struct (string! name, SourceReference source_reference = null) {
var node = new Struct (name, source_reference);
node.code_binding = codegen.create_struct_binding (node);
return node;
}
public Interface! create_interface (string! name, SourceReference source_reference = null) {
var node = new Interface (name, source_reference);
node.code_binding = codegen.create_interface_binding (node);
return node;
}
public Enum! create_enum (string! name, SourceReference source_reference = null) {
var node = new Enum (name, source_reference);
node.code_binding = codegen.create_enum_binding (node);
return node;
}
public EnumValue! create_enum_value (string! name) {
var node = new EnumValue (name);
node.code_binding = codegen.create_enum_value_binding (node);
return node;
}
public EnumValue! create_enum_value_with_value (string! name, Expression value) {
var node = new EnumValue.with_value (name, value);
node.code_binding = codegen.create_enum_value_binding (node);
return node;
}
public Callback! create_callback (string name, TypeReference return_type, SourceReference source_reference = null) {
var node = new Callback (name, return_type, source_reference);
node.code_binding = codegen.create_callback_binding (node);
return node;
}
public Constant! create_constant (string! name, TypeReference! type_reference, Expression initializer, SourceReference source_reference) {
var node = new Constant (name, type_reference, initializer, source_reference);
node.code_binding = codegen.create_constant_binding (node);
return node;
}
public Field! create_field (string! name, TypeReference! type_reference, Expression initializer, SourceReference source_reference = null) {
var node = new Field (name, type_reference, initializer, source_reference);
node.code_binding = codegen.create_field_binding (node);
return node;
}
public Method! create_method (string name, TypeReference return_type, SourceReference source_reference = null) {
var node = new Method (name, return_type, source_reference);
node.code_binding = codegen.create_method_binding (node);
return node;
}
public CreationMethod! create_creation_method (string name, SourceReference source_reference = null) {
var node = new CreationMethod (name, source_reference);
node.code_binding = codegen.create_creation_method_binding (node);
return node;
}
public FormalParameter! create_formal_parameter (string! name, TypeReference type_reference, SourceReference source_reference = null) {
var node = new FormalParameter (name, type_reference, source_reference);
node.code_binding = codegen.create_formal_parameter_binding (node);
return node;
}
public FormalParameter! create_formal_parameter_with_ellipsis (SourceReference source_reference = null) {
var node = new FormalParameter.with_ellipsis (source_reference);
node.code_binding = codegen.create_formal_parameter_binding (node);
return node;
}
public Property! create_property (string! name, TypeReference! type_reference, PropertyAccessor get_accessor, PropertyAccessor set_accessor, SourceReference source_reference) {
var node = new Property (name, type_reference, get_accessor, set_accessor, source_reference);
node.code_binding = codegen.create_property_binding (node);
return node;
}
public PropertyAccessor! create_property_accessor (bool readable, bool writable, bool construction, Block body, SourceReference source_reference) {
var node = new PropertyAccessor (readable, writable, construction, body, source_reference);
node.code_binding = codegen.create_property_accessor_binding (node);
return node;
}
public Signal! create_signal (string! name, TypeReference! return_type, SourceReference source_reference = null) {
var node = new Signal (name, return_type, source_reference);
node.code_binding = codegen.create_signal_binding (node);
return node;
}
public Constructor! create_constructor (SourceReference source_reference) {
var node = new Constructor (source_reference);
node.code_binding = codegen.create_constructor_binding (node);
return node;
}
public Destructor! create_destructor (SourceReference source_reference = null) {
var node = new Destructor (source_reference);
node.code_binding = codegen.create_destructor_binding (node);
return node;
}
public TypeParameter! create_type_parameter (string name, SourceReference source_reference) {
var node = new TypeParameter (name, source_reference);
node.code_binding = codegen.create_type_parameter_binding (node);
return node;
}
public Block! create_block (SourceReference source_reference = null) {
var node = new Block (source_reference);
node.code_binding = codegen.create_block_binding (node);
return node;
}
public EmptyStatement! create_empty_statement (SourceReference source_reference = null) {
var node = new EmptyStatement (source_reference);
node.code_binding = codegen.create_empty_statement_binding (node);
return node;
}
public DeclarationStatement! create_declaration_statement (LocalVariableDeclaration! declaration, SourceReference source_reference) {
var node = new DeclarationStatement (declaration, source_reference);
node.code_binding = codegen.create_declaration_statement_binding (node);
return node;
}
public LocalVariableDeclaration! create_local_variable_declaration (TypeReference type_reference, SourceReference source_reference) {
var node = new LocalVariableDeclaration (type_reference, source_reference);
node.code_binding = codegen.create_local_variable_declaration_binding (node);
return node;
}
public LocalVariableDeclaration! create_local_variable_declaration_var_type (SourceReference source_reference) {
var node = new LocalVariableDeclaration.var_type (source_reference);
node.code_binding = codegen.create_local_variable_declaration_binding (node);
return node;
}
public VariableDeclarator! create_variable_declarator (string! name, Expression initializer = null, SourceReference source_reference = null) {
var node = new VariableDeclarator (name, initializer, source_reference);
node.code_binding = codegen.create_variable_declarator_binding (node);
return node;
}
public InitializerList! create_initializer_list (SourceReference source_reference) {
var node = new InitializerList (source_reference);
node.code_binding = codegen.create_initializer_list_binding (node);
return node;
}
public ExpressionStatement! create_expression_statement (Expression! expression, SourceReference source_reference = null) {
var node = new ExpressionStatement (expression, source_reference);
node.code_binding = codegen.create_expression_statement_binding (node);
return node;
}
public IfStatement! create_if_statement (Expression! condition, Block! true_statement, Block false_statement, SourceReference source_reference) {
var node = new IfStatement (condition, true_statement, false_statement, source_reference);
node.code_binding = codegen.create_if_statement_binding (node);
return node;
}
public SwitchStatement! create_switch_statement (Expression! expression, SourceReference source_reference) {
var node = new SwitchStatement (expression, source_reference);
node.code_binding = codegen.create_switch_statement_binding (node);
return node;
}
public SwitchSection! create_switch_section (SourceReference source_reference) {
var node = new SwitchSection (source_reference);
node.code_binding = codegen.create_switch_section_binding (node);
return node;
}
public SwitchLabel! create_switch_label (Expression expression, SourceReference source_reference = null) {
var node = new SwitchLabel (expression, source_reference);
node.code_binding = codegen.create_switch_label_binding (node);
return node;
}
public SwitchLabel! create_switch_label_with_default (SourceReference source_reference = null) {
var node = new SwitchLabel.with_default (source_reference);
node.code_binding = codegen.create_switch_label_binding (node);
return node;
}
public WhileStatement! create_while_statement (Expression! condition, Block! body, SourceReference source_reference = null) {
var node = new WhileStatement (condition, body, source_reference);
node.code_binding = codegen.create_while_statement_binding (node);
return node;
}
public DoStatement! create_do_statement (Block! body, Expression! condition, SourceReference source_reference = null) {
var node = new DoStatement (