summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Rakefile1
-rw-r--r--doc/compile/README.md296
-rw-r--r--doc/mrbgems/README.md11
-rw-r--r--include/mruby/string.h1
-rw-r--r--src/array.c2
-rw-r--r--src/codegen.c35
-rw-r--r--src/dump.c8
-rw-r--r--src/object.c2
-rw-r--r--src/parse.y24
-rw-r--r--src/range.c4
-rw-r--r--src/state.c2
-rw-r--r--src/string.c22
-rw-r--r--src/struct.c4
-rw-r--r--src/vm.c2
-rw-r--r--tasks/mruby_build.rake2
15 files changed, 152 insertions, 264 deletions
diff --git a/Rakefile b/Rakefile
index 7d8dd4117..6a04ef87c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -31,6 +31,7 @@ depfiles = MRuby.targets['host'].bins.map do |bin|
install_path = MRuby.targets['host'].exefile("bin/#{bin}")
file install_path => MRuby.targets['host'].exefile("build/host/bin/#{bin}") do |t|
+ FileUtils.rm t.name, :force => true
FileUtils.cp t.prerequisites.first, t.name
end
diff --git a/doc/compile/README.md b/doc/compile/README.md
index ec995bd74..a86ddbe62 100644
--- a/doc/compile/README.md
+++ b/doc/compile/README.md
@@ -23,11 +23,9 @@ Inside of the root directory of the mruby source exist a file
called *build_config.rb*. This file contains the build configuration
of mruby and looks like this for example:
-```
-MRuby::Build.new do |conf|
- toolchain :gcc
-end
-```
+ MRuby::Build.new do |conf|
+ toolchain :gcc
+ end
All tools necessary to compile mruby can be set or modified here. In case
you want to maintain an additional *build_config.rb* you can define a
@@ -51,26 +49,20 @@ configurates the build environment for specific compiler infrastructures.
Toolchain configuration for the GNU C Compiler.
-```
-toolchain :gcc
-```
+ toolchain :gcc
#### clang
Toolchain configuration for the LLVM C Compiler clang. Mainly equal to the
GCC toolchain.
-```
-toolchain :clang
-```
+ toolchain :clang
#### Visual Studio 2012
Toolchain configuration for Visual Studio 2012 on Windows.
-```
-toolchain :vs2012
-```
+ toolchain :vs2012
### Binaries
@@ -81,108 +73,92 @@ process. The following tools can be selected:
* mirb (mruby interactive shell
To select all define an array in ```conf.bins```:
-```
-conf.bins = %(mrbc mruby mirb)
-```
+
+ conf.bins = %(mrbc mruby mirb)
### File Separator
Some environments require a different file separator character. It is possible to
set the character via ```conf.file_separator```.
-```
-conf.file_separator = '/'
-```
+ conf.file_separator = '/'
### C Compiler
Configuration of the C compiler binary, flags and include paths.
-```
-conf.cc do |cc|
- cc.command = ...
- cc.flags = ...
- cc.include_paths = ...
- cc.defines = ...
- cc.option_include_path = ...
- cc.option_define = ...
- cc.compile_options = ...
-end
-```
+ conf.cc do |cc|
+ cc.command = ...
+ cc.flags = ...
+ cc.include_paths = ...
+ cc.defines = ...
+ cc.option_include_path = ...
+ cc.option_define = ...
+ cc.compile_options = ...
+ end
### Linker
Configuration of the Linker binary, flags and library paths.
-```
-conf.linker do |linker|
- linker.command = ...
- linker.flags = ...
- linker.flags_before_libraries = ...
- linker.libraries = ...
- linker.flags_after_libraries = ...
- linker.library_paths = ....
- linker.option_library = ...
- linker.option_library_path = ...
- linker.link_options = ...
-end
-```
+ conf.linker do |linker|
+ linker.command = ...
+ linker.flags = ...
+ linker.flags_before_libraries = ...
+ linker.libraries = ...
+ linker.flags_after_libraries = ...
+ linker.library_paths = ....
+ linker.option_library = ...
+ linker.option_library_path = ...
+ linker.link_options = ...
+ end
### Archiver
Configuration of the Archiver binary and flags.
-```
-conf.archiver do |archiver|
- archiver.command = ...
- archiver.archive_options = ...
-end
-```
+ conf.archiver do |archiver|
+ archiver.command = ...
+ archiver.archive_options = ...
+ end
### Parser Generator
Configuration of the Parser Generator binary and flags.
-```
-conf.yacc do |yacc|
- yacc.command = ...
- yacc.compile_options = ...
-end
-```
+ conf.yacc do |yacc|
+ yacc.command = ...
+ yacc.compile_options = ...
+ end
### GPerf
Configuration of the GPerf binary and flags.
-```
-conf.gperf do |gperf|
- gperf.command = ...
- gperf.compile_options = ...
-end
-```
+
+ conf.gperf do |gperf|
+ gperf.command = ...
+ gperf.compile_options = ...
+ end
### File Extensions
-```
-conf.exts do |exts
- exts.object = ...
- exts.executable = ...
- exts.library = ...
-end
-```
+ conf.exts do |exts
+ exts.object = ...
+ exts.executable = ...
+ exts.library = ...
+ end
### Mrbgems
Integrate GEMs in the build process.
-```
-# Integrate GEM with additional configuration
-conf.gem 'path/to/gem' do |g|
- g.cc.flags << ...
-end
+ # Integrate GEM with additional configuration
+ conf.gem 'path/to/gem' do |g|
+ g.cc.flags << ...
+ end
-# Integrate GEM without additional configuration
-conf.gem 'path/to/another/gem'
-```
+ # Integrate GEM without additional configuration
+ conf.gem 'path/to/another/gem'
## Cross-Compilation
@@ -192,14 +168,12 @@ achive this the *build_config.rb* needs to contain an instance of
tools and flags for the target platform. An example could look
like this:
-```
-MRuby::CrossBuild.new('32bit') do |conf|
- toolchain :gcc
+ MRuby::CrossBuild.new('32bit') do |conf|
+ toolchain :gcc
- conf.cc.flags << "-m32"
- conf.linker.flags << "-m32
-end
-```
+ conf.cc.flags << "-m32"
+ conf.linker.flags << "-m32
+ end
All configuration options of ```MRuby::Build``` can also be used
in ```MRuby::CrossBuild```.
@@ -209,29 +183,27 @@ in ```MRuby::CrossBuild```.
During the build process the directory *build* will be created in the
root directory. The structure of this directory will look like this:
-```
-+- build
- |
- +- host
- |
- +- bin <- Binaries (mirb, mrbc and mruby)
- |
- +- lib <- Libraries (libmruby.a and libmruby_core.a)
- |
- +- mrblib
- |
- +- src
- |
- +- test <- mrbtest tool
- |
- +- tools
- |
- +- mirb
- |
- +- mrbc
- |
- +- mruby
-```
+ +- build
+ |
+ +- host
+ |
+ +- bin <- Binaries (mirb, mrbc and mruby)
+ |
+ +- lib <- Libraries (libmruby.a and libmruby_core.a)
+ |
+ +- mrblib
+ |
+ +- src
+ |
+ +- test <- mrbtest tool
+ |
+ +- tools
+ |
+ +- mirb
+ |
+ +- mrbc
+ |
+ +- mruby
The compilation workflow will look like this:
* compile all files under *src* (object files will be stored
@@ -263,48 +235,46 @@ link with *build/host/lib/libmruby.a*
In case of a cross-compilation to *i386* the *build* directory structure looks
like this:
-```
-+- build
- |
- +- host
- | |
- | +- bin <- Native Binaries
- | |
- | +- lib <- Native Libraries
- | |
- | +- mrblib
- | |
- | +- src
- | |
- | +- test <- Native mrbtest tool
- | |
- | +- tools
- | |
- | +- mirb
- | |
- | +- mrbc
- | |
- | +- mruby
- +- i386
- |
- +- bin <- Cross-compiled Binaries
- |
- +- lib <- Cross-compiled Libraries
- |
- +- mrblib
- |
- +- src
- |
- +- test <- Cross-compiled mrbtest tool
- |
- +- tools
- |
- +- mirb
- |
- +- mrbc
- |
- +- mruby
-```
+ +- build
+ |
+ +- host
+ | |
+ | +- bin <- Native Binaries
+ | |
+ | +- lib <- Native Libraries
+ | |
+ | +- mrblib
+ | |
+ | +- src
+ | |
+ | +- test <- Native mrbtest tool
+ | |
+ | +- tools
+ | |
+ | +- mirb
+ | |
+ | +- mrbc
+ | |
+ | +- mruby
+ +- i386
+ |
+ +- bin <- Cross-compiled Binaries
+ |
+ +- lib <- Cross-compiled Libraries
+ |
+ +- mrblib
+ |
+ +- src
+ |
+ +- test <- Cross-compiled mrbtest tool
+ |
+ +- tools
+ |
+ +- mirb
+ |
+ +- mrbc
+ |
+ +- mruby
An extra directory is created for the target platform. In case you
compile for *i386* a directory called *i386* is created under the
@@ -331,23 +301,23 @@ link with *build/i386/lib/libmruby.a*
link with *build/i386/lib/libmruby_core.a*
```
- _____________________________________________________________
-| Native Compilation for Host System |
-| _____ ______ _____ ____ ____ _____ |
-|| CC | -> |AR | -> |GEN | -> |CC | -> |CC | -> |AR ||
-|| *.c | |core.a| |y.tab| |mrbc| |*.rb| |lib.a||
-| ----- ------ ----- ---- ---- ----- |
- -------------------------------------------------------------
+ _______________________________________________________________
+| Native Compilation for Host System |
+| _____ ______ _____ ____ ____ _____ |
+| | CC | -> |AR | -> |GEN | -> |CC | -> |CC | -> |AR | |
+| | *.c | |core.a| |y.tab| |mrbc| |*.rb| |lib.a| |
+| ----- ------ ----- ---- ---- ----- |
+ ---------------------------------------------------------------
||
\||/
\/
- ______________________________________________________________
-| Cross Compilation for Target System |
-| _____ _____ _____ ____ ______ _____ |
-|| CC | -> |AR | -> |CC | -> |CC | -> |AR | -> |CC ||
-|| *.c | |lib.a| |mruby| |mirb| |core.a| |mrbc ||
-| ----- ----- ----- ---- ------ ----- |
- --------------------------------------------------------------
+ ________________________________________________________________
+| Cross Compilation for Target System |
+| _____ _____ _____ ____ ______ _____ |
+| | CC | -> |AR | -> |CC | -> |CC | -> |AR | -> |CC | |
+| | *.c | |lib.a| |mruby| |mirb| |core.a| |mrbc | |
+| ----- ----- ----- ---- ------ ----- |
+ ----------------------------------------------------------------
```
## Test Environment
diff --git a/doc/mrbgems/README.md b/doc/mrbgems/README.md
index 49c8f56d1..6c473b57d 100644
--- a/doc/mrbgems/README.md
+++ b/doc/mrbgems/README.md
@@ -99,13 +99,10 @@ mrbgems expects that you have implemented a C method called
by the name of your GEM. If you call your GEM *c_extension_example*, your
finalizer method could look like this:
-```
-void
-mrb_c_extension_example_gem_final(mrb_state* mrb) {
- free(someone);
-}
-```
-
+ void
+ mrb_c_extension_example_gem_final(mrb_state* mrb) {
+ free(someone);
+ }
### Example
diff --git a/include/mruby/string.h b/include/mruby/string.h
index cd2c83dcd..4ff0f1ee1 100644
--- a/include/mruby/string.h
+++ b/include/mruby/string.h
@@ -68,7 +68,6 @@ int mrb_str_offset(mrb_state *mrb, mrb_value str, int pos);
mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str); /* mrb_str_dup */
mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self);
mrb_value mrb_str_cat2(mrb_state *mrb, mrb_value str, const char *ptr);
-mrb_value mrb_str_catf(mrb_state *mrb, mrb_value str, const char *format, ...);
mrb_value mrb_str_to_inum(mrb_state *mrb, mrb_value str, int base, int badcheck);
double mrb_str_to_dbl(mrb_state *mrb, mrb_value str, int badcheck);
mrb_value mrb_str_to_str(mrb_state *mrb, mrb_value str);
diff --git a/src/array.c b/src/array.c
index d4f5d1c5e..a358e1207 100644
--- a/src/array.c
+++ b/src/array.c
@@ -66,7 +66,7 @@ mrb_ary_new(mrb_state *mrb)
static inline void
array_copy(mrb_value *dst, const mrb_value *src, size_t size)
{
- int i;
+ size_t i;
for (i = 0; i < size; i++) {
dst[i] = src[i];
diff --git a/src/codegen.c b/src/codegen.c
index 5c3614814..5803a9c25 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -4,7 +4,6 @@
** See Copyright Notice in mruby.h
*/
-#undef CODEGEN_TEST
#define CODEGEN_DUMP
#include "mruby.h"
@@ -2538,7 +2537,7 @@ codedump(mrb_state *mrb, int n)
void
codedump_all(mrb_state *mrb, int start)
{
- int i;
+ size_t i;
for (i=start; i<mrb->irep_len; i++) {
codedump(mrb, i);
@@ -2577,35 +2576,3 @@ mrb_generate_code(mrb_state *mrb, parser_state *p)
return start;
}
-
-#ifdef CODEGEN_TEST
-int
-main()
-{
- mrb_state *mrb = mrb_open();
- int n;
-
-#if 1
- n = mrb_compile_string(mrb, "p(__FILE__)\np(__LINE__)");
-#else
- n = mrb_compile_string(mrb, "\
-def fib(n)\n\
- if n<2\n\
- n\n\
- else\n\
- fib(n-2)+fib(n-1)\n\
- end\n\
-end\n\
-p(fib(30), \"\\n\")\n\
-");
-#endif
- printf("ret: %d\n", n);
-#ifdef CODEGEN_DUMP
- codedump_all(mrb, n);
-#endif
- mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[0]), mrb_nil_value());
- mrb_close(mrb);
-
- return 0;
-}
-#endif
diff --git a/src/dump.c b/src/dump.c
index 884a9141f..e0d755c8c 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -59,7 +59,7 @@ static inline int uint16_dump(uint16_t,char*,int);
static inline int uint32_dump(uint32_t,char*,int);
static char* str_dump(char*,char*,uint16_t,int);
static uint16_t str_dump_len(char*,uint16_t, int);
-static uint32_t get_irep_header_size(mrb_state*,mrb_irep*,int);
+static uint32_t get_irep_header_size(mrb_state*,int);
static uint32_t get_iseq_block_size(mrb_state*,mrb_irep*,int);
static uint32_t get_pool_block_size(mrb_state*,mrb_irep*,int);
static uint32_t get_syms_block_size(mrb_state*,mrb_irep*,int);
@@ -202,7 +202,7 @@ str_dump_len(char *str, uint16_t len, int type)
}
static uint32_t
-get_irep_header_size(mrb_state *mrb, mrb_irep *irep, int type)
+get_irep_header_size(mrb_state *mrb, int type)
{
uint32_t size = 0;
@@ -305,7 +305,7 @@ get_irep_record_size(mrb_state *mrb, int irep_no, int type)
mrb_irep *irep = mrb->irep[irep_no];
size += DUMP_SIZE(MRB_DUMP_SIZE_OF_LONG, type); /* rlen */
- size += get_irep_header_size(mrb, irep, type);
+ size += get_irep_header_size(mrb, type);
size += get_iseq_block_size(mrb, irep, type);
size += get_pool_block_size(mrb, irep, type);
size += get_syms_block_size(mrb, irep, type);
@@ -480,7 +480,7 @@ calc_crc_section(mrb_state *mrb, mrb_irep *irep, uint16_t *crc, int section)
int result;
switch (section) {
- case DUMP_IREP_HEADER: buf_size = get_irep_header_size(mrb, irep, type); break;
+ case DUMP_IREP_HEADER: buf_size = get_irep_header_size(mrb, type); break;
case DUMP_ISEQ_BLOCK: buf_size = get_iseq_block_size(mrb, irep, type); break;
case DUMP_POOL_BLOCK: buf_size = get_pool_block_size(mrb, irep, type); break;
case DUMP_SYMS_BLOCK: buf_size = get_syms_block_size(mrb, irep, type); break;
diff --git a/src/object.c b/src/object.c
index 99034e3be..f8ebd44bc 100644
--- a/src/object.c
+++ b/src/object.c
@@ -395,7 +395,7 @@ mrb_check_type(mrb_state *mrb, mrb_value x, enum mrb_vtype t)
{
const struct types *type = builtin_types;
struct RString *s;
- int xt;
+ enum mrb_vtype xt;
xt = mrb_type(x);
if ((xt != t) || (xt == MRB_TT_DATA)) {
diff --git a/src/parse.y b/src/parse.y
index 1ca3385f5..9ee9c9bec 100644
--- a/src/parse.y
+++ b/src/parse.y
@@ -5,7 +5,6 @@
*/
%{
-#undef PARSER_TEST
#undef PARSER_DEBUG
#define YYDEBUG 1
@@ -5648,26 +5647,3 @@ parser_dump(mrb_state *mrb, node *tree, int offset)
}
#endif
}
-
-#ifdef PARSER_TEST
-int
-main()
-{
- mrb_state *mrb = mrb_open();
- int n;
-
- n = mrb_compile_string(mrb, "\
-def fib(n)\n\
- if n<2\n\
- n\n\
- else\n\
- fib(n-2)+fib(n-1)\n\
- end\n\
-end\n\
-print(fib(20), \"\\n\")\n\
-");
- printf("ret: %d\n", n);
-
- return 0;
-}
-#endif
diff --git a/src/range.c b/src/range.c
index 8633b3116..2cdc34f5c 100644
--- a/src/range.c
+++ b/src/range.c
@@ -333,7 +333,7 @@ range_to_s(mrb_state *mrb, mrb_value range)
}
static mrb_value
-inspect_range(mrb_state *mrb, mrb_value range, mrb_value dummy, int recur)
+inspect_range(mrb_state *mrb, mrb_value range, int recur)
{
mrb_value str, str2;
struct RRange *r = mrb_range_ptr(range);
@@ -368,7 +368,7 @@ inspect_range(mrb_state *mrb, mrb_value range, mrb_value dummy, int recur)
static mrb_value
range_inspect(mrb_state *mrb, mrb_value range)
{
- return inspect_range(mrb, range, range, 0);
+ return inspect_range(mrb, range, 0);
}
/* 15.2.14.4.14(x) */
diff --git a/src/state.c b/src/state.c
index e30b0cea3..53773ac89 100644
--- a/src/state.c
+++ b/src/state.c
@@ -85,7 +85,7 @@ void mrb_free_heap(mrb_state *mrb);
void
mrb_close(mrb_state *mrb)
{
- int i;
+ size_t i;
mrb_final_core(mrb);
diff --git a/src/string.c b/src/string.c
index 144c4bd2a..df74bb3c8 100644
--- a/src/string.c
+++ b/src/string.c
@@ -6,7 +6,6 @@
#include "mruby.h"
-#include <stdarg.h>
#include <string.h>
#include "mruby/string.h"
#include <ctype.h>
@@ -2854,27 +2853,6 @@ mrb_str_cat2(mrb_state *mrb, mrb_value str, const char *ptr)
return mrb_str_cat(mrb, str, ptr, strlen(ptr));
}
-static mrb_value
-mrb_str_vcatf(mrb_state *mrb, mrb_value str, const char *fmt, va_list ap)
-{
- mrb_string_value(mrb, &str);
- mrb_str_resize(mrb, str, (char*)RSTRING_END(str) - RSTRING_PTR(str));
-
- return str;
-}
-
-mrb_value
-mrb_str_catf(mrb_state *mrb, mrb_value str, const char *format, ...)
-{
- va_list ap;
-
- va_start(ap, format);
- str = mrb_str_vcatf(mrb, str, format, ap);
- va_end(ap);
-
- return str;
-}
-
mrb_value
mrb_str_append(mrb_state *mrb, mrb_value str, mrb_value str2)
{
diff --git a/src/struct.c b/src/struct.c
index 85d0fa094..1396cd728 100644
--- a/src/struct.c
+++ b/src/struct.c
@@ -463,7 +463,7 @@ mrb_struct_initialize(mrb_state *mrb, mrb_value self, mrb_value values)
}
static mrb_value
-inspect_struct(mrb_state *mrb, mrb_value s, mrb_value dummy, int recur)
+inspect_struct(mrb_state *mrb, mrb_value s, int recur)
{
const char *cn = mrb_class_name(mrb, mrb_obj_class(mrb, s));
mrb_value members, str = mrb_str_new(mrb, "#<struct ", 9);
@@ -521,7 +521,7 @@ inspect_struct(mrb_state *mrb, mrb_value s, mrb_value dummy, int recur)
static mrb_value
mrb_struct_inspect(mrb_state *mrb, mrb_value s)
{
- return inspect_struct(mrb, s, s, 0);
+ return inspect_struct(mrb, s, 0);
}
/* 15.2.18.4.9 */
diff --git a/src/vm.c b/src/vm.c
index 696b566c8..ca31f6675 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -58,7 +58,7 @@ The value below allows about 60000 recursive calls in the simplest case. */
static inline void
stack_copy(mrb_value *dst, const mrb_value *src, size_t size)
{
- int i;
+ size_t i;
for (i = 0; i < size; i++) {
dst[i] = src[i];
diff --git a/tasks/mruby_build.rake b/tasks/mruby_build.rake
index ff62f92b8..cd9f77fc4 100644
--- a/tasks/mruby_build.rake
+++ b/tasks/mruby_build.rake
@@ -99,7 +99,7 @@ module MRuby
end
def mrbcfile
- exefile("build/host/bin/mrbc")
+ MRuby.targets['host'].exefile("build/host/bin/mrbc")
end
def compilers