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

rename MemberAccessibility to SymbolAccessibility and move its declaration

2007-08-30  Juerg Billeter  <j@bitron.ch>

	* vala/valamemberaccessibility.vala: rename MemberAccessibility to
	  SymbolAccessibility and move its declaration to vala/valasymbol.vala
	* vala/parser.y: store accessibility modifier for properties and follow
	  the renames caused by the accessibility releated refactoring, cast
	  the Struct allocated in struct_declaration to silence gcc
	* vala/Makefile.am: remove valamemberaccessibility.* files
	* vala/valasymbol.vala: add access property found in serveral
	  sub-classes and add is_internal_symbol () method, which considers
	  parent symbols to determinate if a symbol belongs to internal API
	* gobject/*, vala/*, vapigen/valagidlparser.vala:
	  move the access property/field found in several Symbol derived
	  classes to the Symbol class where it belongs and rename the
	  MemberAccessibility enumeration to SymbolAccessibility

	* vala/valaformalparameter.vala, vala/valanamespace.vala: set access
	  to public on initialization, as there is no accessibility modifier
	* gobject/valacodegenerator.vala: do not add internal symbols to
	  header_type_member_declarations
	* vala/valasemanticanalyzer.vala: do not add HEADER_SHALLOW symbol
	  dependencies for internal symbols
	* gobject/valacodegeneratormethod.vala: consider all anchestors,
	  not just the parent for visibility

	patch by Mathias Hasselmann, fixes bug 471475

svn path=/trunk/; revision=546
parent dafce8e1
2007-08-30 Jürg Billeter <j@bitron.ch>
* vala/valamemberaccessibility.vala: rename MemberAccessibility to
SymbolAccessibility and move its declaration to vala/valasymbol.vala
* vala/parser.y: store accessibility modifier for properties and follow
the renames caused by the accessibility releated refactoring, cast
the Struct allocated in struct_declaration to silence gcc
* vala/Makefile.am: remove valamemberaccessibility.* files
* vala/valasymbol.vala: add access property found in serveral
sub-classes and add is_internal_symbol () method, which considers
parent symbols to determinate if a symbol belongs to internal API
* gobject/*, vala/*, vapigen/valagidlparser.vala:
move the access property/field found in several Symbol derived
classes to the Symbol class where it belongs and rename the
MemberAccessibility enumeration to SymbolAccessibility
* vala/valaformalparameter.vala, vala/valanamespace.vala: set access
to public on initialization, as there is no accessibility modifier
* gobject/valacodegenerator.vala: do not add internal symbols to
header_type_member_declarations
* vala/valasemanticanalyzer.vala: do not add HEADER_SHALLOW symbol
dependencies for internal symbols
* gobject/valacodegeneratormethod.vala: consider all anchestors,
not just the parent for visibility
patch by Mathias Hasselmann, fixes bug 471475
2007-08-30 Jürg Billeter <j@bitron.ch>
* vala/valaclass.vala, vala/valainterfacewriter.vala,
......
......@@ -77,7 +77,7 @@ public class Vala.ClassRegisterFunction : TypeRegisterFunction {
}
}
public override MemberAccessibility get_accessibility () {
public override SymbolAccessibility get_accessibility () {
return class_reference.access;
}
......
......@@ -345,7 +345,7 @@ public class Vala.CodeGenerator : CodeVisitor {
var ctypedef = new CCodeTypeDefinition (cb.return_type.get_cname (), cfundecl);
if (cb.access != MemberAccessibility.PRIVATE) {
if (!cb.is_internal_symbol ()) {
header_type_definition.append (ctypedef);
} else {
source_type_member_declaration.append (ctypedef);
......@@ -395,7 +395,7 @@ public class Vala.CodeGenerator : CodeVisitor {
cdecl.add_declarator (new CCodeVariableDeclarator.with_initializer ("%s%s".printf (c.get_cname (), arr), (CCodeExpression) c.initializer.ccodenode));
cdecl.modifiers = CCodeModifiers.STATIC;
if (c.access != MemberAccessibility.PRIVATE) {
if (!c.is_internal_symbol ()) {
header_type_member_declaration.append (cdecl);
} else {
source_type_member_declaration.append (cdecl);
......@@ -409,7 +409,7 @@ public class Vala.CodeGenerator : CodeVisitor {
CCodeExpression lhs = null;
CCodeStruct st = null;
if (f.access != MemberAccessibility.PRIVATE) {
if (f.access != SymbolAccessibility.PRIVATE) {
st = instance_struct;
if (f.instance) {
lhs = new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), f.get_cname ());
......@@ -432,7 +432,7 @@ public class Vala.CodeGenerator : CodeVisitor {
lhs = new CCodeIdentifier (f.get_cname ());
}
} else if (f.access == MemberAccessibility.PRIVATE) {
} else if (f.access == SymbolAccessibility.PRIVATE) {
if (f.instance) {
st = instance_priv_struct;
lhs = new CCodeMemberAccess.pointer (new CCodeMemberAccess.pointer (new CCodeIdentifier ("self"), "priv"), f.get_cname ());
......@@ -567,7 +567,7 @@ public class Vala.CodeGenerator : CodeVisitor {
function.add_parameter (cvalueparam);
}
if (t.access != MemberAccessibility.PRIVATE) {
if (!prop.is_internal_symbol ()) {
header_type_member_declaration.append (function.copy ());
} else {
function.modifiers |= CCodeModifiers.STATIC;
......@@ -639,7 +639,7 @@ public class Vala.CodeGenerator : CodeVisitor {
}
if (!is_virtual) {
if (t.access != MemberAccessibility.PRIVATE) {
if (!prop.is_internal_symbol ()) {
header_type_member_declaration.append (function.copy ());
} else {
function.modifiers |= CCodeModifiers.STATIC;
......@@ -2102,7 +2102,7 @@ public class Vala.CodeGenerator : CodeVisitor {
typed_inst = pub_inst;
}
CCodeExpression inst;
if (field.access == MemberAccessibility.PRIVATE) {
if (field.access == SymbolAccessibility.PRIVATE) {
inst = new CCodeMemberAccess.pointer (typed_inst, "priv");
} else {
inst = typed_inst;
......
......@@ -62,7 +62,7 @@ public class Vala.CodeGenerator {
CCodeFragment decl_frag;
CCodeFragment def_frag;
if (cl.access != MemberAccessibility.PRIVATE) {
if (cl.access != SymbolAccessibility.PRIVATE) {
decl_frag = header_type_declaration;
def_frag = header_type_definition;
} else {
......@@ -148,7 +148,7 @@ public class Vala.CodeGenerator {
var type_fun = new ClassRegisterFunction (cl);
type_fun.init_from_type (in_plugin);
if (cl.access != MemberAccessibility.PRIVATE) {
if (cl.access != SymbolAccessibility.PRIVATE) {
header_type_member_declaration.append (type_fun.get_declaration ());
} else {
source_type_member_declaration.append (type_fun.get_declaration ());
......@@ -163,7 +163,7 @@ public class Vala.CodeGenerator {
}
} else if (cl.default_construction_method != null) {
var function = new CCodeFunction (cl.get_lower_case_cprefix () + "free", "void");
if (cl.access == MemberAccessibility.PRIVATE) {
if (cl.access == SymbolAccessibility.PRIVATE) {
function.modifiers = CCodeModifiers.STATIC;
}
......
......@@ -36,7 +36,7 @@ public class Vala.CodeGenerator {
CCodeFragment decl_frag;
CCodeFragment def_frag;
if (iface.access != MemberAccessibility.PRIVATE) {
if (iface.access != SymbolAccessibility.PRIVATE) {
decl_frag = header_type_declaration;
def_frag = header_type_definition;
} else {
......@@ -82,7 +82,7 @@ public class Vala.CodeGenerator {
var type_fun = new InterfaceRegisterFunction (iface);
type_fun.init_from_type ();
if (iface.access != MemberAccessibility.PRIVATE) {
if (iface.access != SymbolAccessibility.PRIVATE) {
header_type_member_declaration.append (type_fun.get_declaration ());
} else {
source_type_member_declaration.append (type_fun.get_declaration ());
......
......@@ -69,7 +69,7 @@ public class Vala.CodeGenerator {
typed_inst = pub_inst;
}
CCodeExpression inst;
if (f.access == MemberAccessibility.PRIVATE) {
if (f.access == SymbolAccessibility.PRIVATE) {
inst = new CCodeMemberAccess.pointer (typed_inst, "priv");
} else {
inst = typed_inst;
......
......@@ -185,11 +185,7 @@ public class Vala.CodeGenerator {
}
}
bool visible = m.access != MemberAccessibility.PRIVATE;
if (m.parent_symbol is DataType) {
var dt = (DataType) m.parent_symbol;
visible = visible && dt.access != MemberAccessibility.PRIVATE;
}
bool visible = !m.is_internal_symbol ();
/* real function declaration and definition not needed
* for abstract methods */
......
......@@ -34,7 +34,7 @@ public class Vala.CodeGenerator {
CCodeFragment decl_frag;
CCodeFragment def_frag;
if (st.access != MemberAccessibility.PRIVATE) {
if (st.access != SymbolAccessibility.PRIVATE) {
decl_frag = header_type_declaration;
def_frag = header_type_definition;
} else {
......@@ -55,7 +55,7 @@ public class Vala.CodeGenerator {
if (st.default_construction_method != null) {
var function = new CCodeFunction (st.get_lower_case_cprefix () + "free", "void");
if (st.access == MemberAccessibility.PRIVATE) {
if (st.access == SymbolAccessibility.PRIVATE) {
function.modifiers = CCodeModifiers.STATIC;
}
......
......@@ -67,7 +67,7 @@ public class Vala.DBusBindingProvider : Object, BindingProvider {
var m = new 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 = MemberAccessibility.PUBLIC;
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));
......@@ -88,7 +88,7 @@ public class Vala.DBusBindingProvider : Object, BindingProvider {
error_type.data_type = dbus_error_type;
m.add_error_domain (error_type);
}
m.access = MemberAccessibility.PUBLIC;
m.access = SymbolAccessibility.PUBLIC;
m.add_parameter (new FormalParameter.with_ellipsis ());
symbols.add (m);
return m;
......@@ -98,7 +98,7 @@ public class Vala.DBusBindingProvider : Object, BindingProvider {
return null;
}
var s = new DBusSignal (ma.member_name, new TypeReference (), ma.source_reference);
s.access = MemberAccessibility.PUBLIC;
s.access = SymbolAccessibility.PUBLIC;
symbols.add (s);
return s;
}
......
......@@ -64,7 +64,7 @@ public class Vala.InterfaceRegisterFunction : TypeRegisterFunction {
return "G_TYPE_INTERFACE";
}
public override MemberAccessibility get_accessibility () {
public override SymbolAccessibility get_accessibility () {
return interface_reference.access;
}
......
......@@ -50,7 +50,7 @@ public abstract class Vala.TypeRegisterFunction : Object {
if (!plugin) {
fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
/* Function will not be prototyped anyway */
if (get_accessibility () == MemberAccessibility.PRIVATE) {
if (get_accessibility () == SymbolAccessibility.PRIVATE) {
fun.modifiers = CCodeModifiers.STATIC;
}
} else {
......@@ -58,7 +58,7 @@ public abstract class Vala.TypeRegisterFunction : Object {
fun.add_parameter (new CCodeFormalParameter ("module", "GTypeModule *"));
var get_fun = new CCodeFunction ("%s_get_type".printf (get_type_declaration ().get_lower_case_cname (null)), "GType");
if (get_accessibility () == MemberAccessibility.PRIVATE) {
if (get_accessibility () == SymbolAccessibility.PRIVATE) {
fun.modifiers = CCodeModifiers.STATIC;
}
......@@ -206,5 +206,5 @@ public abstract class Vala.TypeRegisterFunction : Object {
/**
* Returns the accessibility for this type.
*/
public abstract MemberAccessibility get_accessibility ();
public abstract SymbolAccessibility get_accessibility ();
}
......@@ -191,9 +191,6 @@ libvalacore_la_SOURCES = \
valamemberaccess.c \
valamemberaccess.h \
valamemberaccess.vala \
valamemberaccessibility.c \
valamemberaccessibility.h \
valamemberaccessibility.vala \
valamemorymanager.c \
valamemorymanager.h \
valamemorymanager.vala \
......@@ -384,7 +381,6 @@ valainclude_HEADERS = \
valalockstatement.h \
valamember.h \
valamemberaccess.h \
valamemberaccessibility.h \
valamemorymanager.h \
valamethod.h \
valanamedargument.h \
......
......@@ -2436,7 +2436,7 @@ class_declaration
VALA_CODE_NODE (current_symbol)->attributes = $2;
if ($3 != 0) {
VALA_DATA_TYPE (current_symbol)->access = $3;
vala_symbol_set_access (VALA_SYMBOL (current_symbol), $3);
}
if (($4 & VALA_MODIFIER_ABSTRACT) == VALA_MODIFIER_ABSTRACT) {
vala_class_set_is_abstract (VALA_CLASS (current_symbol), TRUE);
......@@ -2482,15 +2482,15 @@ opt_access_modifier
access_modifier
: PUBLIC
{
$$ = VALA_MEMBER_ACCESSIBILITY_PUBLIC;
$$ = VALA_SYMBOL_ACCESSIBILITY_PUBLIC;
}
| PROTECTED
{
$$ = VALA_MEMBER_ACCESSIBILITY_PROTECTED;
$$ = VALA_SYMBOL_ACCESSIBILITY_PROTECTED;
}
| PRIVATE
{
$$ = VALA_MEMBER_ACCESSIBILITY_PRIVATE;
$$ = VALA_SYMBOL_ACCESSIBILITY_PRIVATE;
}
;
......@@ -2644,7 +2644,7 @@ constant_declaration
g_object_unref ($5);
g_object_unref ($6);
if ($3 != 0) {
$$->access = $3;
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
}
;
......@@ -2666,7 +2666,7 @@ field_declaration
$$ = vala_field_new (vala_symbol_get_name (VALA_SYMBOL ($6)), $5, vala_variable_declarator_get_initializer ($6), src);
g_object_unref (src);
if ($3 != 0) {
$$->access = $3;
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
vala_field_set_instance ($$, FALSE);
......@@ -2811,7 +2811,7 @@ method_header
$$ = vala_method_new ($6, $5, src);
g_object_unref (src);
if ($3 != 0) {
$$->access = $3;
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
vala_method_set_instance ($$, FALSE);
......@@ -2860,7 +2860,7 @@ method_header
g_object_unref (src);
vala_method_set_instance ($$, FALSE);
if ($3 != 0) {
$$->access = $3;
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
VALA_CODE_NODE($$)->attributes = $2;
......@@ -2993,6 +2993,8 @@ property_declaration
VALA_CODE_NODE($$)->attributes = $2;
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
g_object_unref ($5);
g_free ($6);
g_object_unref ($8);
......@@ -3024,6 +3026,8 @@ property_declaration
VALA_CODE_NODE($$)->attributes = $2;
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
g_object_unref ($5);
g_free ($6);
g_object_unref ($8);
......@@ -3120,7 +3124,7 @@ signal_declaration
$$ = vala_signal_new ($6, $5, src);
g_object_unref (src);
if ($3 != 0) {
vala_signal_set_access ($$, $3);
vala_symbol_set_access (VALA_SYMBOL ($$), $3);
}
VALA_CODE_NODE($$)->attributes = $2;
......@@ -3201,7 +3205,7 @@ struct_declaration
// merge class declarations
}
} else {
current_symbol = vala_struct_new (name, src);
current_symbol = VALA_SYMBOL (vala_struct_new (name, src));
g_free (name);
g_object_unref (src);
......@@ -3219,7 +3223,7 @@ struct_declaration
}
VALA_CODE_NODE(current_symbol)->attributes = $2;
if ($3 != 0) {
VALA_DATA_TYPE(current_symbol)->access = $3;
vala_symbol_set_access (VALA_SYMBOL (current_symbol), $3);
}
if ($8 != NULL) {
for (l = $8; l != NULL; l = l->next) {
......@@ -3314,7 +3318,7 @@ interface_declaration
VALA_CODE_NODE (iface)->attributes = $2;
if ($3 != 0) {
VALA_DATA_TYPE (iface)->access = $3;
vala_symbol_set_access (VALA_SYMBOL (iface), $3);
}
if (($4 & VALA_MODIFIER_STATIC) == VALA_MODIFIER_STATIC) {
vala_interface_set_is_static (iface, TRUE);
......@@ -3442,7 +3446,7 @@ enum_declaration
VALA_CODE_NODE (en)->attributes = $2;
if ($3 != 0) {
VALA_DATA_TYPE (en)->access = $3;
vala_symbol_set_access (VALA_SYMBOL (en), $3);
}
push_symbol (VALA_SYMBOL (en));
......@@ -3549,7 +3553,7 @@ callback_declaration
g_object_unref (parent_symbol);
if ($3 != 0) {
VALA_DATA_TYPE (cb)->access = $3;
vala_symbol_set_access (VALA_SYMBOL (cb), $3);
}
VALA_CODE_NODE (cb)->attributes = $2;
......
......@@ -155,7 +155,7 @@ public class Vala.Array : DataType {
if (length_field == null) {
length_field = new ArrayLengthField (source_reference);
length_field.access = MemberAccessibility.PUBLIC;
length_field.access = SymbolAccessibility.PUBLIC;
var root_symbol = source_reference.file.context.root;
length_field.type_reference = new TypeReference ();
......@@ -170,7 +170,7 @@ public class Vala.Array : DataType {
resize_method = new ArrayResizeMethod (source_reference);
resize_method.return_type = new TypeReference ();
resize_method.access = MemberAccessibility.PUBLIC;
resize_method.access = SymbolAccessibility.PUBLIC;
resize_method.set_cname ("g_renew");
......@@ -190,7 +190,7 @@ public class Vala.Array : DataType {
move_method = new ArrayMoveMethod (source_reference);
move_method.return_type = new TypeReference ();
move_method.access = MemberAccessibility.PUBLIC;
move_method.access = SymbolAccessibility.PUBLIC;
move_method.set_cname ("_vala_array_move");
......
......@@ -165,7 +165,7 @@ public class Vala.Class : DataType {
// non_null fields not yet supported due to initialization issues
f.type_reference.non_null = false;
fields.add (f);
if (f.access == MemberAccessibility.PRIVATE && f.instance) {
if (f.access == SymbolAccessibility.PRIVATE && f.instance) {
_has_private_fields = true;
}
scope.add (f.name, f);
......@@ -228,7 +228,7 @@ public class Vala.Class : DataType {
// non_null fields not yet supported due to initialization issues
field_type.non_null = false;
var f = new Field ("_%s".printf (prop.name), field_type, null, prop.source_reference);
f.access = MemberAccessibility.PRIVATE;
f.access = SymbolAccessibility.PRIVATE;
add_field (f);
}
}
......
......@@ -36,14 +36,6 @@ public class Vala.Constant : Member, Lockable {
*/
public Expression initializer { get; set; }
/**
* Specifies the accessibility of this constant. Public accessibility
* doesn't limit access. Default accessibility limits access to this
* program or library. Private accessibility limits access to instances
* of the contained type.
*/
public MemberAccessibility access;
private string cname;
private bool lock_used = false;
......
......@@ -29,14 +29,6 @@ using Gee;
* code or imported from an external library with a Vala API file.
*/
public abstract class Vala.DataType : Symbol {
/**
* 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;
private Gee.List<string> cheader_filenames = new ArrayList<string> ();
private Pointer pointer_type;
......
......@@ -37,14 +37,6 @@ public class Vala.Field : Member, Invokable, Lockable {
*/
public Expression initializer { get; set; }
/**
* Specifies the accessibility of this field. Public accessibility
* doesn't limit access. Default accessibility limits access to this
* program or library. Private accessibility limits access to instances
* of the contained type.
*/
public MemberAccessibility access;
/**
* Specifies whether this field may only be accessed with an instance of
* the contained type.
......
......@@ -80,6 +80,10 @@ public class Vala.FormalParameter : Symbol, Invokable {
source_reference = source;
}
construct {
access = SymbolAccessibility.PUBLIC;
}
public override void accept (CodeVisitor! visitor) {
visitor.visit_formal_parameter (this);
}
......
......@@ -89,7 +89,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
return;
}
if (cl.access == MemberAccessibility.PRIVATE) {
if (cl.access == SymbolAccessibility.PRIVATE) {
return;
}
......@@ -176,7 +176,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
return;
}
if (st.access == MemberAccessibility.PRIVATE) {
if (st.access == SymbolAccessibility.PRIVATE) {
return;
}
......@@ -211,7 +211,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
return;
}
if (iface.access == MemberAccessibility.PRIVATE) {
if (iface.access == SymbolAccessibility.PRIVATE) {
return;
}
......@@ -277,7 +277,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
return;
}
if (en.access == MemberAccessibility.PRIVATE) {
if (en.access == SymbolAccessibility.PRIVATE) {
return;
}
......@@ -334,7 +334,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
return;
}
if (f.access == MemberAccessibility.PRIVATE) {
if (f.access == SymbolAccessibility.PRIVATE) {
return;
}
......@@ -421,7 +421,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
return;
}
if (cb.access == MemberAccessibility.PRIVATE) {
if (cb.access == SymbolAccessibility.PRIVATE) {
return;
}
......@@ -457,7 +457,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
return;
}
if (m.access == MemberAccessibility.PRIVATE || m.overrides) {
if (m.access == SymbolAccessibility.PRIVATE || m.overrides) {
return;
}
......@@ -586,7 +586,7 @@ public class Vala.InterfaceWriter : CodeVisitor {
}
public override void visit_signal (Signal! sig) {
if (sig.access == MemberAccessibility.PRIVATE) {
if (sig.access == SymbolAccessibility.PRIVATE) {
return;
}
......
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