Commit dbf533d6 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

Drop deprecated support for static classes and interfaces

2008-11-02  Jürg Billeter  <j@bitron.ch>

	* vala/valaclass.vala:
	* vala/valagenieparser.vala:
	* vala/valainterface.vala:
	* vala/valainterfacewriter.vala:
	* vala/valaparser.vala:
	* vala/valasemanticanalyzer.vala:
	* gobject/valaccodebasemodule.vala:
	* gobject/valaccodemethodmodule.vala:
	* gobject/valaclassregisterfunction.vala:
	* gobject/valagobjectclassmodule.vala:
	* gobject/valagobjectinterfacemodule.vala:

	Drop deprecated support for static classes and interfaces

svn path=/trunk/; revision=1956
parent 9fb6c7f5
2008-11-02 Jürg Billeter <j@bitron.ch>
* vala/valaclass.vala:
* vala/valagenieparser.vala:
* vala/valainterface.vala:
* vala/valainterfacewriter.vala:
* vala/valaparser.vala:
* vala/valasemanticanalyzer.vala:
* gobject/valaccodebasemodule.vala:
* gobject/valaccodemethodmodule.vala:
* gobject/valaclassregisterfunction.vala:
* gobject/valagobjectclassmodule.vala:
* gobject/valagobjectinterfacemodule.vala:
Drop deprecated support for static classes and interfaces
2008-11-02 Jürg Billeter <j@bitron.ch>
* vapi/glib-2.0.vapi:
......
......@@ -300,16 +300,12 @@ public class Vala.CCodeBaseModule : CCodeModule {
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (st.get_cname ()), new CCodeVariableDeclarator (st.get_cname ())));
} else if (node is Class) {
var cl = (Class) node;
if (!cl.is_static) {
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (cl.get_cname ()), new CCodeVariableDeclarator (cl.get_cname ())));
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%sClass".printf (cl.get_cname ()), new CCodeVariableDeclarator ("%sClass".printf (cl.get_cname ()))));
}
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (cl.get_cname ()), new CCodeVariableDeclarator (cl.get_cname ())));
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%sClass".printf (cl.get_cname ()), new CCodeVariableDeclarator ("%sClass".printf (cl.get_cname ()))));
} else if (node is Interface) {
var iface = (Interface) node;
if (!iface.is_static) {
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (iface.get_cname ()), new CCodeVariableDeclarator (iface.get_cname ())));
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (iface.get_type_cname ()), new CCodeVariableDeclarator (iface.get_type_cname ())));
}
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (iface.get_cname ()), new CCodeVariableDeclarator (iface.get_cname ())));
codegen.header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (iface.get_type_cname ()), new CCodeVariableDeclarator (iface.get_type_cname ())));
}
}
}
......
......@@ -157,13 +157,6 @@ public class Vala.CCodeMethodModule : CCodeModule {
codegen.current_method_inner_error = old_method_inner_error;
codegen.next_temp_var_id = old_next_temp_var_id;
if (codegen.current_type_symbol is Interface) {
var iface = (Interface) codegen.current_type_symbol;
if (iface.is_static) {
return;
}
}
codegen.function = new CCodeFunction (m.get_real_cname (), get_creturn_type (m, creturn_type.get_cname ()));
m.ccodenode = codegen.function;
......
......@@ -87,7 +87,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
public override string? get_gtype_value_table_init_function_name () {
bool is_fundamental = !class_reference.is_compact && !class_reference.is_static && class_reference.base_class == null;
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
return "%s_init".printf (class_reference.get_lower_case_cname ("value_"));
......@@ -95,7 +95,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
public override string? get_gtype_value_table_free_function_name () {
bool is_fundamental = !class_reference.is_compact && !class_reference.is_static && class_reference.base_class == null;
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
return "%s_free_value".printf (class_reference.get_lower_case_cname ("value_"));
......@@ -103,7 +103,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
public override string? get_gtype_value_table_copy_function_name () {
bool is_fundamental = !class_reference.is_compact && !class_reference.is_static && class_reference.base_class == null;
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
return "%s_copy_value".printf (class_reference.get_lower_case_cname ("value_"));
......@@ -111,7 +111,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
public override string? get_gtype_value_table_peek_pointer_function_name () {
bool is_fundamental = !class_reference.is_compact && !class_reference.is_static && class_reference.base_class == null;
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
return "%s_peek_pointer".printf (class_reference.get_lower_case_cname ("value_"));
......@@ -119,7 +119,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
public override string? get_gtype_value_table_collect_value_function_name () {
bool is_fundamental = !class_reference.is_compact && !class_reference.is_static && class_reference.base_class == null;
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
return "%s_collect_value".printf (class_reference.get_lower_case_cname ("value_"));
......@@ -127,7 +127,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
public override string? get_gtype_value_table_lcopy_value_function_name () {
bool is_fundamental = !class_reference.is_compact && !class_reference.is_static && class_reference.base_class == null;
bool is_fundamental = !class_reference.is_compact && class_reference.base_class == null;
if ( is_fundamental )
return "%s_lcopy_value".printf (class_reference.get_lower_case_cname ("value_"));
......
......@@ -44,7 +44,7 @@ public class Vala.GObjectClassModule : CCodeModule {
codegen.current_type_symbol = cl;
codegen.current_class = cl;
bool is_gtypeinstance = !cl.is_compact && !cl.is_static;
bool is_gtypeinstance = !cl.is_compact;
bool is_gobject = cl.is_subtype_of (codegen.gobject_type);
bool is_fundamental = is_gtypeinstance && cl.base_class == null;
......@@ -55,17 +55,14 @@ public class Vala.GObjectClassModule : CCodeModule {
}
if (!cl.is_static) {
codegen.instance_struct = new CCodeStruct ("_%s".printf (cl.get_cname ()));
codegen.type_struct = new CCodeStruct ("_%sClass".printf (cl.get_cname ()));
codegen.instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (cl.get_cname ()));
codegen.prop_enum = new CCodeEnum ();
codegen.prop_enum.add_value (new CCodeEnumValue ("%s_DUMMY_PROPERTY".printf (cl.get_upper_case_cname (null))));
codegen.class_init_fragment = new CCodeFragment ();
codegen.instance_init_fragment = new CCodeFragment ();
codegen.instance_finalize_fragment = new CCodeFragment ();
}
codegen.instance_struct = new CCodeStruct ("_%s".printf (cl.get_cname ()));
codegen.type_struct = new CCodeStruct ("_%sClass".printf (cl.get_cname ()));
codegen.instance_priv_struct = new CCodeStruct ("_%sPrivate".printf (cl.get_cname ()));
codegen.prop_enum = new CCodeEnum ();
codegen.prop_enum.add_value (new CCodeEnumValue ("%s_DUMMY_PROPERTY".printf (cl.get_upper_case_cname (null))));
codegen.class_init_fragment = new CCodeFragment ();
codegen.instance_init_fragment = new CCodeFragment ();
codegen.instance_finalize_fragment = new CCodeFragment ();
CCodeFragment decl_frag;
......@@ -101,7 +98,7 @@ public class Vala.GObjectClassModule : CCodeModule {
}
if (!cl.is_static && cl.source_reference.file.cycle == null) {
if (cl.source_reference.file.cycle == null) {
decl_frag.append (new CCodeTypeDefinition ("struct %s".printf (codegen.instance_struct.name), new CCodeVariableDeclarator (cl.get_cname ())));
}
......@@ -132,12 +129,10 @@ public class Vala.GObjectClassModule : CCodeModule {
}
}
if (!cl.is_static) {
if (cl.source_reference.comment != null) {
def_frag.append (new CCodeComment (cl.source_reference.comment));
}
def_frag.append (codegen.instance_struct);
if (cl.source_reference.comment != null) {
def_frag.append (new CCodeComment (cl.source_reference.comment));
}
def_frag.append (codegen.instance_struct);
if (is_gtypeinstance) {
def_frag.append (codegen.type_struct);
......@@ -274,7 +269,7 @@ public class Vala.GObjectClassModule : CCodeModule {
codegen.source_type_member_definition.append (ref_fun);
codegen.source_type_member_definition.append (unref_fun);
}
} else if (!cl.is_static) {
} else {
add_instance_init_function (cl);
var function = new CCodeFunction (cl.get_lower_case_cprefix () + "free", "void");
......@@ -688,7 +683,7 @@ public class Vala.GObjectClassModule : CCodeModule {
init_block.add_statement (new CCodeExpressionStatement (parent_assignment));
if (!cl.is_compact && !cl.is_static && !cl.is_subtype_of (codegen.gobject_type) && (cl.get_fields ().size > 0 || cl.destructor != null || cl.is_fundamental ())) {
if (!cl.is_compact && !cl.is_subtype_of (codegen.gobject_type) && (cl.get_fields ().size > 0 || cl.destructor != null || cl.is_fundamental ())) {
// set finalize function
var fundamental_class = cl;
while (fundamental_class.base_class != null) {
......
......@@ -48,51 +48,47 @@ public class Vala.GObjectInterfaceModule : CCodeModule {
def_frag = codegen.source_type_definition;
}
if (!iface.is_static) {
codegen.type_struct = new CCodeStruct ("_%s".printf (iface.get_type_cname ()));
decl_frag.append (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (iface.get_lower_case_cname (null));
decl_frag.append (new CCodeMacroReplacement (iface.get_type_id (), macro));
codegen.type_struct = new CCodeStruct ("_%s".printf (iface.get_type_cname ()));
decl_frag.append (new CCodeNewline ());
var macro = "(%s_get_type ())".printf (iface.get_lower_case_cname (null));
decl_frag.append (new CCodeMacroReplacement (iface.get_type_id (), macro));
macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (iface.get_type_id (), iface.get_cname ());
decl_frag.append (new CCodeMacroReplacement ("%s(obj)".printf (iface.get_upper_case_cname (null)), macro));
macro = "(G_TYPE_CHECK_INSTANCE_CAST ((obj), %s, %s))".printf (iface.get_type_id (), iface.get_cname ());
decl_frag.append (new CCodeMacroReplacement ("%s(obj)".printf (iface.get_upper_case_cname (null)), macro));
macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (iface.get_type_id ());
decl_frag.append (new CCodeMacroReplacement ("%s(obj)".printf (codegen.get_type_check_function (iface)), macro));
macro = "(G_TYPE_CHECK_INSTANCE_TYPE ((obj), %s))".printf (iface.get_type_id ());
decl_frag.append (new CCodeMacroReplacement ("%s(obj)".printf (codegen.get_type_check_function (iface)), macro));
macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %s))".printf (iface.get_type_id (), iface.get_type_cname ());
decl_frag.append (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf (iface.get_upper_case_cname (null)), macro));
decl_frag.append (new CCodeNewline ());
macro = "(G_TYPE_INSTANCE_GET_INTERFACE ((obj), %s, %s))".printf (iface.get_type_id (), iface.get_type_cname ());
decl_frag.append (new CCodeMacroReplacement ("%s_GET_INTERFACE(obj)".printf (iface.get_upper_case_cname (null)), macro));
decl_frag.append (new CCodeNewline ());
if (iface.source_reference.file.cycle == null) {
decl_frag.append (new CCodeTypeDefinition ("struct _%s".printf (iface.get_cname ()), new CCodeVariableDeclarator (iface.get_cname ())));
decl_frag.append (new CCodeTypeDefinition ("struct %s".printf (codegen.type_struct.name), new CCodeVariableDeclarator (iface.get_type_cname ())));
}
codegen.type_struct.add_field ("GTypeInterface", "parent_iface");
if (iface.source_reference.file.cycle == null) {
decl_frag.append (new CCodeTypeDefinition ("struct _%s".printf (iface.get_cname ()), new CCodeVariableDeclarator (iface.get_cname ())));
decl_frag.append (new CCodeTypeDefinition ("struct %s".printf (codegen.type_struct.name), new CCodeVariableDeclarator (iface.get_type_cname ())));
}
codegen.type_struct.add_field ("GTypeInterface", "parent_iface");
if (iface.source_reference.comment != null) {
def_frag.append (new CCodeComment (iface.source_reference.comment));
}
def_frag.append (codegen.type_struct);
if (iface.source_reference.comment != null) {
def_frag.append (new CCodeComment (iface.source_reference.comment));
}
def_frag.append (codegen.type_struct);
iface.accept_children (codegen);
if (!iface.is_static) {
add_interface_base_init_function (iface);
add_interface_base_init_function (iface);
var type_fun = new InterfaceRegisterFunction (iface, codegen);
type_fun.init_from_type ();
if (iface.access != SymbolAccessibility.PRIVATE) {
codegen.header_type_member_declaration.append (type_fun.get_declaration ());
} else {
codegen.source_type_member_declaration.append (type_fun.get_declaration ());
}
codegen.source_type_member_definition.append (type_fun.get_definition ());
var type_fun = new InterfaceRegisterFunction (iface, codegen);
type_fun.init_from_type ();
if (iface.access != SymbolAccessibility.PRIVATE) {
codegen.header_type_member_declaration.append (type_fun.get_declaration ());
} else {
codegen.source_type_member_declaration.append (type_fun.get_declaration ());
}
codegen.source_type_member_definition.append (type_fun.get_definition ());
codegen.current_type_symbol = null;
}
......
......@@ -38,12 +38,6 @@ public class Vala.Class : ObjectTypeSymbol {
*/
public bool is_abstract { get; set; }
/**
* Specifies whether this class is static. Static classes may not be
* instantiated and may only contain static members.
*/
public bool is_static { get; set; }
/**
* Instances of compact classes are fast to create and have a
* compact memory layout. Compact classes don't support runtime
......
......@@ -2403,10 +2403,6 @@ public class Vala.Genie.Parser : CodeVisitor {
if (ModifierFlags.ABSTRACT in flags) {
cl.is_abstract = true;
}
if (ModifierFlags.STATIC in flags) {
cl.is_static = true;
Report.warning (get_last_src (), "static classes are deprecated, use namespaces");
}
set_attributes (cl, attrs);
foreach (TypeParameter type_param in type_param_list) {
cl.add_type_parameter (type_param);
......@@ -2421,7 +2417,7 @@ public class Vala.Genie.Parser : CodeVisitor {
// ensure there is always a default construction method
if (!scanner.source_file.external_package
&& !cl.is_static && !cl.is_abstract
&& !cl.is_abstract
&& cl.default_construction_method == null) {
var m = new CreationMethod (cl.name, null, cl.source_reference);
m.binding = MemberBinding.STATIC;
......
......@@ -27,12 +27,6 @@ using Gee;
* Represents a class declaration in the source code.
*/
public class Vala.Interface : ObjectTypeSymbol {
/**
* Specifies whether this interface is static. Static interfaces are not
* available at run-time. They can be implemented by structs.
*/
public bool is_static { get; set; }
private Gee.List<TypeParameter> type_parameters = new ArrayList<TypeParameter> ();
private Gee.List<DataType> prerequisites = new ArrayList<DataType> ();
......
......@@ -172,9 +172,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
write_indent ();
write_accessibility (cl);
if (cl.is_static) {
write_string ("static ");
} else if (cl.is_abstract) {
if (cl.is_abstract) {
write_string ("abstract ");
}
write_string ("class ");
......
......@@ -1960,10 +1960,6 @@ public class Vala.Parser : CodeVisitor {
if (ModifierFlags.ABSTRACT in flags) {
cl.is_abstract = true;
}
if (ModifierFlags.STATIC in flags) {
cl.is_static = true;
Report.warning (get_last_src (), "static classes are deprecated, use namespaces");
}
if (ModifierFlags.EXTERN in flags || scanner.source_file.external_package) {
cl.external = true;
}
......@@ -1979,7 +1975,7 @@ public class Vala.Parser : CodeVisitor {
// ensure there is always a default construction method
if (!scanner.source_file.external_package
&& !cl.is_static && !cl.is_abstract
&& !cl.is_abstract
&& cl.default_construction_method == null) {
var m = new CreationMethod (cl.name, null, cl.source_reference);
m.access = SymbolAccessibility.PUBLIC;
......
......@@ -2744,13 +2744,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return;
}
if (cl.is_static) {
expr.value_type = null;
expr.error = true;
Report.error (expr.source_reference, "Can't create instance of static class `%s'".printf (cl.get_full_name ()));
return;
}
if (expr.symbol_reference == null) {
expr.symbol_reference = cl.default_construction_method;
}
......
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