Commit c8368984 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

fix overriding cname of creation methods

2007-03-10  Jürg Billeter  <j@bitron.ch>

	* vala/valacreationmethod.vala, vala/valamethod.vala: fix overriding
	  cname of creation methods

svn path=/trunk/; revision=229
parent 75ac8a9a
2007-03-10 Jürg Billeter <j@bitron.ch>
* vala/valacreationmethod.vala, vala/valamethod.vala: fix overriding
cname of creation methods
2007-03-07 Jürg Billeter <j@bitron.ch>
* vala/valasemanticanalyzer.vala: check whether a class implements all
......
......@@ -31,18 +31,14 @@ public class Vala.CreationMethod : Method {
*/
public int n_construction_params { get; set; }
private string cname;
/**
* Creates a new method.
*
* @param name method name
* @param source reference to source code
* @return newly created method
* @param name method name
* @param source_reference reference to source code
* @return newly created method
*/
public CreationMethod (string _name, SourceReference source = null) {
name = _name;
source_reference = source;
public CreationMethod (construct string name, construct SourceReference source_reference = null) {
}
public override void accept (CodeVisitor! visitor) {
......@@ -58,23 +54,14 @@ public class Vala.CreationMethod : Method {
visitor.visit_end_creation_method (this);
}
/**
* Returns the interface name of this method as it is used in C code.
*
* @return the name to be used in C code
*/
public override string! get_cname () {
if (cname == null) {
var parent = symbol.parent_symbol.node;
if (parent is DataType) {
if (name == null) {
cname = "%snew".printf (((DataType) parent).get_lower_case_cprefix ());
} else {
cname = "%snew_%s".printf (((DataType) parent).get_lower_case_cprefix (), name);
}
}
public override ref string! get_default_cname () {
var parent = symbol.parent_symbol.node;
assert (parent is DataType);
if (name == null) {
return "%snew".printf (((DataType) parent).get_lower_case_cprefix ());
} else {
return "%snew_%s".printf (((DataType) parent).get_lower_case_cprefix (), name);
}
return cname;
}
}
......@@ -203,20 +203,30 @@ public class Vala.Method : Member, Invokable {
*
* @return the name to be used in C code
*/
public virtual string! get_cname () {
public string! get_cname () {
if (cname == null) {
var parent = symbol.parent_symbol.node;
if (parent is DataType) {
cname = "%s%s".printf (((DataType) parent).get_lower_case_cprefix (), name);
} else if (parent is Namespace) {
cname = "%s%s".printf (((Namespace) parent).get_lower_case_cprefix (), name);
} else {
cname = name;
}
cname = get_default_cname ();
}
return cname;
}
/**
* Returns the default interface name of this method as it is used in C
* code.
*
* @return the name to be used in C code by default
*/
public virtual ref string! get_default_cname () {
var parent = symbol.parent_symbol.node;
if (parent is DataType) {
return "%s%s".printf (((DataType) parent).get_lower_case_cprefix (), name);
} else if (parent is Namespace) {
return "%s%s".printf (((Namespace) parent).get_lower_case_cprefix (), name);
} else {
return name;
}
}
/**
* Returns the implementation name of this data type as it is used in C
* code.
......
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