25 lines
1.3 KiB
Markdown
25 lines
1.3 KiB
Markdown
# Code style
|
|
All code is done with 2 spaces for indentation.
|
|
|
|
For cell script and its integration files, objects are preferred over classes, and preferrably limited use of prototypes, make objects sendable between actors (.ce files).
|
|
|
|
## cell script format
|
|
Cell script files end in .ce or .cm. Cell script is similar to Javascript but with some differences.
|
|
|
|
Variables are delcared with 'var'. Var behaves like let.
|
|
Constants are declared with 'def'.
|
|
!= and == are strict, there is no !== or ===.
|
|
There is no undefined, only null.
|
|
There are no classes, only objects and prototypes.
|
|
Prefer backticks for string interpolation. Otherwise, convering non strings with the text() function is required.
|
|
Everything should be lowercase.
|
|
|
|
There are no arraybuffers, only blobs, which work with bits. They must be stoned like stone(blob) before being read from.
|
|
|
|
## c format
|
|
For cell script integration files, everything should be declared static that can be. Most don't have headers at all. Files in a package are not shared between packages.
|
|
|
|
There is no undefined, so JS_IsNull and JS_NULL should be used only.
|
|
|
|
## how module loading is done in cell script
|
|
Within a package, a c file, if using the correct macros (CELL_USE_FUNCS etc), will be loaded as a module with its name; so png.c inside ac package is loaded as <package>/png, giving you access to its functions. |