summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2013-05-02 10:12:07 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2013-05-02 10:12:07 +0900
commit3d149f6350a9fb00e8f28fd0cb527d53ec5aec9c (patch)
tree3438cb01ec5518b9fc8f3a4e15fb199f2050b42a
parenta092e4102066bb1a039fdccbd301d44f69114648 (diff)
parentfd2e32e971a59ff3b20d7f5fede2aa4dd3c8263d (diff)
downloadmruby-3d149f6350a9fb00e8f28fd0cb527d53ec5aec9c.tar.gz
mruby-3d149f6350a9fb00e8f28fd0cb527d53ec5aec9c.zip
Merge branch 'master' of github.com:mruby/mruby
-rw-r--r--doc/mrbgems/README.md34
-rw-r--r--examples/targets/ArduinoDue.rb2
-rw-r--r--include/mruby.h33
-rw-r--r--mrbgems/default.gembox32
-rw-r--r--mrbgems/full-core.gembox7
-rw-r--r--src/range.c2
-rw-r--r--src/variable.c9
-rw-r--r--tasks/mruby_build_gem.rake12
8 files changed, 62 insertions, 69 deletions
diff --git a/doc/mrbgems/README.md b/doc/mrbgems/README.md
index 6b7462af5..1ad39a02b 100644
--- a/doc/mrbgems/README.md
+++ b/doc/mrbgems/README.md
@@ -6,7 +6,7 @@ standardised way into mruby.
## Usage
By default mrbgems is currently deactivated. As soon as you add a GEM to your
-build configuration (*build_config.rb*), mrbgems will be activated and the
+build configuration (i.e. *build_config.rb*), mrbgems will be activated and the
extension integrated.
To add a GEM into the *build_config.rb* add the following line for example:
@@ -25,41 +25,41 @@ A remote GIT repository location for a GEM is also supported:
conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
-NOTE: ':bitbucket' option supports only git. Hg is unsupported in this version.
+NOTE: `:bitbucket` option supports only git. Hg is unsupported in this version.
## GemBox
There are instances when you wish to add a collection of gems into mruby at
once, or be able to substitute gems based on configuration, without having to
add each gem to the *build_config.rb* file. A packaged collection of mrbgems
-is called a Gembox. A Gembox is a file that contains a list of gems to load
+is called a GemBox. A GemBox is a file that contains a list of gems to load
into mruby, in the same format as if you were adding them to *build_config.rb*
-via `config.gem`, but wrapped in an ```Mruby::GemBox``` object. Gemboxes are
-loaded into mruby via `config.gembox boxname`.
+via `config.gem`, but wrapped in an `MRuby::GemBox` object. GemBoxes are
+loaded into mruby via `config.gembox 'boxname'`.
-Below we have created a Gembox containing mruby-time and mrbgems-example:
+Below we have created a GemBox containing *mruby-time* and *mrbgems-example*:
MRuby::GemBox.new do |conf|
conf.gem "#{root}/mrbgems/mruby-time"
conf.gem :github => 'masuidrive/mrbgems-example'
end
-As mentioned, the Gembox uses the same conventions as `MRuby::Build`. The Gembox
+As mentioned, the GemBox uses the same conventions as `MRuby::Build`. The GemBox
must be saved with a *.gembox* extension inside the *mrbgems* directory to to be
picked up by mruby.
-To use this example Gembox, we save it as 'custom.box' inside the *mrbgems*
+To use this example GemBox, we save it as `custom.gembox` inside the *mrbgems*
directory in mruby, and add the following to our *build_config.rb* file inside
the build block:
conf.gembox 'custom'
-This will cause the 'custom' gembox to be read in during the build process,
-adding mruby-time and mrbgems-example to the build.
+This will cause the *custom* GemBox to be read in during the build process,
+adding *mruby-time* and *mrbgems-example* to the build.
-There are two Gemboxes that ship with mruby: [default](mrbgems/default.gembox)
-and [full-core](mrbgems/full-core). The [default](mrbgems/default.gembox) Gembox
-contains several core components of mruby, and [full-core](mrbgems/full-core)
+There are two GemBoxes that ship with mruby: [default](../../mrbgems/default.gembox)
+and [full-core](../../mrbgems/full-core.gembox). The [default](../../mrbgems/default.gembox) GemBox
+contains several core components of mruby, and [full-core](../../mrbgems/full-core.gembox)
contains every gem found in the *mrbgems* directory.
## GEM Structure
@@ -80,7 +80,7 @@ The maximal GEM structure looks like this:
The folder *mrblib* contains pure Ruby files to extend mruby. The folder *src*
contains C files to extend mruby. The folder *test* contains C and pure Ruby files
-for testing purposes which will be used by ```mrbtest```. *mrbgem.rake* contains
+for testing purposes which will be used by `mrbtest`. *mrbgem.rake* contains
the specification to compile C and Ruby files. *README.md* is a short description
of your GEM.
@@ -96,7 +96,7 @@ GEM direcotry. A typical GEM specification could look like this for example:
The mrbgems build process will use this specification to compile Object and Ruby
files. The compilation results will be add to *lib/libmruby.a*. This file is used
-by tools like ```mruby``` and ```mirb``` to empower the GEM functionality.
+by tools like `mruby` and `mirb` to empower the GEM functionality.
In case your GEM has more complex build requirements you can use
the following options additionally inside of your GEM specification:
@@ -120,7 +120,7 @@ integrate C libraries into mruby.
### Pre-Conditions
mrbgems expects that you have implemented a C method called
-```mrb_YOURGEMNAME_gem_init(mrb_state)```. ```YOURGEMNAME``` will be replaced
+`mrb_YOURGEMNAME_gem_init(mrb_state)`. `YOURGEMNAME` will be replaced
by the name of your GEM. If you call your GEM *c_extension_example*, your
initialisation method could look like this:
@@ -133,7 +133,7 @@ initialisation method could look like this:
### Finalize
mrbgems expects that you have implemented a C method called
-```mrb_YOURGEMNAME_gem_final(mrb_state)```. ```YOURGEMNAME``` will be replaced
+`mrb_YOURGEMNAME_gem_final(mrb_state)`. `YOURGEMNAME` will be replaced
by the name of your GEM. If you call your GEM *c_extension_example*, your
finalizer method could look like this:
diff --git a/examples/targets/ArduinoDue.rb b/examples/targets/ArduinoDue.rb
index 3fad6ecea..efbe51e97 100644
--- a/examples/targets/ArduinoDue.rb
+++ b/examples/targets/ArduinoDue.rb
@@ -1,4 +1,4 @@
-# Cross Compiling configuration for Arduino Duea
+# Cross Compiling configuration for Arduino Due
# http://arduino.cc/en/Main/ArduinoBoardDue
#
# Requires Arduino IDE >= 1.5
diff --git a/include/mruby.h b/include/mruby.h
index 5e3d78c1e..1317ee17d 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -161,7 +161,6 @@ struct RClass * mrb_class_new(mrb_state *mrb, struct RClass *super);
struct RClass * mrb_module_new(mrb_state *mrb);
int mrb_class_defined(mrb_state *mrb, const char *name);
struct RClass * mrb_class_get(mrb_state *mrb, const char *name);
-struct RClass * mrb_class_obj_get(mrb_state *mrb, const char *name);
mrb_value mrb_obj_dup(mrb_state *mrb, mrb_value obj);
mrb_value mrb_check_to_integer(mrb_state *mrb, mrb_value val, const char *method);
@@ -308,22 +307,22 @@ void mrb_bug(const char *fmt, ...);
+ those E_* macros requires mrb_state* variable named mrb.
+ exception objects obtained from those macros are local to mrb
*/
-#define E_RUNTIME_ERROR (mrb_class_obj_get(mrb, "RuntimeError"))
-#define E_TYPE_ERROR (mrb_class_obj_get(mrb, "TypeError"))
-#define E_ARGUMENT_ERROR (mrb_class_obj_get(mrb, "ArgumentError"))
-#define E_INDEX_ERROR (mrb_class_obj_get(mrb, "IndexError"))
-#define E_RANGE_ERROR (mrb_class_obj_get(mrb, "RangeError"))
-#define E_NAME_ERROR (mrb_class_obj_get(mrb, "NameError"))
-#define E_NOMETHOD_ERROR (mrb_class_obj_get(mrb, "NoMethodError"))
-#define E_SCRIPT_ERROR (mrb_class_obj_get(mrb, "ScriptError"))
-#define E_SYNTAX_ERROR (mrb_class_obj_get(mrb, "SyntaxError"))
-#define E_LOCALJUMP_ERROR (mrb_class_obj_get(mrb, "LocalJumpError"))
-#define E_REGEXP_ERROR (mrb_class_obj_get(mrb, "RegexpError"))
-
-#define E_NOTIMP_ERROR (mrb_class_obj_get(mrb, "NotImplementedError"))
-#define E_FLOATDOMAIN_ERROR (mrb_class_obj_get(mrb, "FloatDomainError"))
-
-#define E_KEY_ERROR (mrb_class_obj_get(mrb, "KeyError"))
+#define E_RUNTIME_ERROR (mrb_class_get(mrb, "RuntimeError"))
+#define E_TYPE_ERROR (mrb_class_get(mrb, "TypeError"))
+#define E_ARGUMENT_ERROR (mrb_class_get(mrb, "ArgumentError"))
+#define E_INDEX_ERROR (mrb_class_get(mrb, "IndexError"))
+#define E_RANGE_ERROR (mrb_class_get(mrb, "RangeError"))
+#define E_NAME_ERROR (mrb_class_get(mrb, "NameError"))
+#define E_NOMETHOD_ERROR (mrb_class_get(mrb, "NoMethodError"))
+#define E_SCRIPT_ERROR (mrb_class_get(mrb, "ScriptError"))
+#define E_SYNTAX_ERROR (mrb_class_get(mrb, "SyntaxError"))
+#define E_LOCALJUMP_ERROR (mrb_class_get(mrb, "LocalJumpError"))
+#define E_REGEXP_ERROR (mrb_class_get(mrb, "RegexpError"))
+
+#define E_NOTIMP_ERROR (mrb_class_get(mrb, "NotImplementedError"))
+#define E_FLOATDOMAIN_ERROR (mrb_class_get(mrb, "FloatDomainError"))
+
+#define E_KEY_ERROR (mrb_class_get(mrb, "KeyError"))
mrb_value mrb_yield(mrb_state *mrb, mrb_value v, mrb_value blk);
mrb_value mrb_yield_argv(mrb_state *mrb, mrb_value b, int argc, mrb_value *argv);
diff --git a/mrbgems/default.gembox b/mrbgems/default.gembox
index 7e81abd34..76a6c11b6 100644
--- a/mrbgems/default.gembox
+++ b/mrbgems/default.gembox
@@ -1,49 +1,49 @@
MRuby::GemBox.new do |conf|
# Use standard Kernel#sprintf method
- conf.gem "#{root}/mrbgems/mruby-sprintf"
+ conf.gem :core => "mruby-sprintf"
# Use standard print/puts/p
- conf.gem "#{root}/mrbgems/mruby-print"
+ conf.gem :core => "mruby-print"
# Use standard Math module
- conf.gem "#{root}/mrbgems/mruby-math"
+ conf.gem :core => "mruby-math"
# Use standard Time class
- conf.gem "#{root}/mrbgems/mruby-time"
+ conf.gem :core => "mruby-time"
# Use standard Struct class
- conf.gem "#{root}/mrbgems/mruby-struct"
+ conf.gem :core => "mruby-struct"
# Use extensional Enumerable module
- conf.gem "#{root}/mrbgems/mruby-enum-ext"
+ conf.gem :core => "mruby-enum-ext"
# Use extensional String class
- conf.gem "#{root}/mrbgems/mruby-string-ext"
+ conf.gem :core => "mruby-string-ext"
# Use extensional Numeric class
- conf.gem "#{root}/mrbgems/mruby-numeric-ext"
+ conf.gem :core => "mruby-numeric-ext"
# Use extensional Array class
- conf.gem "#{root}/mrbgems/mruby-array-ext"
+ conf.gem :core => "mruby-array-ext"
# Use extensional Hash class
- conf.gem "#{root}/mrbgems/mruby-hash-ext"
+ conf.gem :core => "mruby-hash-ext"
# Use extensional Range class
- conf.gem "#{root}/mrbgems/mruby-range-ext"
+ conf.gem :core => "mruby-range-ext"
# Use extensional Proc class
- conf.gem "#{root}/mrbgems/mruby-proc-ext"
+ conf.gem :core => "mruby-proc-ext"
# Use extensional Symbol class
- conf.gem "#{root}/mrbgems/mruby-symbol-ext"
+ conf.gem :core => "mruby-symbol-ext"
# Use Random class
- conf.gem "#{root}/mrbgems/mruby-random"
+ conf.gem :core => "mruby-random"
# Generate mirb command
- conf.gem "#{root}/mrbgems/mruby-bin-mirb"
+ conf.gem :core => "mruby-bin-mirb"
# Generate mruby command
- conf.gem "#{root}/mrbgems/mruby-bin-mruby"
+ conf.gem :core => "mruby-bin-mruby"
end
diff --git a/mrbgems/full-core.gembox b/mrbgems/full-core.gembox
index b9f19e452..4a6ebbc80 100644
--- a/mrbgems/full-core.gembox
+++ b/mrbgems/full-core.gembox
@@ -1,8 +1,9 @@
MRuby::GemBox.new do |conf|
- conf.gem "#{root}/mrbgems/mruby-sprintf"
- conf.gem "#{root}/mrbgems/mruby-print"
+ conf.gem :core => "mruby-sprintf"
+ conf.gem :core => "mruby-print"
Dir.glob("#{root}/mrbgems/mruby-*") do |x|
- conf.gem x unless x =~ /\/mruby-(print|sprintf)$/
+ g = File.basename(x)
+ conf.gem :core => g unless g =~ /^mruby-(print|sprintf)$/
end
end
diff --git a/src/range.c b/src/range.c
index 6068b9f99..7e3e03136 100644
--- a/src/range.c
+++ b/src/range.c
@@ -9,7 +9,7 @@
#include "mruby/range.h"
#include "mruby/string.h"
-#define RANGE_CLASS (mrb_class_obj_get(mrb, "Range"))
+#define RANGE_CLASS (mrb_class_get(mrb, "Range"))
static void
range_check(mrb_state *mrb, mrb_value a, mrb_value b)
diff --git a/src/variable.c b/src/variable.c
index 33932ec4c..355bdde14 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1066,15 +1066,6 @@ mrb_attr_get(mrb_state *mrb, mrb_value obj, mrb_sym id)
return mrb_iv_get(mrb, obj, id);
}
-struct RClass *
-mrb_class_obj_get(mrb_state *mrb, const char *name)
-{
- mrb_value mod = mrb_obj_value(mrb->object_class);
- mrb_sym sym = mrb_intern(mrb, name);
-
- return mrb_class_ptr(mrb_const_get(mrb, mod, sym));
-}
-
struct csym_arg {
struct RClass *c;
mrb_sym sym;
diff --git a/tasks/mruby_build_gem.rake b/tasks/mruby_build_gem.rake
index 993591efd..83c46de24 100644
--- a/tasks/mruby_build_gem.rake
+++ b/tasks/mruby_build_gem.rake
@@ -10,7 +10,7 @@ module MRuby
def gem(gemdir, &block)
caller_dir = File.expand_path(File.dirname(/^(.*?):\d/.match(caller.first).to_a[1]))
if gemdir.is_a?(Hash)
- gemdir = load_external_gem(gemdir)
+ gemdir = load_special_path_gem(gemdir)
else
gemdir = File.expand_path(gemdir, caller_dir)
end
@@ -28,14 +28,16 @@ module MRuby
Gem.current
end
- def load_external_gem(params)
+ def load_special_path_gem(params)
if params[:github]
params[:git] = "https://github.com/#{params[:github]}.git"
elsif params[:bitbucket]
params[:git] = "https://bitbucket.org/#{params[:bitbucket]}.git"
end
- if params[:git]
+ if params[:core]
+ gemdir = "#{root}/mrbgems/#{params[:core]}"
+ elsif params[:git]
url = params[:git]
gemdir = "build/mrbgems/#{url.match(/([-_\w]+)(\.[-_\w]+|)$/).to_a[1]}"
return gemdir if File.exists?(gemdir)
@@ -45,11 +47,11 @@ module MRuby
FileUtils.mkdir_p "build/mrbgems"
git.run_clone gemdir, url, options
-
- gemdir
else
fail "unknown gem option #{params}"
end
+
+ gemdir
end
def enable_gems?