[vala/staging] codegen: Commonized generation of public/private fields
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] codegen: Commonized generation of public/private fields
- Date: Tue, 21 Jan 2020 09:12:29 +0000 (UTC)
commit ed421a9aa362d48f778e4a8e22f1d4a763d6beea
Author: Simon Werbeck <simon werbeck gmail com>
Date: Mon Jan 13 15:10:48 2020 +0100
codegen: Commonized generation of public/private fields
codegen/valagtypemodule.vala | 36 ++++++++++++++----------------------
1 file changed, 14 insertions(+), 22 deletions(-)
---
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index a67b8c68c..72007249b 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -276,8 +276,9 @@ public class Vala.GTypeModule : GErrorModule {
var prop = (Property) s;
generate_struct_property_declaration (cl, prop, instance_struct,
type_struct, decl_space, ref has_struct_member);
} else if (s is Field) {
- var f = (Field) s;
- generate_struct_field_declaration (cl, f, instance_struct,
type_struct, decl_space, ref has_struct_member);
+ if (s.access != SymbolAccessibility.PRIVATE) {
+ generate_struct_field_declaration ((Field) s,
instance_struct, type_struct, decl_space, ref has_struct_member);
+ }
} else {
Report.error (s.source_reference, "internal: Unsupported symbol");
}
@@ -298,7 +299,9 @@ public class Vala.GTypeModule : GErrorModule {
}
foreach (Field f in cl.get_fields ()) {
- generate_struct_field_declaration (cl, f, instance_struct, type_struct,
decl_space, ref has_struct_member);
+ if (f.access != SymbolAccessibility.PRIVATE) {
+ generate_struct_field_declaration (f, instance_struct, type_struct,
decl_space, ref has_struct_member);
+ }
}
}
@@ -403,11 +406,7 @@ public class Vala.GTypeModule : GErrorModule {
}
}
- void generate_struct_field_declaration (ObjectTypeSymbol type_sym, Field f, CCodeStruct
instance_struct, CCodeStruct type_struct, CCodeFile decl_space, ref bool has_struct_member) {
- if (f.access == SymbolAccessibility.PRIVATE) {
- return;
- }
-
+ void generate_struct_field_declaration (Field f, CCodeStruct instance_struct, CCodeStruct
type_struct, CCodeFile decl_space, ref bool has_struct_member) {
CCodeModifiers modifiers = (f.is_volatile ? CCodeModifiers.VOLATILE : 0) |
(f.version.deprecated ? CCodeModifiers.DEPRECATED : 0);
if (f.binding == MemberBinding.INSTANCE) {
append_field (instance_struct, f, decl_space);
@@ -489,24 +488,17 @@ public class Vala.GTypeModule : GErrorModule {
}
}
+ bool has_struct_member = false;
foreach (Field f in cl.get_fields ()) {
- CCodeModifiers modifiers = (f.is_volatile ? CCodeModifiers.VOLATILE : 0) |
(f.version.deprecated ? CCodeModifiers.DEPRECATED : 0);
- if (f.binding == MemberBinding.INSTANCE) {
- if (f.access == SymbolAccessibility.PRIVATE) {
- append_field (instance_priv_struct, f, decl_space);
- }
-
- if (f.lock_used) {
+ if (f.access == SymbolAccessibility.PRIVATE) {
+ generate_struct_field_declaration (f, instance_priv_struct, type_priv_struct,
decl_space, ref has_struct_member);
+ }
+ if (f.lock_used) {
+ if (f.binding == MemberBinding.INSTANCE) {
cl.has_private_fields = true;
// add field for mutex
instance_priv_struct.add_field (get_ccode_name (mutex_type),
get_symbol_lock_name (get_ccode_name (f)));
- }
- } else if (f.binding == MemberBinding.CLASS) {
- if (f.access == SymbolAccessibility.PRIVATE) {
- type_priv_struct.add_field (get_ccode_name (f.variable_type),
get_ccode_name (f), modifiers);
- }
-
- if (f.lock_used) {
+ } else if (f.binding == MemberBinding.CLASS) {
has_class_locks = true;
// add field for mutex
type_priv_struct.add_field (get_ccode_name (mutex_type),
get_symbol_lock_name (get_ccode_name (f)));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]