Skip to content
Commits on Source (12)
2022-07-14 Rico Tzschichholz <ricotz@ubuntu.com>
Release 0.56.2
2022-07-01 Rico Tzschichholz <ricotz@ubuntu.com>
vapi: Add rest-1.0 bindings
vapi: Add geocode-glib-2.0 binding
2022-06-14 Rico Tzschichholz <ricotz@ubuntu.com>
codegen: Check cname of fields and methods against reserved identfiers
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1329
codegen: Split reserved identifiers for C and Vala
codegen: Make sure to initialize static collections
vala: Avoid critical in SourceFile.get_mapped_length()
See https://gitlab.gnome.org/GNOME/vala/issues/1330
2022-06-04 Corentin Noël <corentin.noel@collabora.com>
vapi: Add initial wayland-client binding
Allow to properly use gtk4-wayland.
2022-06-02 Gustav Hartvigsson <gustav.hartvigsson@gmail.com>
glib2.0: Add abs() to int8/int16/int32/ssize_t
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1328
2022-05-31 Rico Tzschichholz <ricotz@ubuntu.com>
codegen: Detect usage of static type-parameter in runtime context
Compact classes doesn't carry runtime information of its type-parameters.
In case this information is required we need report an error.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1326
2022-05-10 Rico Tzschichholz <ricotz@ubuntu.com>
codegen: Correctly set array-length for NoAccessorMethods properties
If value is a null-terminated array then calculate and set its length.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1316
2022-04-22 Rico Tzschichholz <ricotz@ubuntu.com>
 
Release 0.56.1
......
......@@ -280,6 +280,7 @@ EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
GMODULE_CFLAGS = @GMODULE_CFLAGS@
......
Vala 0.56.2
===========
* Various improvements and bug fixes:
- codegen: Correctly set array-length for NoAccessorMethods properties [#1316]
- codegen: Detect usage of static type-parameter in runtime context [#1326]
- vala: Avoid critical in SourceFile.get_mapped_length() [#1330]
- codegen: Make sure to initialize static collections
- codegen: Split reserved identifiers for C and Vala
- codegen: Check cname of fields and methods against reserved identfiers [#1329]
* Bindings:
- glib2.0: Add abs() to int8/int16/int32/ssize_t [#1328]
- Add initial wayland-client binding
- Add geocode-glib-2.0 binding
- Add rest-1.0 bindings
Vala 0.56.1
===========
* Various improvements and bug fixes:
......
This diff is collapsed.
......@@ -289,6 +289,7 @@ EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
GMODULE_CFLAGS = @GMODULE_CFLAGS@
......
......@@ -284,6 +284,7 @@ EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
GMODULE_CFLAGS = @GMODULE_CFLAGS@
......
......@@ -172,6 +172,7 @@ namespace Vala {
public bool requires_memdup2;
public bool requires_vala_extern;
public static Vala.Set<string> reserved_identifiers;
public static Vala.Set<string> reserved_vala_identifiers;
public Vala.Symbol root_symbol;
public Vala.DataType short_type;
public Vala.CCodeEnum signal_enum;
......@@ -290,6 +291,7 @@ namespace Vala {
public Vala.CCodeExpression get_variable_cexpression (string name);
public string get_variable_cname (string name);
public Vala.CCodeExpression? handle_struct_argument (Vala.Parameter? param, Vala.Expression arg, Vala.CCodeExpression? cexpr);
public static void init ();
public static bool is_constant_ccode (Vala.CodeNode expr);
public static bool is_constant_ccode_expression (Vala.CCodeExpression cexpr);
public bool is_in_constructor ();
......
......@@ -80,6 +80,7 @@ vala_get_ccode_attribute (ValaCodeNode* node)
_tmp2_ = __int_dup0 (&_tmp1_);
_g_free0 (vala_ccode_attribute_cache_index);
vala_ccode_attribute_cache_index = _tmp2_;
vala_ccode_base_module_init ();
}
_tmp3_ = vala_ccode_attribute_cache_index;
_tmp4_ = vala_code_node_get_attribute_cache (node, *_tmp3_);
......
......@@ -26,6 +26,9 @@ namespace Vala {
static unowned CCodeAttribute get_ccode_attribute (CodeNode node) {
if (ccode_attribute_cache_index == null) {
ccode_attribute_cache_index = CodeNode.get_attribute_cache_index ();
// make sure static collections are initialized
CCodeBaseModule.init ();
}
unowned AttributeCache? attr = node.get_attribute_cache (ccode_attribute_cache_index);
......
This diff is collapsed.
......@@ -734,7 +734,8 @@ public class Vala.CCodeAttribute : AttributeCache {
}
if (cname[0].isdigit ()) {
Report.error (node.source_reference, "Field name starts with a digit. Use the `cname' attribute to provide a valid C name if intended");
return "";
} else if (CCodeBaseModule.reserved_identifiers.contains (cname)) {
Report.error (node.source_reference, "Field name `%s' collides with reserved identifier. Use the `cname' attribute to provide a valid C name if intended", cname);
}
return cname;
} else if (sym is CreationMethod) {
......@@ -760,6 +761,7 @@ public class Vala.CCodeAttribute : AttributeCache {
if (m.signal_reference != null) {
return "%s%s".printf (get_ccode_lower_case_prefix (m.parent_symbol), get_ccode_lower_case_name (m.signal_reference));
}
string cname;
if (sym.name == "main" && sym.parent_symbol.name == null) {
// avoid conflict with generated main function
if (m.coroutine) {
......@@ -768,10 +770,14 @@ public class Vala.CCodeAttribute : AttributeCache {
return "_vala_main";
}
} else if (sym.name.has_prefix ("_")) {
return "_%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), sym.name.substring (1));
cname = "_%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), sym.name.substring (1));
} else {
return "%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), sym.name);
cname = "%s%s".printf (get_ccode_lower_case_prefix (sym.parent_symbol), sym.name);
}
if (CCodeBaseModule.reserved_identifiers.contains (cname)) {
Report.error (node.source_reference, "Method name `%s' collides with reserved identifier. Use the `cname' attribute to provide a valid C name if intended", cname);
}
return cname;
} else if (sym is Property) {
return sym.name.replace ("_", "-");
} else if (sym is PropertyAccessor) {
......@@ -787,7 +793,7 @@ public class Vala.CCodeAttribute : AttributeCache {
return Symbol.camel_case_to_lower_case (sym.name).replace ("_", "-");;
} else if (sym is LocalVariable) {
unowned string name = sym.name;
if (CCodeBaseModule.reserved_identifiers.contains (name)) {
if (CCodeBaseModule.reserved_identifiers.contains (name) || CCodeBaseModule.reserved_vala_identifiers.contains (name)) {
return "_%s_".printf (name);
} else {
return name;
......@@ -798,7 +804,7 @@ public class Vala.CCodeAttribute : AttributeCache {
return "...";
}
unowned string name = sym.name;
if (CCodeBaseModule.reserved_identifiers.contains (name)) {
if (CCodeBaseModule.reserved_identifiers.contains (name) || CCodeBaseModule.reserved_vala_identifiers.contains (name)) {
return "_%s_".printf (name);
} else {
return name;
......
......@@ -80,6 +80,7 @@ struct _ValaCCodeBaseModuleParamSpecEmitContext {
static gint ValaCCodeBaseModule_private_offset;
static gpointer vala_ccode_base_module_parent_class = NULL;
ValaSet* vala_ccode_base_module_reserved_identifiers = NULL;
ValaSet* vala_ccode_base_module_reserved_vala_identifiers = NULL;
gint vala_ccode_base_module_ccode_attribute_cache_index = 0;
static gpointer vala_ccode_base_module_emit_context_parent_class = NULL;
 
......@@ -1213,58 +1214,6 @@ vala_ccode_base_module_construct (GType object_type)
ValaSet* _tmp25_;
ValaSet* _tmp26_;
ValaSet* _tmp27_;
GHashFunc _tmp28_;
GEqualFunc _tmp29_;
ValaHashSet* _tmp30_;
ValaSet* _tmp31_;
ValaSet* _tmp32_;
ValaSet* _tmp33_;
ValaSet* _tmp34_;
ValaSet* _tmp35_;
ValaSet* _tmp36_;
ValaSet* _tmp37_;
ValaSet* _tmp38_;
ValaSet* _tmp39_;
ValaSet* _tmp40_;
ValaSet* _tmp41_;
ValaSet* _tmp42_;
ValaSet* _tmp43_;
ValaSet* _tmp44_;
ValaSet* _tmp45_;
ValaSet* _tmp46_;
ValaSet* _tmp47_;
ValaSet* _tmp48_;
ValaSet* _tmp49_;
ValaSet* _tmp50_;
ValaSet* _tmp51_;
ValaSet* _tmp52_;
ValaSet* _tmp53_;
ValaSet* _tmp54_;
ValaSet* _tmp55_;
ValaSet* _tmp56_;
ValaSet* _tmp57_;
ValaSet* _tmp58_;
ValaSet* _tmp59_;
ValaSet* _tmp60_;
ValaSet* _tmp61_;
ValaSet* _tmp62_;
ValaSet* _tmp63_;
ValaSet* _tmp64_;
ValaSet* _tmp65_;
ValaSet* _tmp66_;
ValaSet* _tmp67_;
ValaSet* _tmp68_;
ValaSet* _tmp69_;
ValaSet* _tmp70_;
ValaSet* _tmp71_;
ValaSet* _tmp72_;
ValaSet* _tmp73_;
ValaSet* _tmp74_;
ValaSet* _tmp75_;
ValaSet* _tmp76_;
ValaSet* _tmp77_;
ValaSet* _tmp78_;
ValaSet* _tmp79_;
self = (ValaCCodeBaseModule*) vala_code_generator_construct (object_type);
_tmp0_ = vala_get_build_version ();
if (g_strcmp0 (_tmp0_, VALA_BUILD_VERSION) != 0) {
......@@ -1324,110 +1273,181 @@ vala_ccode_base_module_construct (GType object_type)
vala_collection_add ((ValaCollection*) _tmp26_, "VOID:VARIANT");
_tmp27_ = self->predefined_marshal_set;
vala_collection_add ((ValaCollection*) _tmp27_, "BOOLEAN:BOXED,BOXED");
_tmp28_ = g_str_hash;
_tmp29_ = g_str_equal;
_tmp30_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp28_, _tmp29_);
vala_ccode_base_module_init ();
return self;
}
void
vala_ccode_base_module_init (void)
{
ValaSet* _tmp0_;
GHashFunc _tmp1_;
GEqualFunc _tmp2_;
ValaHashSet* _tmp3_;
ValaSet* _tmp4_;
ValaSet* _tmp5_;
ValaSet* _tmp6_;
ValaSet* _tmp7_;
ValaSet* _tmp8_;
ValaSet* _tmp9_;
ValaSet* _tmp10_;
ValaSet* _tmp11_;
ValaSet* _tmp12_;
ValaSet* _tmp13_;
ValaSet* _tmp14_;
ValaSet* _tmp15_;
ValaSet* _tmp16_;
ValaSet* _tmp17_;
ValaSet* _tmp18_;
ValaSet* _tmp19_;
ValaSet* _tmp20_;
ValaSet* _tmp21_;
ValaSet* _tmp22_;
ValaSet* _tmp23_;
ValaSet* _tmp24_;
ValaSet* _tmp25_;
ValaSet* _tmp26_;
ValaSet* _tmp27_;
ValaSet* _tmp28_;
ValaSet* _tmp29_;
ValaSet* _tmp30_;
ValaSet* _tmp31_;
ValaSet* _tmp32_;
ValaSet* _tmp33_;
ValaSet* _tmp34_;
ValaSet* _tmp35_;
ValaSet* _tmp36_;
ValaSet* _tmp37_;
ValaSet* _tmp38_;
ValaSet* _tmp39_;
ValaSet* _tmp40_;
ValaSet* _tmp41_;
ValaSet* _tmp42_;
ValaSet* _tmp43_;
ValaSet* _tmp44_;
ValaSet* _tmp45_;
ValaSet* _tmp46_;
ValaSet* _tmp47_;
ValaSet* _tmp48_;
ValaSet* _tmp49_;
GHashFunc _tmp50_;
GEqualFunc _tmp51_;
ValaHashSet* _tmp52_;
ValaSet* _tmp53_;
ValaSet* _tmp54_;
ValaSet* _tmp55_;
_tmp0_ = vala_ccode_base_module_reserved_identifiers;
if (_tmp0_ != NULL) {
return;
}
_tmp1_ = g_str_hash;
_tmp2_ = g_str_equal;
_tmp3_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp1_, _tmp2_);
_vala_iterable_unref0 (vala_ccode_base_module_reserved_identifiers);
vala_ccode_base_module_reserved_identifiers = (ValaSet*) _tmp30_;
vala_ccode_base_module_reserved_identifiers = (ValaSet*) _tmp3_;
_tmp4_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp4_, "_Bool");
_tmp5_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp5_, "_Complex");
_tmp6_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp6_, "_Imaginary");
_tmp7_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp7_, "asm");
_tmp8_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp8_, "auto");
_tmp9_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp9_, "break");
_tmp10_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp10_, "case");
_tmp11_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp11_, "char");
_tmp12_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp12_, "const");
_tmp13_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp13_, "continue");
_tmp14_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp14_, "default");
_tmp15_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp15_, "do");
_tmp16_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp16_, "double");
_tmp17_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp17_, "else");
_tmp18_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp18_, "enum");
_tmp19_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp19_, "extern");
_tmp20_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp20_, "float");
_tmp21_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp21_, "for");
_tmp22_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp22_, "goto");
_tmp23_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp23_, "if");
_tmp24_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp24_, "inline");
_tmp25_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp25_, "int");
_tmp26_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp26_, "long");
_tmp27_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp27_, "register");
_tmp28_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp28_, "restrict");
_tmp29_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp29_, "return");
_tmp30_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp30_, "short");
_tmp31_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp31_, "_Bool");
vala_collection_add ((ValaCollection*) _tmp31_, "signed");
_tmp32_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp32_, "_Complex");
vala_collection_add ((ValaCollection*) _tmp32_, "sizeof");
_tmp33_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp33_, "_Imaginary");
vala_collection_add ((ValaCollection*) _tmp33_, "static");
_tmp34_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp34_, "asm");
vala_collection_add ((ValaCollection*) _tmp34_, "struct");
_tmp35_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp35_, "auto");
vala_collection_add ((ValaCollection*) _tmp35_, "switch");
_tmp36_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp36_, "break");
vala_collection_add ((ValaCollection*) _tmp36_, "typedef");
_tmp37_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp37_, "case");
vala_collection_add ((ValaCollection*) _tmp37_, "union");
_tmp38_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp38_, "char");
vala_collection_add ((ValaCollection*) _tmp38_, "unsigned");
_tmp39_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp39_, "const");
vala_collection_add ((ValaCollection*) _tmp39_, "void");
_tmp40_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp40_, "continue");
vala_collection_add ((ValaCollection*) _tmp40_, "volatile");
_tmp41_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp41_, "default");
vala_collection_add ((ValaCollection*) _tmp41_, "while");
_tmp42_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp42_, "do");
vala_collection_add ((ValaCollection*) _tmp42_, "_Alignas");
_tmp43_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp43_, "double");
vala_collection_add ((ValaCollection*) _tmp43_, "_Alignof");
_tmp44_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp44_, "else");
vala_collection_add ((ValaCollection*) _tmp44_, "_Atomic");
_tmp45_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp45_, "enum");
vala_collection_add ((ValaCollection*) _tmp45_, "_Generic");
_tmp46_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp46_, "extern");
vala_collection_add ((ValaCollection*) _tmp46_, "_Noreturn");
_tmp47_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp47_, "float");
vala_collection_add ((ValaCollection*) _tmp47_, "_Static_assert");
_tmp48_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp48_, "for");
vala_collection_add ((ValaCollection*) _tmp48_, "_Thread_local");
_tmp49_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp49_, "goto");
_tmp50_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp50_, "if");
_tmp51_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp51_, "inline");
_tmp52_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp52_, "int");
_tmp53_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp53_, "long");
_tmp54_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp54_, "register");
_tmp55_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp55_, "restrict");
_tmp56_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp56_, "return");
_tmp57_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp57_, "short");
_tmp58_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp58_, "signed");
_tmp59_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp59_, "sizeof");
_tmp60_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp60_, "static");
_tmp61_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp61_, "struct");
_tmp62_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp62_, "switch");
_tmp63_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp63_, "typedef");
_tmp64_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp64_, "union");
_tmp65_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp65_, "unsigned");
_tmp66_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp66_, "void");
_tmp67_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp67_, "volatile");
_tmp68_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp68_, "while");
_tmp69_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp69_, "_Alignas");
_tmp70_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp70_, "_Alignof");
_tmp71_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp71_, "_Atomic");
_tmp72_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp72_, "_Generic");
_tmp73_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp73_, "_Noreturn");
_tmp74_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp74_, "_Static_assert");
_tmp75_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp75_, "_Thread_local");
_tmp76_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp76_, "cdecl");
_tmp77_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp77_, "error");
_tmp78_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp78_, "result");
_tmp79_ = vala_ccode_base_module_reserved_identifiers;
vala_collection_add ((ValaCollection*) _tmp79_, "self");
return self;
vala_collection_add ((ValaCollection*) _tmp49_, "cdecl");
_tmp50_ = g_str_hash;
_tmp51_ = g_str_equal;
_tmp52_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp50_, _tmp51_);
_vala_iterable_unref0 (vala_ccode_base_module_reserved_vala_identifiers);
vala_ccode_base_module_reserved_vala_identifiers = (ValaSet*) _tmp52_;
_tmp53_ = vala_ccode_base_module_reserved_vala_identifiers;
vala_collection_add ((ValaCollection*) _tmp53_, "error");
_tmp54_ = vala_ccode_base_module_reserved_vala_identifiers;
vala_collection_add ((ValaCollection*) _tmp54_, "result");
_tmp55_ = vala_ccode_base_module_reserved_vala_identifiers;
vala_collection_add ((ValaCollection*) _tmp55_, "self");
}
 
