gen_nit :: NitModule :: annotations
Annotations on the module declarationgen_nit :: NitModule :: annotations=
Annotations on the module declarationgen_nit :: NitModule :: defaultinit
gen_nit :: NitModule :: annotations
Annotations on the module declarationgen_nit :: NitModule :: annotations=
Annotations on the module declarationcore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
gen_nit :: NitModule :: defaultinit
core :: Object :: defaultinit
template :: Template :: defaultinit
core :: Writable :: defaultinit
template :: Template :: is_frozen=
Is the template allowing more modification (add
)
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).core :: Writable :: write_to_bytes
Likewrite_to
but return a new Bytes (may be quite large)
core :: Writable :: write_to_file
Likewrite_to
but take care of creating the file
core :: Writable :: write_to_string
Likewrite_to
but return a new String (may be quite large).
# Template of a Nit module to generate Nit code
class NitModule
super Template
# Header on top of the module, usually the documentation
var header: nullable Writable = null is writable
# The module's name
var name: Writable is writable
# Annotations on the module declaration
var annotations = new Array[Writable]
# Importation declarations
#
# Accepts two formats:
# * Module name only, short or qualified: `json`, `gamnit::flat`, etc.
# * Full importation declaration: `import json`, `private import gamnit::flat`, etc.
var imports = new Set[Writable]
# Main content of this module
var content = new Array[Writable]
redef fun rendering
do
var header = header
if header != null then add header
var name = name
if annotations.is_empty then
add "module {name}\n\n"
else
add "module {name} is\n"
for annotation in annotations do add "\t{annotation}\n"
add "end\n\n"
end
for i in imports do
if i.to_s.has("import ") then
add i
else
add "import "
add i
end
add "\n"
end
add "\n"
for l in content do
add l
add "\n"
end
end
end
lib/gen_nit/gen_nit.nit:45,1--98,3