From 1e5b00e772150afe1ec36e3edc131b8dc304e493 Mon Sep 17 00:00:00 2001 From: h2so5 Date: Wed, 1 May 2013 21:10:17 +0900 Subject: Remove mrb_class_obj_get --- include/mruby.h | 33 ++++++++++++++++----------------- src/range.c | 2 +- src/variable.c | 9 --------- 3 files changed, 17 insertions(+), 27 deletions(-) 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/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; -- cgit v1.2.3 From e6efc519a97473d3f020ee33dacb51f48a874ed4 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 2 May 2013 02:11:09 +0800 Subject: ArduinoDue Target Cosmetic Change small cosmetic change --- examples/targets/ArduinoDue.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.3 From 1f45b85a0b20990a6b6d1a2d21874d3a2b5620fb Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 2 May 2013 02:29:42 +0800 Subject: Cosmetic improvements of mrbgems documentation Cosmetic improvements of mrbgems documentation --- doc/mrbgems/README.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 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: -- cgit v1.2.3 From 045db9e528cb5907695a82673d34c2d322428eb0 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 2 May 2013 02:53:47 +0800 Subject: Implement :core parameter for conf.gem --- tasks/mruby_build_gem.rake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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? -- cgit v1.2.3 From 3afa961e8c56969f3f3bc3203fdde16ad5577f09 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 2 May 2013 02:54:08 +0800 Subject: Apply :core parameter to default.gembox --- mrbgems/default.gembox | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 -- cgit v1.2.3 From bffc9878ecd8cea73f4c3e1e1d29dec05041edc7 Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 2 May 2013 02:54:21 +0800 Subject: Apply :core parameter to full-core.gembox --- mrbgems/full-core.gembox | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 -- cgit v1.2.3