Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
3d149f63
Commit
3d149f63
authored
May 02, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:mruby/mruby
parents
a092e410
fd2e32e9
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
62 additions
and
69 deletions
+62
-69
doc/mrbgems/README.md
doc/mrbgems/README.md
+17
-17
examples/targets/ArduinoDue.rb
examples/targets/ArduinoDue.rb
+1
-1
include/mruby.h
include/mruby.h
+16
-17
mrbgems/default.gembox
mrbgems/default.gembox
+16
-16
mrbgems/full-core.gembox
mrbgems/full-core.gembox
+4
-3
src/range.c
src/range.c
+1
-1
src/variable.c
src/variable.c
+0
-9
tasks/mruby_build_gem.rake
tasks/mruby_build_gem.rake
+7
-5
No files found.
doc/mrbgems/README.md
View file @
3d149f63
...
@@ -6,7 +6,7 @@ standardised way into mruby.
...
@@ -6,7 +6,7 @@ standardised way into mruby.
## Usage
## Usage
By default mrbgems is currently deactivated. As soon as you add a GEM to your
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.
extension integrated.
To add a GEM into the
*build_config.rb*
add the following line for example:
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:
...
@@ -25,41 +25,41 @@ A remote GIT repository location for a GEM is also supported:
conf.gem :bitbucket => 'mruby/mrbgems-example', :branch => 'master'
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
## GemBox
There are instances when you wish to add a collection of gems into mruby at
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
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
add each gem to the
*build_config.rb*
file. A packaged collection of mrbgems
is called a Gem
box. A Gemb
ox is a file that contains a list of gems to load
is called a Gem
Box. A GemB
ox 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*
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. Gemb
oxes are
via
`config.gem`
, but wrapped in an
`
MRuby::GemBox`
object. GemB
oxes are
loaded into mruby via
`config.gembox
boxname
`
.
loaded into mruby via
`config.gembox
'boxname'
`
.
Below we have created a Gem
box containing mruby-time and mrbgems-example
:
Below we have created a Gem
Box containing
*mruby-time*
and
*mrbgems-example*
:
MRuby::GemBox.new do |conf|
MRuby::GemBox.new do |conf|
conf.gem "#{root}/mrbgems/mruby-time"
conf.gem "#{root}/mrbgems/mruby-time"
conf.gem :github => 'masuidrive/mrbgems-example'
conf.gem :github => 'masuidrive/mrbgems-example'
end
end
As mentioned, the Gem
box uses the same conventions as
`MRuby::Build`
. The Gemb
ox
As mentioned, the Gem
Box uses the same conventions as
`MRuby::Build`
. The GemB
ox
must be saved with a
*.gembox*
extension inside the
*mrbgems*
directory to to be
must be saved with a
*.gembox*
extension inside the
*mrbgems*
directory to to be
picked up by mruby.
picked up by mruby.
To use this example Gem
box, we save it as 'custom.box'
inside the
*mrbgems*
To use this example Gem
Box, we save it as
`custom.gembox`
inside the
*mrbgems*
directory in mruby, and add the following to our
*build_config.rb*
file inside
directory in mruby, and add the following to our
*build_config.rb*
file inside
the build block:
the build block:
conf.gembox 'custom'
conf.gembox 'custom'
This will cause the
'custom' gemb
ox to be read in during the build process,
This will cause the
*custom*
GemB
ox to be read in during the build process,
adding
mruby-time and mrbgems-example
to the build.
adding
*mruby-time*
and
*mrbgems-example*
to the build.
There are two Gem
boxes that ship with mruby:
[
default
](
mrbgems/default.gembox
)
There are two Gem
Boxes that ship with mruby:
[
default
](
../../
mrbgems/default.gembox
)
and
[
full-core
](
mrbgems/full-core
)
. The
[
default
](
mrbgems/default.gembox
)
Gemb
ox
and
[
full-core
](
../../mrbgems/full-core.gembox
)
. The
[
default
](
../../mrbgems/default.gembox
)
GemB
ox
contains several core components of mruby, and
[
full-core
](
mrbgems/full-core
)
contains several core components of mruby, and
[
full-core
](
../../mrbgems/full-core.gembox
)
contains every gem found in the
*mrbgems*
directory.
contains every gem found in the
*mrbgems*
directory.
## GEM Structure
## GEM Structure
...
@@ -80,7 +80,7 @@ The maximal GEM structure looks like this:
...
@@ -80,7 +80,7 @@ The maximal GEM structure looks like this:
The folder
*mrblib*
contains pure Ruby files to extend mruby. The folder
*src*
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
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
the specification to compile C and Ruby files.
*README.md*
is a short description
of your GEM.
of your GEM.
...
@@ -96,7 +96,7 @@ GEM direcotry. A typical GEM specification could look like this for example:
...
@@ -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
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
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
In case your GEM has more complex build requirements you can use
the following options additionally inside of your GEM specification:
the following options additionally inside of your GEM specification:
...
@@ -120,7 +120,7 @@ integrate C libraries into mruby.
...
@@ -120,7 +120,7 @@ integrate C libraries into mruby.
### Pre-Conditions
### Pre-Conditions
mrbgems expects that you have implemented a C method called
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
by the name of your GEM. If you call your GEM
*c_extension_example*
, your
initialisation method could look like this:
initialisation method could look like this:
...
@@ -133,7 +133,7 @@ initialisation method could look like this:
...
@@ -133,7 +133,7 @@ initialisation method could look like this:
### Finalize
### Finalize
mrbgems expects that you have implemented a C method called
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
by the name of your GEM. If you call your GEM
*c_extension_example*
, your
finalizer method could look like this:
finalizer method could look like this:
...
...
examples/targets/ArduinoDue.rb
View file @
3d149f63
# Cross Compiling configuration for Arduino Due
a
# Cross Compiling configuration for Arduino Due
# http://arduino.cc/en/Main/ArduinoBoardDue
# http://arduino.cc/en/Main/ArduinoBoardDue
#
#
# Requires Arduino IDE >= 1.5
# Requires Arduino IDE >= 1.5
...
...
include/mruby.h
View file @
3d149f63
...
@@ -161,7 +161,6 @@ struct RClass * mrb_class_new(mrb_state *mrb, struct RClass *super);
...
@@ -161,7 +161,6 @@ struct RClass * mrb_class_new(mrb_state *mrb, struct RClass *super);
struct
RClass
*
mrb_module_new
(
mrb_state
*
mrb
);
struct
RClass
*
mrb_module_new
(
mrb_state
*
mrb
);
int
mrb_class_defined
(
mrb_state
*
mrb
,
const
char
*
name
);
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_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_obj_dup
(
mrb_state
*
mrb
,
mrb_value
obj
);
mrb_value
mrb_check_to_integer
(
mrb_state
*
mrb
,
mrb_value
val
,
const
char
*
method
);
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, ...);
...
@@ -308,22 +307,22 @@ void mrb_bug(const char *fmt, ...);
+ those E_* macros requires mrb_state* variable named mrb.
+ those E_* macros requires mrb_state* variable named mrb.
+ exception objects obtained from those macros are local to mrb
+ exception objects obtained from those macros are local to mrb
*/
*/
#define E_RUNTIME_ERROR (mrb_class_
obj_
get(mrb, "RuntimeError"))
#define E_RUNTIME_ERROR (mrb_class_get(mrb, "RuntimeError"))
#define E_TYPE_ERROR (mrb_class_
obj_
get(mrb, "TypeError"))
#define E_TYPE_ERROR (mrb_class_get(mrb, "TypeError"))
#define E_ARGUMENT_ERROR (mrb_class_
obj_
get(mrb, "ArgumentError"))
#define E_ARGUMENT_ERROR (mrb_class_get(mrb, "ArgumentError"))
#define E_INDEX_ERROR (mrb_class_
obj_
get(mrb, "IndexError"))
#define E_INDEX_ERROR (mrb_class_get(mrb, "IndexError"))
#define E_RANGE_ERROR (mrb_class_
obj_
get(mrb, "RangeError"))
#define E_RANGE_ERROR (mrb_class_get(mrb, "RangeError"))
#define E_NAME_ERROR (mrb_class_
obj_
get(mrb, "NameError"))
#define E_NAME_ERROR (mrb_class_get(mrb, "NameError"))
#define E_NOMETHOD_ERROR (mrb_class_
obj_
get(mrb, "NoMethodError"))
#define E_NOMETHOD_ERROR (mrb_class_get(mrb, "NoMethodError"))
#define E_SCRIPT_ERROR (mrb_class_
obj_
get(mrb, "ScriptError"))
#define E_SCRIPT_ERROR (mrb_class_get(mrb, "ScriptError"))
#define E_SYNTAX_ERROR (mrb_class_
obj_
get(mrb, "SyntaxError"))
#define E_SYNTAX_ERROR (mrb_class_get(mrb, "SyntaxError"))
#define E_LOCALJUMP_ERROR (mrb_class_
obj_
get(mrb, "LocalJumpError"))
#define E_LOCALJUMP_ERROR (mrb_class_get(mrb, "LocalJumpError"))
#define E_REGEXP_ERROR (mrb_class_
obj_
get(mrb, "RegexpError"))
#define E_REGEXP_ERROR (mrb_class_get(mrb, "RegexpError"))
#define E_NOTIMP_ERROR (mrb_class_
obj_
get(mrb, "NotImplementedError"))
#define E_NOTIMP_ERROR (mrb_class_get(mrb, "NotImplementedError"))
#define E_FLOATDOMAIN_ERROR (mrb_class_
obj_
get(mrb, "FloatDomainError"))
#define E_FLOATDOMAIN_ERROR (mrb_class_get(mrb, "FloatDomainError"))
#define E_KEY_ERROR (mrb_class_
obj_
get(mrb, "KeyError"))
#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
(
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
);
mrb_value
mrb_yield_argv
(
mrb_state
*
mrb
,
mrb_value
b
,
int
argc
,
mrb_value
*
argv
);
...
...
mrbgems/default.gembox
View file @
3d149f63
MRuby::GemBox.new do |conf|
MRuby::GemBox.new do |conf|
# Use standard Kernel#sprintf method
# Use standard Kernel#sprintf method
conf.gem
"#{root}/mrbgems/
mruby-sprintf"
conf.gem
:core => "
mruby-sprintf"
# Use standard print/puts/p
# Use standard print/puts/p
conf.gem
"#{root}/mrbgems/
mruby-print"
conf.gem
:core => "
mruby-print"
# Use standard Math module
# Use standard Math module
conf.gem
"#{root}/mrbgems/
mruby-math"
conf.gem
:core => "
mruby-math"
# Use standard Time class
# Use standard Time class
conf.gem
"#{root}/mrbgems/
mruby-time"
conf.gem
:core => "
mruby-time"
# Use standard Struct class
# Use standard Struct class
conf.gem
"#{root}/mrbgems/
mruby-struct"
conf.gem
:core => "
mruby-struct"
# Use extensional Enumerable module
# Use extensional Enumerable module
conf.gem
"#{root}/mrbgems/
mruby-enum-ext"
conf.gem
:core => "
mruby-enum-ext"
# Use extensional String class
# Use extensional String class
conf.gem
"#{root}/mrbgems/
mruby-string-ext"
conf.gem
:core => "
mruby-string-ext"
# Use extensional Numeric class
# Use extensional Numeric class
conf.gem
"#{root}/mrbgems/
mruby-numeric-ext"
conf.gem
:core => "
mruby-numeric-ext"
# Use extensional Array class
# Use extensional Array class
conf.gem
"#{root}/mrbgems/
mruby-array-ext"
conf.gem
:core => "
mruby-array-ext"
# Use extensional Hash class
# Use extensional Hash class
conf.gem
"#{root}/mrbgems/
mruby-hash-ext"
conf.gem
:core => "
mruby-hash-ext"
# Use extensional Range class
# Use extensional Range class
conf.gem
"#{root}/mrbgems/
mruby-range-ext"
conf.gem
:core => "
mruby-range-ext"
# Use extensional Proc class
# Use extensional Proc class
conf.gem
"#{root}/mrbgems/
mruby-proc-ext"
conf.gem
:core => "
mruby-proc-ext"
# Use extensional Symbol class
# Use extensional Symbol class
conf.gem
"#{root}/mrbgems/
mruby-symbol-ext"
conf.gem
:core => "
mruby-symbol-ext"
# Use Random class
# Use Random class
conf.gem
"#{root}/mrbgems/
mruby-random"
conf.gem
:core => "
mruby-random"
# Generate mirb command
# Generate mirb command
conf.gem
"#{root}/mrbgems/
mruby-bin-mirb"
conf.gem
:core => "
mruby-bin-mirb"
# Generate mruby command
# Generate mruby command
conf.gem
"#{root}/mrbgems/
mruby-bin-mruby"
conf.gem
:core => "
mruby-bin-mruby"
end
end
mrbgems/full-core.gembox
View file @
3d149f63
MRuby::GemBox.new do |conf|
MRuby::GemBox.new do |conf|
conf.gem
"#{root}/mrbgems/
mruby-sprintf"
conf.gem
:core => "
mruby-sprintf"
conf.gem
"#{root}/mrbgems/
mruby-print"
conf.gem
:core => "
mruby-print"
Dir.glob("#{root}/mrbgems/mruby-*") do |x|
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
end
end
src/range.c
View file @
3d149f63
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include "mruby/range.h"
#include "mruby/range.h"
#include "mruby/string.h"
#include "mruby/string.h"
#define RANGE_CLASS (mrb_class_
obj_
get(mrb, "Range"))
#define RANGE_CLASS (mrb_class_get(mrb, "Range"))
static
void
static
void
range_check
(
mrb_state
*
mrb
,
mrb_value
a
,
mrb_value
b
)
range_check
(
mrb_state
*
mrb
,
mrb_value
a
,
mrb_value
b
)
...
...
src/variable.c
View file @
3d149f63
...
@@ -1066,15 +1066,6 @@ mrb_attr_get(mrb_state *mrb, mrb_value obj, mrb_sym id)
...
@@ -1066,15 +1066,6 @@ mrb_attr_get(mrb_state *mrb, mrb_value obj, mrb_sym id)
return
mrb_iv_get
(
mrb
,
obj
,
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
csym_arg
{
struct
RClass
*
c
;
struct
RClass
*
c
;
mrb_sym
sym
;
mrb_sym
sym
;
...
...
tasks/mruby_build_gem.rake
View file @
3d149f63
...
@@ -10,7 +10,7 @@ module MRuby
...
@@ -10,7 +10,7 @@ module MRuby
def
gem
(
gemdir
,
&
block
)
def
gem
(
gemdir
,
&
block
)
caller_dir
=
File
.
expand_path
(
File
.
dirname
(
/^(.*?):\d/
.
match
(
caller
.
first
).
to_a
[
1
]))
caller_dir
=
File
.
expand_path
(
File
.
dirname
(
/^(.*?):\d/
.
match
(
caller
.
first
).
to_a
[
1
]))
if
gemdir
.
is_a?
(
Hash
)
if
gemdir
.
is_a?
(
Hash
)
gemdir
=
load_
external
_gem
(
gemdir
)
gemdir
=
load_
special_path
_gem
(
gemdir
)
else
else
gemdir
=
File
.
expand_path
(
gemdir
,
caller_dir
)
gemdir
=
File
.
expand_path
(
gemdir
,
caller_dir
)
end
end
...
@@ -28,14 +28,16 @@ module MRuby
...
@@ -28,14 +28,16 @@ module MRuby
Gem
.
current
Gem
.
current
end
end
def
load_
external
_gem
(
params
)
def
load_
special_path
_gem
(
params
)
if
params
[
:github
]
if
params
[
:github
]
params
[
:git
]
=
"https://github.com/
#{
params
[
:github
]
}
.git"
params
[
:git
]
=
"https://github.com/
#{
params
[
:github
]
}
.git"
elsif
params
[
:bitbucket
]
elsif
params
[
:bitbucket
]
params
[
:git
]
=
"https://bitbucket.org/
#{
params
[
:bitbucket
]
}
.git"
params
[
:git
]
=
"https://bitbucket.org/
#{
params
[
:bitbucket
]
}
.git"
end
end
if
params
[
:git
]
if
params
[
:core
]
gemdir
=
"
#{
root
}
/mrbgems/
#{
params
[
:core
]
}
"
elsif
params
[
:git
]
url
=
params
[
:git
]
url
=
params
[
:git
]
gemdir
=
"build/mrbgems/
#{
url
.
match
(
/([-_\w]+)(\.[-_\w]+|)$/
).
to_a
[
1
]
}
"
gemdir
=
"build/mrbgems/
#{
url
.
match
(
/([-_\w]+)(\.[-_\w]+|)$/
).
to_a
[
1
]
}
"
return
gemdir
if
File
.
exists?
(
gemdir
)
return
gemdir
if
File
.
exists?
(
gemdir
)
...
@@ -45,11 +47,11 @@ module MRuby
...
@@ -45,11 +47,11 @@ module MRuby
FileUtils
.
mkdir_p
"build/mrbgems"
FileUtils
.
mkdir_p
"build/mrbgems"
git
.
run_clone
gemdir
,
url
,
options
git
.
run_clone
gemdir
,
url
,
options
gemdir
else
else
fail
"unknown gem option
#{
params
}
"
fail
"unknown gem option
#{
params
}
"
end
end
gemdir
end
end
def
enable_gems?
def
enable_gems?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment