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
6eedb617
Unverified
Commit
6eedb617
authored
May 07, 2021
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
May 07, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5447 from dearblue/tab
Extend the tab with 8 whitespace
parents
bc620824
6fc5dc98
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
190 additions
and
180 deletions
+190
-180
doc/guides/compile.md
doc/guides/compile.md
+48
-44
doc/guides/mrbgems.md
doc/guides/mrbgems.md
+75
-69
mrbgems/mruby-pack/src/pack.c
mrbgems/mruby-pack/src/pack.c
+20
-20
mrbgems/mruby-socket/src/socket.c
mrbgems/mruby-socket/src/socket.c
+40
-40
mrbgems/mruby-string-ext/src/string.c
mrbgems/mruby-string-ext/src/string.c
+7
-7
No files found.
doc/guides/compile.md
View file @
6eedb617
...
...
@@ -333,9 +333,9 @@ conf.enable_debug
When debugging mode is enabled
*
Macro
`MRB_DEBUG`
would be defined.
*
Which means
`mrb_assert()`
macro is enabled.
*
Which means
`mrb_assert()`
macro is enabled.
*
Debug information of irep would be generated by
`mrbc`
.
*
Because
`-g`
flag would be added to
`mrbc`
runner.
*
Because
`-g`
flag would be added to
`mrbc`
runner.
*
You can have better backtrace of mruby scripts with this.
## Cross-Compilation
...
...
@@ -379,23 +379,25 @@ end
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
|
+- LEGAL <- License description
|
+- bin <- Binaries (mirb, mrbc and mruby)
|
+- lib <- Libraries (libmruby.a and libmruby_core.a)
|
+- mrbc <- Minimal mrbc place
|
+- mrbgems <- Compilation result from mrbgems
|
+- mrblib <- Compilation result from mrblib
|
+- src <- Compilation result from C sources
```
+- build
|
+- host
|
+- LEGAL <- License description
|
+- bin <- Binaries (mirb, mrbc and mruby)
|
+- lib <- Libraries (libmruby.a and libmruby_core.a)
|
+- mrbc <- Minimal mrbc place
|
+- mrbgems <- Compilation result from mrbgems
|
+- mrblib <- Compilation result from mrblib
|
+- src <- Compilation result from C sources
```
The compilation workflow will look like this:
...
...
@@ -425,31 +427,33 @@ The compilation workflow will look like this:
In case of a cross-compilation to
`i386`
the
`build`
directory structure looks
like this:
+- build
|
+- host
| |
| +- bin <- Native Binaries
| |
| +- lib <- Native Libraries
| |
| +- mrbgems
| |
| +- src
|
+- i386
|
+- bin <- Cross-compiled Binaries
|
+- include <- Header Directory
|
+- lib <- Cross-compiled Libraries
|
+- mrbgems
|
+- mrblib
|
+- src
```
+- build
|
+- host
| |
| +- bin <- Native Binaries
| |
| +- lib <- Native Libraries
| |
| +- mrbgems
| |
| +- src
|
+- i386
|
+- bin <- Cross-compiled Binaries
|
+- include <- Header Directory
|
+- lib <- Cross-compiled Libraries
|
+- mrbgems
|
+- mrblib
|
+- src
```
An extra directory is created for the target platform. In case you
compile for
`i386`
a directory called
`i386`
is created under the
...
...
doc/guides/mrbgems.md
View file @
6eedb617
...
...
@@ -111,21 +111,21 @@ contains every gem found in the `mrbgems` directory.
The maximal GEM structure looks like this:
```
+- GEM_NAME <- Name of GEM
|
+- README.md
<- Readme for GEM
|
+- mrbgem.rake
<- GEM Specification
|
+- include/
<- Header for Ruby extension (will exported)
|
+- mrblib/
<- Source for Ruby extension
|
+- src/
<- Source for C extension
|
+- tools/
<- Source for Executable (in C)
|
+- test/
<- Test code (Ruby)
+- GEM_NAME
<- Name of GEM
|
+- README.md
<- Readme for GEM
|
+- mrbgem.rake
<- GEM Specification
|
+- include/
<- Header for Ruby extension (will exported)
|
+- mrblib/
<- Source for Ruby extension
|
+- src/
<- Source for C extension
|
+- tools/
<- Source for Executable (in C)
|
+- test/
<- Test code (Ruby)
```
The folder
`mrblib`
contains pure Ruby files to extend mruby. The folder
`src`
...
...
@@ -297,19 +297,21 @@ mrb_c_extension_example_gem_final(mrb_state* mrb) {
### Example
+- c_extension_example/
|
+- README.md (Optional)
|
+- src/
| |
| +- example.c <- C extension source
|
+- test/
| |
| +- example.rb <- Test code for C extension
|
+- mrbgem.rake <- GEM specification
```
+- c_extension_example/
|
+- README.md (Optional)
|
+- src/
| |
| +- example.c <- C extension source
|
+- test/
| |
| +- example.rb <- Test code for C extension
|
+- mrbgem.rake <- GEM specification
```
## Ruby Extension
...
...
@@ -323,19 +325,21 @@ none
### Example
+- ruby_extension_example/
|
+- README.md (Optional)
|
+- mrblib/
| |
| +- example.rb <- Ruby extension source
|
+- test/
| |
| +- example.rb <- Test code for Ruby extension
|
+- mrbgem.rake <- GEM specification
```
+- ruby_extension_example/
|
+- README.md (Optional)
|
+- mrblib/
| |
| +- example.rb <- Ruby extension source
|
+- test/
| |
| +- example.rb <- Test code for Ruby extension
|
+- mrbgem.rake <- GEM specification
```
## C and Ruby Extension
...
...
@@ -353,23 +357,25 @@ See C and Ruby example.
### Example
+- c_and_ruby_extension_example/
|
+- README.md (Optional)
|
+- mrblib/
| |
| +- example.rb <- Ruby extension source
|
+- src/
| |
| +- example.c <- C extension source
|
+- test/
| |
| +- example.rb <- Test code for C and Ruby extension
|
+- mrbgem.rake <- GEM specification
```
+- c_and_ruby_extension_example/
|
+- README.md (Optional)
|
+- mrblib/
| |
| +- example.rb <- Ruby extension source
|
+- src/
| |
| +- example.c <- C extension source
|
+- test/
| |
| +- example.rb <- Test code for C and Ruby extension
|
+- mrbgem.rake <- GEM specification
```
## Binary gems
...
...
@@ -389,23 +395,23 @@ binary gems, to separate normal gems and binary gems.
### Example
```
+- mruby-bin-example/
+- mruby-bin-example/
|
+- README.md
(Optional)
+- README.md (Optional)
|
+- bintest/
| |
|
+- example.rb
<- Test code for binary gem
|
|
|
+- example.rb
<- Test code for binary gem
|
+- mrbgem.rake
<- Gem specification
+- mrbgem.rake <- Gem specification
|
+- mrblib/
<- Source for Ruby extension (Optional)
+- mrblib/ <- Source for Ruby extension (Optional)
|
+- src/
<- Source for C extension (Optional)
+- src/ <- Source for C extension (Optional)
|
+- tools/
|
+- example/
<- Executable name directory
|
+- example.c
<- Source for Executable (includes main)
|
+- example/
<- Executable name directory
|
+- example.c
<- Source for Executable (includes main)
```
mrbgems/mruby-pack/src/pack.c
View file @
6eedb617
...
...
@@ -48,19 +48,19 @@ enum {
PACK_TYPE_NONE
};
#define PACK_FLAG_s 0x00000001
/* native size ("_" "!") */
#define PACK_FLAG_a 0x00000002
/* null padding ("a") */
#define PACK_FLAG_Z 0x00000004
/* append nul char ("z") */
#define PACK_FLAG_SIGNED 0x00000008
/* native size ("_" "!") */
#define PACK_FLAG_GT 0x00000010
/* big endian (">") */
#define PACK_FLAG_LT 0x00000020
/* little endian ("<") */
#define PACK_FLAG_WIDTH 0x00000040
/* "count" is "width" */
#define PACK_FLAG_LSB 0x00000080
/* LSB / low nibble first */
#define PACK_FLAG_COUNT2 0x00000100
/* "count" is special... */
#define PACK_FLAG_LITTLEENDIAN 0x00000200
/* little endian actually */
#define PACK_BASE64_IGNORE
0xff
#define PACK_BASE64_PADDING
0xfe
#define PACK_FLAG_s 0x00000001
/* native size ("_" "!") */
#define PACK_FLAG_a 0x00000002
/* null padding ("a") */
#define PACK_FLAG_Z 0x00000004
/* append nul char ("z") */
#define PACK_FLAG_SIGNED 0x00000008
/* native size ("_" "!") */
#define PACK_FLAG_GT 0x00000010
/* big endian (">") */
#define PACK_FLAG_LT 0x00000020
/* little endian ("<") */
#define PACK_FLAG_WIDTH 0x00000040
/* "count" is "width" */
#define PACK_FLAG_LSB 0x00000080
/* LSB / low nibble first */
#define PACK_FLAG_COUNT2 0x00000100
/* "count" is special... */
#define PACK_FLAG_LITTLEENDIAN 0x00000200
/* little endian actually */
#define PACK_BASE64_IGNORE
0xff
#define PACK_BASE64_PADDING
0xfe
const
static
unsigned
char
base64chars
[]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
...
...
@@ -874,13 +874,13 @@ unpack_m(mrb_state *mrb, const void *src, int slen, mrb_value ary, unsigned int
if
(
slen
--
==
0
)
goto
done
;
c
=
*
sptr
++
;
if
(
c
>=
sizeof
(
base64_dec_tab
))
continue
;
ch
[
i
]
=
base64_dec_tab
[
c
];
if
(
ch
[
i
]
==
PACK_BASE64_PADDING
)
{
ch
[
i
]
=
0
;
padding
++
;
}
if
(
c
>=
sizeof
(
base64_dec_tab
))
continue
;
ch
[
i
]
=
base64_dec_tab
[
c
];
if
(
ch
[
i
]
==
PACK_BASE64_PADDING
)
{
ch
[
i
]
=
0
;
padding
++
;
}
}
while
(
c
>=
sizeof
(
base64_dec_tab
)
||
ch
[
i
]
==
PACK_BASE64_IGNORE
);
}
...
...
mrbgems/mruby-socket/src/socket.c
View file @
6eedb617
...
...
@@ -65,52 +65,52 @@
#ifdef _WIN32
static
const
char
*
inet_ntop
(
int
af
,
const
void
*
src
,
char
*
dst
,
socklen_t
cnt
)
{
if
(
af
==
AF_INET
)
{
struct
sockaddr_in
in
;
memset
(
&
in
,
0
,
sizeof
(
in
));
in
.
sin_family
=
AF_INET
;
memcpy
(
&
in
.
sin_addr
,
src
,
sizeof
(
struct
in_addr
));
getnameinfo
((
struct
sockaddr
*
)
&
in
,
sizeof
(
struct
sockaddr_in
),
dst
,
cnt
,
NULL
,
0
,
NI_NUMERICHOST
);
return
dst
;
}
else
if
(
af
==
AF_INET6
)
{
struct
sockaddr_in6
in
;
memset
(
&
in
,
0
,
sizeof
(
in
));
in
.
sin6_family
=
AF_INET6
;
memcpy
(
&
in
.
sin6_addr
,
src
,
sizeof
(
struct
in_addr6
));
getnameinfo
((
struct
sockaddr
*
)
&
in
,
sizeof
(
struct
sockaddr_in6
),
dst
,
cnt
,
NULL
,
0
,
NI_NUMERICHOST
);
return
dst
;
}
return
NULL
;
if
(
af
==
AF_INET
)
{
struct
sockaddr_in
in
;
memset
(
&
in
,
0
,
sizeof
(
in
));
in
.
sin_family
=
AF_INET
;
memcpy
(
&
in
.
sin_addr
,
src
,
sizeof
(
struct
in_addr
));
getnameinfo
((
struct
sockaddr
*
)
&
in
,
sizeof
(
struct
sockaddr_in
),
dst
,
cnt
,
NULL
,
0
,
NI_NUMERICHOST
);
return
dst
;
}
else
if
(
af
==
AF_INET6
)
{
struct
sockaddr_in6
in
;
memset
(
&
in
,
0
,
sizeof
(
in
));
in
.
sin6_family
=
AF_INET6
;
memcpy
(
&
in
.
sin6_addr
,
src
,
sizeof
(
struct
in_addr6
));
getnameinfo
((
struct
sockaddr
*
)
&
in
,
sizeof
(
struct
sockaddr_in6
),
dst
,
cnt
,
NULL
,
0
,
NI_NUMERICHOST
);
return
dst
;
}
return
NULL
;
}
static
int
inet_pton
(
int
af
,
const
char
*
src
,
void
*
dst
)
{
struct
addrinfo
hints
,
*
res
,
*
ressave
;
struct
addrinfo
hints
,
*
res
,
*
ressave
;
memset
(
&
hints
,
0
,
sizeof
(
struct
addrinfo
));
hints
.
ai_family
=
af
;
memset
(
&
hints
,
0
,
sizeof
(
struct
addrinfo
));
hints
.
ai_family
=
af
;
if
(
getaddrinfo
(
src
,
NULL
,
&
hints
,
&
res
)
!=
0
)
{
printf
(
"Couldn't resolve host %s
\n
"
,
src
);
return
-
1
;
}
if
(
getaddrinfo
(
src
,
NULL
,
&
hints
,
&
res
)
!=
0
)
{
printf
(
"Couldn't resolve host %s
\n
"
,
src
);
return
-
1
;
}
ressave
=
res
;
ressave
=
res
;
while
(
res
)
{
memcpy
(
dst
,
res
->
ai_addr
,
res
->
ai_addrlen
);
res
=
res
->
ai_next
;
}
while
(
res
)
{
memcpy
(
dst
,
res
->
ai_addr
,
res
->
ai_addrlen
);
res
=
res
->
ai_next
;
}
freeaddrinfo
(
ressave
);
return
0
;
freeaddrinfo
(
ressave
);
return
0
;
}
#endif
...
...
@@ -574,7 +574,7 @@ mrb_ipsocket_recvfrom(mrb_state *mrb, mrb_value self)
buf
=
mrb_str_new_capa
(
mrb
,
maxlen
);
socklen
=
sizeof
(
ss
);
n
=
recvfrom
(
fd
,
RSTRING_PTR
(
buf
),
(
fsize_t
)
maxlen
,
(
int
)
flags
,
(
struct
sockaddr
*
)
&
ss
,
&
socklen
);
(
struct
sockaddr
*
)
&
ss
,
&
socklen
);
if
(
n
==
-
1
)
{
mrb_sys_fail
(
mrb
,
"recvfrom"
);
}
...
...
@@ -938,8 +938,8 @@ mrb_mruby_socket_gem_init(mrb_state* mrb)
constants
=
mrb_define_module_under
(
mrb
,
sock
,
"Constants"
);
#define define_const(SYM) \
do {
\
mrb_define_const(mrb, constants, #SYM, mrb_int_value(mrb, SYM));
\
do {
\
mrb_define_const(mrb, constants, #SYM, mrb_int_value(mrb, SYM));
\
} while (0)
#include "const.cstub"
...
...
mrbgems/mruby-string-ext/src/string.c
View file @
6eedb617
...
...
@@ -262,7 +262,7 @@ enum tr_pattern_type {
<range> ::= <ch> '-' <ch>
*/
struct
tr_pattern
{
uint8_t
type
;
// 1:in-order, 2:range
uint8_t
type
;
// 1:in-order, 2:range
mrb_bool
flag_reverse
:
1
;
mrb_bool
flag_on_heap
:
1
;
uint16_t
n
;
...
...
@@ -329,9 +329,9 @@ tr_parse_pattern(mrb_state *mrb, struct tr_pattern *ret, const mrb_value v_patte
mrb_int
len
;
while
(
i
<
pattern_length
)
{
if
((
i
+
2
)
<
pattern_length
&&
pattern
[
i
]
!=
'\\'
&&
pattern
[
i
+
1
]
==
'-'
)
if
((
i
+
2
)
<
pattern_length
&&
pattern
[
i
]
!=
'\\'
&&
pattern
[
i
+
1
]
==
'-'
)
break
;
i
++
;
i
++
;
}
len
=
i
-
start_pos
;
...
...
@@ -375,7 +375,7 @@ tr_find_character(const struct tr_pattern *pat, const char *pat_str, int ch)
if
(
pat
->
type
==
TR_IN_ORDER
)
{
int
i
;
for
(
i
=
0
;
i
<
pat
->
n
;
i
++
)
{
if
(
pat_str
[
pat
->
val
.
start_pos
+
i
]
==
ch
)
ret
=
n_sum
+
i
;
if
(
pat_str
[
pat
->
val
.
start_pos
+
i
]
==
ch
)
ret
=
n_sum
+
i
;
}
}
else
if
(
pat
->
type
==
TR_RANGE
)
{
...
...
@@ -509,7 +509,7 @@ str_tr(mrb_state *mrb, mrb_value str, mrb_value p1, mrb_value p2, mrb_bool squee
if
(
n
>=
0
)
{
flag_changed
=
TRUE
;
if
(
rep
==
NULL
)
{
j
--
;
j
--
;
}
else
{
mrb_int
c
=
tr_get_character
(
rep
,
RSTRING_PTR
(
p2
),
n
);
...
...
@@ -521,8 +521,8 @@ str_tr(mrb_state *mrb, mrb_value str, mrb_value p1, mrb_value p2, mrb_bool squee
if
(
c
>
0x80
)
{
mrb_raisef
(
mrb
,
E_ARGUMENT_ERROR
,
"character (%i) out of range"
,
c
);
}
lastch
=
c
;
s
[
i
]
=
(
char
)
c
;
lastch
=
c
;
s
[
i
]
=
(
char
)
c
;
}
}
}
...
...
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