From c49990610aef6e0b885de2f5dd772c7ed89418a8 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 13 May 2012 19:43:14 +0800 Subject: Add a coding convention file --- doc/coding_conventions.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 doc/coding_conventions.md (limited to 'doc') diff --git a/doc/coding_conventions.md b/doc/coding_conventions.md new file mode 100644 index 000000000..646a052eb --- /dev/null +++ b/doc/coding_conventions.md @@ -0,0 +1,24 @@ +# Coding conventions + +How to style your C and Ruby code which you want submit to mruby. + +## C code + +The core part (parser, bytecode-interpreter, core-lib, etc.) of mruby is written in the C programming language. Please note the following hints for your C code: + ++ comply with C99 [ISO/IEC 9899:1999] ++ don't use C++ style comments, only use /* ... */ ++ reduce library dependencies to a minimum ++ insert a break after the method return value: + + int + main(void) + { + ... + } + +## Ruby code + +Parts of the standard library of mruby is written in the Ruby programming language itself. Please note the following hints for your Ruby code: + ++ -- cgit v1.2.3 From 5d93850df908863e44b3e132c82e07c6465ad4ea Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Sun, 13 May 2012 20:04:04 +0800 Subject: Format the text better and add some more text. --- doc/coding_conventions.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'doc') diff --git a/doc/coding_conventions.md b/doc/coding_conventions.md index 646a052eb..3d3d9d6f4 100644 --- a/doc/coding_conventions.md +++ b/doc/coding_conventions.md @@ -1,15 +1,24 @@ # Coding conventions -How to style your C and Ruby code which you want submit to mruby. +How to style your C and Ruby code which you want to submit. ## C code The core part (parser, bytecode-interpreter, core-lib, etc.) of mruby is written in the C programming language. Please note the following hints for your C code: -+ comply with C99 [ISO/IEC 9899:1999] -+ don't use C++ style comments, only use /* ... */ -+ reduce library dependencies to a minimum -+ insert a break after the method return value: +### Comply with C99 (ISO/IEC 9899:1999) + +mruby should be highly portable to other systems and compilers. For that it is recommended to keep your code as close as possible to the C99 standard (http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf). + +### Reduce library dependencies to a minimum + +The dependencies to libraries should be put to an absolute minimum. This increases the portability but makes it also easier to cut away parts of mruby on-demand. + +### Don't use C++ style comments + + /* This is the prefered comment style */ + +### Insert a break after the method return value: int main(void) @@ -21,4 +30,6 @@ The core part (parser, bytecode-interpreter, core-lib, etc.) of mruby is written Parts of the standard library of mruby is written in the Ruby programming language itself. Please note the following hints for your Ruby code: -+ +### Comply with the Ruby standard (ISO/IEC 30170:2012) + +mruby is currently targeting to execute Ruby code which complies to ISO/IEC 30170:2012 (http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=59579). \ No newline at end of file -- cgit v1.2.3