The C-name is a name that respects the rule of identifiers in the C language: it is only made of alphanumeric characters and starts with a letter (or a underscore).
The C-name can be seen as a mangled version of the full_name
.
Therefore, it is expected to be unique and unambiguous in lawful Nit models for the same kind of entity.
The C-name is used by tools that need some identifiers in generated files to designate the entity.
Is is not suitable to use it directly with the user (e.g. in message) and indirect use should be restricted (e.g. to name a web-page)
# A fully-qualified C-like identifier of this model entity.
#
# The C-name is a name that respects the rule of identifiers in the C language:
# it is only made of alphanumeric characters and starts with a letter (or a underscore).
#
# The C-name can be seen as a mangled version of the `full_name`.
# Therefore, it is expected to be unique and unambiguous in lawful Nit models for the same kind of entity.
#
# The C-name is used by tools that need some identifiers in generated files to designate the
# entity.
#
# Is is not suitable to use it directly with the user (e.g. in message) and
# indirect use should be restricted (e.g. to name a web-page)
fun c_name: String is abstract
src/model/model_base.nit:59,2--72,31
redef var c_name is lazy do
return "{intro_mmodule.c_namespace_for(visibility)}__{name.to_cmangle}"
end
src/model/model.nit:456,2--458,4
redef var c_name is lazy do
if is_intro then
return "{mmodule.c_namespace_for(mclass.visibility)}___{mclass.c_name}"
else if mclass.intro_mmodule.mpackage == mmodule.mpackage and mclass.visibility > private_visibility then
return "{mmodule.c_name}___{mclass.name.to_cmangle}"
else
return "{mmodule.c_name}___{mclass.c_name}"
end
end
src/model/model.nit:709,2--717,4
redef var c_name is lazy do
var res = new FlatBuffer
res.append mclassdef.c_name
res.append "___"
if mclassdef.mclass == mproperty.intro_mclassdef.mclass then
res.append name.to_cmangle
else
if mclassdef.mmodule != mproperty.intro_mclassdef.mmodule then
res.append mproperty.intro_mclassdef.mmodule.c_name
res.append "__"
end
res.append mproperty.intro_mclassdef.name.to_cmangle
res.append "__"
res.append mproperty.name.to_cmangle
end
return res.to_s
end
src/model/model.nit:2590,2--2606,4
# Return the name of the global C identifier associated to `self`.
# This name is used to prefix files and other C identifiers associated with `self`.
redef var c_name is lazy do
var g = mgroup
var res
if g != null and g.mpackage.name != name then
res = g.mpackage.name.to_cmangle + "__" + name.to_cmangle
else
res = name.to_cmangle
end
return res
end
src/model/mmodule.nit:145,2--156,4