static gpointer
......@@ -15066,17 +15086,25 @@ vala_ccode_base_module_get_variable_cname (ValaCCodeBaseModule* self,
result = (gchar*) _tmp13_;
return result;
} else {
ValaSet* _tmp14_;
_tmp14_ = vala_ccode_base_module_reserved_identifiers;
if (vala_collection_contains ((ValaCollection*) _tmp14_, name)) {
gchar* _tmp15_;
_tmp15_ = g_strdup_printf ("_%s_", name);
result = _tmp15_;
gboolean _tmp14_ = FALSE;
ValaSet* _tmp15_;
_tmp15_ = vala_ccode_base_module_reserved_identifiers;
if (vala_collection_contains ((ValaCollection*) _tmp15_, name)) {
_tmp14_ = TRUE;
} else {
ValaSet* _tmp16_;
_tmp16_ = vala_ccode_base_module_reserved_vala_identifiers;
_tmp14_ = vala_collection_contains ((ValaCollection*) _tmp16_, name);
}
if (_tmp14_) {
gchar* _tmp17_;
_tmp17_ = g_strdup_printf ("_%s_", name);
result = _tmp17_;
return result;
} else {
gchar* _tmp16_;
_tmp16_ = g_strdup (name);
result = _tmp16_;
gchar* _tmp18_;
_tmp18_ = g_strdup (name);
result = _tmp18_;
return result;
}
}
......@@ -16948,46 +16976,93 @@ vala_ccode_base_module_get_type_id_expression (ValaCCodeBaseModule* self,
ValaTypeParameter* _tmp0_;
ValaTypeParameter* _tmp1_;
ValaTypeParameter* _tmp2_;
gchar* identifier = NULL;
ValaSymbol* parent = NULL;
ValaTypeParameter* _tmp3_;
gchar* _tmp4_;
const gchar* _tmp5_;
ValaCCodeExpression* _tmp6_;
ValaScope* _tmp4_;
ValaScope* _tmp5_;
ValaSymbol* _tmp6_;
ValaSymbol* _tmp7_;
gboolean _tmp8_ = FALSE;
ValaSymbol* _tmp9_;
gchar* identifier = NULL;
ValaTypeParameter* _tmp20_;
gchar* _tmp21_;
const gchar* _tmp22_;
ValaCCodeExpression* _tmp23_;
_tmp0_ = vala_generic_type_get_type_parameter (G_TYPE_CHECK_INSTANCE_CAST (type, VALA_TYPE_GENERIC_TYPE, ValaGenericType));
_tmp1_ = _tmp0_;
_tmp2_ = _vala_code_node_ref0 (_tmp1_);
type_parameter = _tmp2_;
_tmp3_ = type_parameter;
_tmp4_ = vala_get_ccode_type_id ((ValaCodeNode*) _tmp3_);
identifier = _tmp4_;
_tmp5_ = identifier;
_tmp6_ = vala_ccode_base_module_get_generic_type_expression (self, _tmp5_, G_TYPE_CHECK_INSTANCE_CAST (type, VALA_TYPE_GENERIC_TYPE, ValaGenericType), is_chainup);
result = _tmp6_;
_tmp4_ = vala_symbol_get_owner ((ValaSymbol*) _tmp3_);
_tmp5_ = _tmp4_;
_tmp6_ = vala_scope_get_owner (_tmp5_);
_tmp7_ = _tmp6_;
parent = _tmp7_;
_tmp9_ = parent;
if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp9_, VALA_TYPE_CLASS)) {
ValaSymbol* _tmp10_;
gboolean _tmp11_;
gboolean _tmp12_;
_tmp10_ = parent;
_tmp11_ = vala_class_get_is_compact (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, VALA_TYPE_CLASS, ValaClass));
_tmp12_ = _tmp11_;
_tmp8_ = _tmp12_;
} else {
_tmp8_ = FALSE;
}
if (_tmp8_) {
ValaSourceReference* _tmp13_;
ValaSourceReference* _tmp14_;
ValaTypeSymbol* _tmp15_;
ValaTypeSymbol* _tmp16_;
gchar* _tmp17_;
gchar* _tmp18_;
ValaCCodeInvalidExpression* _tmp19_;
_tmp13_ = vala_code_node_get_source_reference ((ValaCodeNode*) type);
_tmp14_ = _tmp13_;
_tmp15_ = vala_data_type_get_type_symbol (type);
_tmp16_ = _tmp15_;
_tmp17_ = vala_symbol_get_full_name ((ValaSymbol*) _tmp16_);
_tmp18_ = _tmp17_;
vala_report_error (_tmp14_, "static type-parameter `%s' can not be used in runtime context", _tmp18_);
_g_free0 (_tmp18_);
_tmp19_ = vala_ccode_invalid_expression_new ();
result = (ValaCCodeExpression*) _tmp19_;
_vala_code_node_unref0 (type_parameter);
return result;
}
_tmp20_ = type_parameter;
_tmp21_ = vala_get_ccode_type_id ((ValaCodeNode*) _tmp20_);
identifier = _tmp21_;
_tmp22_ = identifier;
_tmp23_ = vala_ccode_base_module_get_generic_type_expression (self, _tmp22_, G_TYPE_CHECK_INSTANCE_CAST (type, VALA_TYPE_GENERIC_TYPE, ValaGenericType), is_chainup);
result = _tmp23_;
_g_free0 (identifier);
_vala_code_node_unref0 (type_parameter);
return result;
} else {
gchar* type_id = NULL;
gchar* _tmp7_;
const gchar* _tmp8_;
const gchar* _tmp11_;
ValaCCodeIdentifier* _tmp12_;
_tmp7_ = vala_get_ccode_type_id ((ValaCodeNode*) type);
type_id = _tmp7_;
_tmp8_ = type_id;
if (g_strcmp0 (_tmp8_, "") == 0) {
gchar* _tmp9_;
_tmp9_ = g_strdup ("G_TYPE_INVALID");
gchar* _tmp24_;
const gchar* _tmp25_;
const gchar* _tmp28_;
ValaCCodeIdentifier* _tmp29_;
_tmp24_ = vala_get_ccode_type_id ((ValaCodeNode*) type);
type_id = _tmp24_;
_tmp25_ = type_id;
if (g_strcmp0 (_tmp25_, "") == 0) {
gchar* _tmp26_;
_tmp26_ = g_strdup ("G_TYPE_INVALID");
_g_free0 (type_id);
type_id = _tmp9_;
type_id = _tmp26_;
} else {
ValaCCodeFile* _tmp10_;
_tmp10_ = self->cfile;
vala_ccode_base_module_generate_type_declaration (self, type, _tmp10_);
ValaCCodeFile* _tmp27_;
_tmp27_ = self->cfile;
vala_ccode_base_module_generate_type_declaration (self, type, _tmp27_);
}
_tmp11_ = type_id;
_tmp12_ = vala_ccode_identifier_new (_tmp11_);
result = (ValaCCodeExpression*) _tmp12_;
_tmp28_ = type_id;
_tmp29_ = vala_ccode_identifier_new (_tmp28_);
result = (ValaCCodeExpression*) _tmp29_;
_g_free0 (type_id);
return result;
}
......@@ -275,6 +275,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public Set<string> predefined_marshal_set;
/* (constant) hash table with all reserved identifiers in the generated code */
public static Set<string> reserved_identifiers;
public static Set<string> reserved_vala_identifiers;
public int next_temp_var_id {
get { return emit_context.next_temp_var_id; }
......@@ -405,6 +406,14 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
predefined_marshal_set.add ("VOID:VARIANT");
predefined_marshal_set.add ("BOOLEAN:BOXED,BOXED");
init ();
}
public static void init () {
if (reserved_identifiers != null) {
return;
}
reserved_identifiers = new HashSet<string> (str_hash, str_equal);
// C99 keywords
......@@ -459,10 +468,12 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
// MSVC keywords
reserved_identifiers.add ("cdecl");
reserved_vala_identifiers = new HashSet<string> (str_hash, str_equal);
// reserved for Vala/GObject naming conventions
reserved_identifiers.add ("error");
reserved_identifiers.add ("result");
reserved_identifiers.add ("self");
reserved_vala_identifiers.add ("error");
reserved_vala_identifiers.add ("result");
reserved_vala_identifiers.add ("self");
}
public override void emit (CodeContext context) {
......@@ -2713,7 +2724,7 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
next_temp_var_id++;
}
return variable_name_map.get (name);
} else if (reserved_identifiers.contains (name)) {
} else if (reserved_identifiers.contains (name) || reserved_vala_identifiers.contains (name)) {
return "_%s_".printf (name);
} else {
return name;
......@@ -3048,6 +3059,11 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
public CCodeExpression get_type_id_expression (DataType type, bool is_chainup = false) {
if (type is GenericType) {
var type_parameter = ((GenericType) type).type_parameter;
unowned Symbol? parent = type_parameter.owner.owner;
if (parent is Class && ((Class) parent).is_compact) {
Report.error (type.source_reference, "static type-parameter `%s' can not be used in runtime context", type.type_symbol.get_full_name ());
return new CCodeInvalidExpression();
}
string identifier = get_ccode_type_id (type_parameter);
return get_generic_type_expression (identifier, (GenericType) type, is_chainup);
} else {
......
This diff is collapsed.
......@@ -348,7 +348,19 @@ public abstract class Vala.CCodeMemberAccessModule : CCodeControlFlowModule {
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, ctemp));
ccall.add_argument (new CCodeConstant ("NULL"));
ccode.add_expression (ccall);
set_cvalue (expr, ctemp);
if (get_ccode_array_null_terminated (prop)) {
requires_array_length = true;
var len_call = new CCodeFunctionCall (new CCodeIdentifier ("_vala_array_length"));
len_call.add_argument (ctemp);
var glib_value = (GLibValue) expr.target_value;
glib_value.array_length_cvalues = null;
glib_value.append_array_length_cvalue (len_call);
glib_value.lvalue = false;
}
}
if (prop.get_accessor.value_type is GenericType) {
......
......@@ -1071,6 +1071,7 @@ VALA_EXTERN ValaBlock* vala_ccode_base_module_next_closure_block (ValaCCodeBaseM
VALA_EXTERN ValaCCodeFunction* vala_ccode_base_module_get_ccode (ValaCCodeBaseModule* self);
VALA_EXTERN ValaArrayList* vala_ccode_base_module_get_temp_ref_values (ValaCCodeBaseModule* self);
VALA_EXTERN ValaSet* vala_ccode_base_module_reserved_identifiers;
VALA_EXTERN ValaSet* vala_ccode_base_module_reserved_vala_identifiers;
VALA_EXTERN gint vala_ccode_base_module_get_next_temp_var_id (ValaCCodeBaseModule* self);
VALA_EXTERN void vala_ccode_base_module_set_next_temp_var_id (ValaCCodeBaseModule* self,
gint value);
......@@ -1084,6 +1085,7 @@ VALA_EXTERN void vala_ccode_base_module_set_current_method_return (ValaCCodeBase
VALA_EXTERN ValaMap* vala_ccode_base_module_get_variable_name_map (ValaCCodeBaseModule* self);
VALA_EXTERN gint vala_ccode_base_module_ccode_attribute_cache_index;
VALA_EXTERN ValaCCodeBaseModule* vala_ccode_base_module_construct (GType object_type);
VALA_EXTERN void vala_ccode_base_module_init (void);
VALA_EXTERN void vala_ccode_base_module_push_context (ValaCCodeBaseModule* self,
ValaCCodeBaseModuleEmitContext* emit_context);
VALA_EXTERN void vala_ccode_base_module_pop_context (ValaCCodeBaseModule* self);
......
......@@ -213,6 +213,7 @@ EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_LIBS = @GLIB_LIBS@
GMODULE_CFLAGS = @GMODULE_CFLAGS@
......
This diff is collapsed.