var opt_out_src = new OptionString("Path to output source file (folder or file)", "--src", "-s")
var opt_assets = new OptionString("Path to assert dir where to put PNG files", "--assets", "-a")
-var opt_scale = new OptionFloat("Apply scaling to exported images (default at 1.0 of 90dpi)", 1.0, "--scale", "-x")
+var opt_scale = new OptionFloat("Apply scaling to exported images (default at 1.0 of 96dpi)", 1.0, "--scale", "-x")
var opt_gamnit = new OptionBool("Target the Gamnit framework (by default it targets Mnit)", "--gamnit", "-g")
var opt_pow2 = new OptionBool("Round the image size to the next power of 2", "--pow2")
var opt_help = new OptionBool("Print this help message", "--help", "-h")
# Output png file to assets
var png_path = "{assets_path}/images/{drawing_name}.png"
var proc2 = new Process.from_a(prog, [drawing, "--without-gui",
- "--export-dpi={(90.0*scale).to_i}",
+ "--export-dpi={(96.0*scale).to_i}",
"--export-png={png_path}",
"--export-area={min_x}:{y0}:{max_x}:{y1}",
"--export-background=#000000", "--export-background-opacity=0.0"])
end
add "# Lexer generated by nitcc for the grammar {name}\n"
- add "module {name}_lexer is no_warning \"missing-doc\"\n"
+ add "module {name}_lexer is generated, no_warning \"missing-doc\"\n"
add("import nitcc_runtime\n")
var p = parser
var gram = autom.grammar
add "# Parser generated by nitcc for the grammar {name}"
- add "module {name}_parser is no_warning(\"missing-doc\",\"old-init\")"
+ add "module {name}_parser is generated, no_warning(\"missing-doc\",\"old-init\")"
add "import nitcc_runtime"
add "class Parser_{name}"
f.write """# Generated by nitcc for the language {{{name}}}
# Standalone parser tester for the language {{{name}}}
-module {{{name}}}_test_parser
+module {{{name}}}_test_parser is generated
import nitcc_runtime
import {{{name}}}_lexer
import {{{name}}}_parser
# Lexer and its tokens.
# This file was generated by SableCC (http://www.sablecc.org/).
-module lexer is no_warning("missing-doc", "old-init")
+module lexer is generated, no_warning("missing-doc", "old-init")
intrude import parser_nodes
private import tables
# Parser.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser is no_warning("missing-doc", "old-init")
+module parser is generated, no_warning("missing-doc", "old-init")
intrude import parser_prod
import tables
# Raw AST node hierarchy.
# This file was generated by SableCC (http://www.sablecc.org/).
-package parser_abs
+package parser_abs is generated
import location
# ~~~
fun simplify_path: String
do
- var a = self.split_with("/")
+ var path_sep = if is_windows then "\\" else "/"
+ var a = self.split_with(path_sep)
var a2 = new Array[String]
for x in a do
if x == "." and not a2.is_empty then continue # skip `././`
class StringWriter
super Writer
- private var content = new Array[String]
- redef fun to_s do return content.plain_to_s
+ private var content = new Buffer
+ redef fun to_s do return content.to_s
redef fun is_writable do return not closed
redef fun write_bytes(b) do
- content.add(b.to_s)
+ content.append(b.to_s)
end
redef fun write(str)
do
assert not closed
- content.add(str.to_s)
+ content.append(str)
+ end
+
+ redef fun write_char(c)
+ do
+ assert not closed
+ content.add(c)
end
# Is the stream closed?
# Lexer generated by nitcc for the grammar json
-module json_lexer is no_warning "missing-doc"
+module json_lexer is generated, no_warning "missing-doc"
import nitcc_runtime
import json_parser
class Lexer_json
# Parser generated by nitcc for the grammar json
-module json_parser is no_warning("missing-doc","old-init")
+module json_parser is generated, no_warning("missing-doc","old-init")
import nitcc_runtime
class Parser_json
super Parser
redef fun accept_json_serializer(v)
do
v.stream.write "\""
+
+ var start_i = 0
+ var escaped = null
for i in [0 .. self.length[ do
var char = self[i]
if char == '\\' then
- v.stream.write "\\\\"
+ escaped = "\\\\"
else if char == '\"' then
- v.stream.write "\\\""
+ escaped = "\\\""
else if char < ' ' then
if char == '\n' then
- v.stream.write "\\n"
+ escaped = "\\n"
else if char == '\r' then
- v.stream.write "\\r"
+ escaped = "\\r"
else if char == '\t' then
- v.stream.write "\\t"
+ escaped = "\\t"
else
- v.stream.write char.escape_to_utf16
+ escaped = char.escape_to_utf16
end
+ end
+
+ if escaped != null then
+ # Write open non-escaped string
+ if start_i <= i then
+ v.stream.write substring(start_i, i-start_i)
+ end
+
+ # Write escaped character
+ v.stream.write escaped
+ escaped = null
+ start_i = i+1
+ end
+ end
+
+ # Write remaining non-escaped string
+ if start_i < length then
+ if start_i == 0 then
+ v.stream.write self
else
- v.stream.write char.to_s
+ v.stream.write substring(start_i, length-start_i)
end
end
+
v.stream.write "\""
end
end
types["htm"] = "text/html"
types["shtml"] = "text/html"
types["css"] = "text/css"
+ types["csv"] = "text/csv"
types["xml"] = "text/xml"
types["rss"] = "text/xml"
types["gif"] = "image/gif"
types["ico"] = "image/x-icon"
types["jng"] = "image/x-jng"
types["wbmp"] = "image/vnd.wap.wbmp"
+ types["gz"] = "application/gzip"
types["jar"] = "application/java-archive"
types["war"] = "application/java-archive"
types["ear"] = "application/java-archive"
import pop_routes
import json::static
import json
+import csv
# Class handler for a route.
#
end
end
+ # Write data as CSV and set the right content type header.
+ fun csv(csv: nullable CsvDocument, status: nullable Int) do
+ header["Content-Type"] = media_types["csv"].as(not null)
+ if csv == null then
+ send(null, status)
+ else
+ send(csv.write_to_string, status)
+ end
+ end
+
# Write error as JSON and set the right content type header.
fun json_error(error: nullable Jsonable, status: nullable Int) do
json(error, status)
LDLIBS := $(filter-out -lrt,$(LDLIBS))
endif
+# Special configuration for Windows under mingw64
+ifeq ($(uname_S),MINGW64_NT-10.0)
+ # Use the pcreposix regex library
+ LDLIBS += -lpcreposix
+
+ # Remove POSIX flag -lrt
+ LDLIBS := $(filter-out -lrt,$(LDLIBS))
+
+ # Silence warnings when storing Int, Char and Bool as pointer address
+ CFLAGS += -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
+endif
+
"""
makefile.write("all: {outpath}\n")
self.toolcontext.info(command, 2)
var res
- if self.toolcontext.verbose_level >= 3 or is_windows then
+ if self.toolcontext.verbose_level >= 3 then
res = sys.system("{command} 2>&1")
+ else if is_windows then
+ res = sys.system("{command} 2>&1 >nul")
else
res = sys.system("{command} 2>&1 >/dev/null")
end
intern
extern
no_warning
+generated
auto_inspect
end
# Is the module a test suite?
mmodule.is_test_suite = not decl.get_annotations("test_suite").is_empty
+ # Is the module generated?
+ mmodule.is_generated = not decl.get_annotations("generated").is_empty
end
end
# Is `self` a unit test module used by `nitunit`?
var is_test_suite: Bool = false is writable
+ # Is `self` a module generated by a tool?
+ #
+ # This flag has no effect on the semantic.
+ # It is only intended on software engineering software to discriminate computer-generated modules from human-written ones.
+ var is_generated: Bool = false is writable
+
# Get the non-`is_fictive` module on which `self` is based on.
#
# On non-fictive module, this returns `self`.
end
var nit_module = new NitModule(module_name)
+nit_module.annotations.add """generated"""
nit_module.annotations.add """no_warning("parentheses")"""
nit_module.header = """
# This file is generated by nitrestful
if importations == null then importations = target_modules
var nit_module = new NitModule(module_name)
+ nit_module.annotations.add """generated"""
nit_module.annotations.add """no_warning("property-conflict")"""
nit_module.header = """
# This file is generated by nitserial
# Lexer and its tokens.
# This file was generated by SableCC (http://www.sablecc.org/).
-module lexer is no_warning("missing-doc")
+module lexer is generated, no_warning("missing-doc")
intrude import parser_nodes
intrude import lexer_work
# Parser.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser is no_warning("missing-doc", "unread-variable")
+module parser is generated, no_warning("missing-doc", "unread-variable")
intrude import parser_prod
intrude import parser_work
# Raw AST node hierarchy.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_abs is no_warning("missing-doc")
+module parser_abs is generated, no_warning("missing-doc")
import location
# Production AST nodes full definition.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_prod is no_warning("missing-doc")
+module parser_prod is generated, no_warning("missing-doc")
import lexer
intrude import parser_nodes
$ output 'parser_abs.nit'
# Raw AST node hierarchy.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_abs is no_warning("missing-doc")
+module parser_abs is generated, no_warning("missing-doc")
import location
$ output 'lexer.nit'
# Lexer and its tokens.
# This file was generated by SableCC (http://www.sablecc.org/).
-module lexer is no_warning("missing-doc")
+module lexer is generated, no_warning("missing-doc")
$ if $usermodule
intrude import $usermodule
$ output 'parser_prod.nit'
# Production AST nodes full definition.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser_prod is no_warning("missing-doc")
+module parser_prod is generated, no_warning("missing-doc")
import lexer
$ if $usermodule
$ output 'parser.nit'
# Parser.
# This file was generated by SableCC (http://www.sablecc.org/).
-module parser is no_warning("missing-doc", "unread-variable")
+module parser is generated, no_warning("missing-doc", "unread-variable")
intrude import parser_prod
intrude import parser_work
#
# It uses, in order:
#
- # * the option `opt_no_color`
+ # * the option `opt_nit_dir`
# * the environment variable `NIT_DIR`
# * the runpath of the program from argv[0]
# * the runpath of the process from /proc
end
# search in the PATH
- var ps = "PATH".environ.split(":")
+ var path_sep = if is_windows then ";" else ":"
+ var ps = "PATH".environ.split(path_sep)
for p in ps do
res = p/".."
if check_nit_dir(res) then return res.simplify_path
# This file is generated by nitrestful
# Do not modify, instead refine the generated services.
module restful_annot_rest is
+ generated
no_warning("parentheses")
end
# This file is generated by nitserial
# Do not modify, but you can redef
module test_serialization_serial is
+ generated
no_warning("property-conflict")
end