-
Notifications
You must be signed in to change notification settings - Fork 2
Make boot.r
File: https://github.com/angerangel/r3bazaar/blob/master/src/tools/make-boot.r
- It launches
[[form-header.r]]
- It launches
[[systems.r]]
- It sets:
- target: TO_WIN32
- graphics-targets: [TO_WIN32]
- has-graphics: false (Why is this set to false? @angerangel)
- opts: system/options/args to 0.3.1
- check that there are some really options or set opts to none.
- it creates a write-if function: it check file to update
- it sets directory variables (boot, inc, src)
- set version
- it sets Title to a generic title and license for every file
- it sets sections block to this list: boot-types, boot-words, boot-root, boot-task, boot-strings, boot-booters, boot-actions, boot-natives, boot-ops, boot-typespecs, boot-errors, boot-sysobj, boot-base, boot-sys, boot-mezz, boot-protocols
- set include-protocols to false (Why?)
- creates an error handler function called error
- set some other variables (product, platform-data, build)
- create the up-word function to uppercase names
- creates a to-c-name function to convert names to standard C names
- crates an empty string called out
- emit function to append data to out
- emit-enum append to out a TAB, a standard C name, a comma (,) and a newline. (probably it is used to use a pretty print style)
- emit-line another pretty print function
- emit-head and emit-end pretty print functions
- binary-to-c function: this will be a long explanation, thank to kuma to undertand how it works:
that function converts a binary rebol string into a rebol string of pretty print comma separated ascii values.
for example, it converts "ABC" to "65, 66, 67"
The weird stuff here it is coded in different way for windows or unix systems, in fact, binary-to-c is two functions in one, when the system running the code is a windows system ( system/version/4 = 3 ) then first version is used, other case when system is a unix-like, second version is used.
windows version is:
func [comp-data /local out] [
out: make string! 4 * (length? comp-data)
forall comp-data [
out: insert out reduce [to-integer first comp-data ", "]
if zero? ((index? comp-data) // 10) [out: insert out "^/^-"]
]
head out
]
unix version is:
func [comp-data /local out] [
out: make string! 4 * (length? comp-data)
forall comp-data [
data: copy/part comp-data 16
comp-data: skip comp-data 15
data: enbase/base data 16
forall data [
insert data "\x"
data: skip data 3
]
data: tail data
insert data {"^/}
append out {"}
append out head data
]
head out
]
The trick here is both function do not work the same, windows version converts string to decimal ascii values comma separated with a prettyprint consisting in an initial tab and a EOL each ten values, example:
"ABC" -> "/t65, 66, 67, "
"ABCDEFGHIJKILH" -> "/t65, 66, 67, 68, 69, 70, 71, 72, 73, 74, /n/t75, 76, 77, 78, "
where /t represents tab ascii value and /n represents new line ascii value (EOL)
whereas unix version converts string to hex ascii values in c format with a trailing EOL, example:
"ABC" -> "\x41\x42\x43/n"
"ABCDEFGHIJKILH" -> "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x50\x51\x52\x53\x54/n"
in order to work properly functions expects comp-data parameter to be of type binary! and, as far as I saw, it is used with compressed binary strings, i.e. compress to-binary "string to convert, usually a rebol source file"
- ... to be finished