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
e4231a0a
Commit
e4231a0a
authored
Mar 01, 2013
by
Masaki Muranaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add typedef to structures that have mrb_ prefix. Use typedef-ed type instead of struct directly.
parent
028ac46d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
33 additions
and
33 deletions
+33
-33
include/mruby/array.h
include/mruby/array.h
+4
-4
include/mruby/data.h
include/mruby/data.h
+6
-6
include/mruby/dump.h
include/mruby/dump.h
+2
-2
include/mruby/range.h
include/mruby/range.h
+3
-3
include/mruby/string.h
include/mruby/string.h
+4
-4
src/array.c
src/array.c
+3
-3
src/etc.c
src/etc.c
+4
-4
src/range.c
src/range.c
+2
-2
src/string.c
src/string.c
+5
-5
No files found.
include/mruby/array.h
View file @
e4231a0a
...
...
@@ -11,18 +11,18 @@
extern
"C"
{
#endif
struct
mrb_shared_array
{
typedef
struct
mrb_shared_array
{
int
refcnt
;
mrb_value
*
ptr
;
int
len
;
};
}
mrb_shared_array
;
struct
RArray
{
MRB_OBJECT_HEADER
;
int
len
;
union
{
int
capa
;
struct
mrb_shared_array
*
shared
;
mrb_shared_array
*
shared
;
}
aux
;
mrb_value
*
ptr
;
};
...
...
@@ -35,7 +35,7 @@ struct RArray {
#define RARRAY_PTR(a) (RARRAY(a)->ptr)
#define MRB_ARY_SHARED 256
void
mrb_ary_decref
(
mrb_state
*
,
struct
mrb_shared_array
*
);
void
mrb_ary_decref
(
mrb_state
*
,
mrb_shared_array
*
);
mrb_value
mrb_ary_new_capa
(
mrb_state
*
,
int
);
mrb_value
mrb_ary_new
(
mrb_state
*
mrb
);
mrb_value
mrb_ary_new_elts
(
mrb_state
*
mrb
,
int
n
,
const
mrb_value
*
elts
);
...
...
include/mruby/data.h
View file @
e4231a0a
...
...
@@ -11,19 +11,19 @@
extern
"C"
{
#endif
struct
mrb_data_type
{
typedef
struct
mrb_data_type
{
const
char
*
struct_name
;
void
(
*
dfree
)(
mrb_state
*
mrb
,
void
*
);
};
}
mrb_data_type
;
struct
RData
{
MRB_OBJECT_HEADER
;
struct
iv_tbl
*
iv
;
struct
mrb_data_type
*
type
;
mrb_data_type
*
type
;
void
*
data
;
};
struct
RData
*
mrb_data_object_alloc
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
void
*
datap
,
const
struct
mrb_data_type
*
type
);
struct
RData
*
mrb_data_object_alloc
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
void
*
datap
,
const
mrb_data_type
*
type
);
#define Data_Wrap_Struct(mrb,klass,type,ptr)\
mrb_data_object_alloc(mrb,klass,ptr,type)
...
...
@@ -37,8 +37,8 @@ struct RData *mrb_data_object_alloc(mrb_state *mrb, struct RClass* klass, void *
#define RDATA(obj) ((struct RData *)((obj).value.p))
#define DATA_PTR(d) (RDATA(d)->data)
#define DATA_TYPE(d) (RDATA(d)->type)
void
*
mrb_get_datatype
(
mrb_state
*
mrb
,
mrb_value
,
const
struct
mrb_data_type
*
);
void
*
mrb_check_datatype
(
mrb_state
*
mrb
,
mrb_value
,
const
struct
mrb_data_type
*
);
void
*
mrb_get_datatype
(
mrb_state
*
mrb
,
mrb_value
,
const
mrb_data_type
*
);
void
*
mrb_check_datatype
(
mrb_state
*
mrb
,
mrb_value
,
const
mrb_data_type
*
);
#define Data_Get_Struct(mrb,obj,type,sval) do {\
*(void**)&sval = mrb_check_datatype(mrb, obj, type); \
} while (0)
...
...
include/mruby/dump.h
View file @
e4231a0a
...
...
@@ -82,7 +82,7 @@ mrb_value mrb_load_irep_file(mrb_state*,FILE*);
#define MRB_DUMP_DEFAULT_STR_LEN 128
//Rite Binary file_header
typedef
struct
_rite_binary_header
{
typedef
struct
{
unsigned
char
rbfi
[
4
];
//Rite Binary File Identify
unsigned
char
rbfv
[
8
];
//Rite Binary File Format Version
unsigned
char
risv
[
8
];
//Rite Instruction Specification Version
...
...
@@ -95,7 +95,7 @@ typedef struct _rite_binary_header {
}
rite_binary_header
;
// Rite File file_header
typedef
struct
_rite_file_header
{
typedef
struct
{
unsigned
char
rbfi
[
4
];
//Rite Binary File Identify
unsigned
char
rbfv
[
8
];
//Rite Binary File Format Version
unsigned
char
risv
[
8
];
//Rite Instruction Specification Version
...
...
include/mruby/range.h
View file @
e4231a0a
...
...
@@ -11,14 +11,14 @@
extern
"C"
{
#endif
struct
mrb_range_edges
{
typedef
struct
mrb_range_edges
{
mrb_value
beg
;
mrb_value
end
;
};
}
mrb_range_edges
;
struct
RRange
{
MRB_OBJECT_HEADER
;
struct
mrb_range_edges
*
edges
;
mrb_range_edges
*
edges
;
int
excl
;
};
...
...
include/mruby/string.h
View file @
e4231a0a
...
...
@@ -21,18 +21,18 @@ extern "C" {
extern
const
char
mrb_digitmap
[];
struct
mrb_shared_string
{
typedef
struct
mrb_shared_string
{
int
refcnt
;
char
*
ptr
;
int
len
;
};
}
mrb_shared_string
;
struct
RString
{
MRB_OBJECT_HEADER
;
int
len
;
union
{
int
capa
;
struct
mrb_shared_string
*
shared
;
mrb_shared_string
*
shared
;
}
aux
;
char
*
ptr
;
};
...
...
@@ -45,7 +45,7 @@ struct RString {
#define RSTRING_END(s) (RSTRING(s)->ptr + RSTRING(s)->len)
#define MRB_STR_SHARED 256
void
mrb_str_decref
(
mrb_state
*
,
struct
mrb_shared_string
*
);
void
mrb_str_decref
(
mrb_state
*
,
mrb_shared_string
*
);
mrb_value
mrb_str_literal
(
mrb_state
*
,
mrb_value
);
void
mrb_str_concat
(
mrb_state
*
,
mrb_value
,
mrb_value
);
mrb_value
mrb_str_plus
(
mrb_state
*
,
mrb_value
,
mrb_value
);
...
...
src/array.c
View file @
e4231a0a
...
...
@@ -125,7 +125,7 @@ static void
ary_modify
(
mrb_state
*
mrb
,
struct
RArray
*
a
)
{
if
(
a
->
flags
&
MRB_ARY_SHARED
)
{
struct
mrb_shared_array
*
shared
=
a
->
aux
.
shared
;
mrb_shared_array
*
shared
=
a
->
aux
.
shared
;
if
(
shared
->
refcnt
==
1
&&
a
->
ptr
==
shared
->
ptr
)
{
a
->
ptr
=
shared
->
ptr
;
...
...
@@ -154,7 +154,7 @@ static void
ary_make_shared
(
mrb_state
*
mrb
,
struct
RArray
*
a
)
{
if
(
!
(
a
->
flags
&
MRB_ARY_SHARED
))
{
struct
mrb_shared_array
*
shared
=
(
struct
mrb_shared_array
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_shared_array
));
mrb_shared_array
*
shared
=
(
mrb_shared_array
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_shared_array
));
shared
->
refcnt
=
1
;
if
(
a
->
aux
.
capa
>
a
->
len
)
{
...
...
@@ -667,7 +667,7 @@ mrb_ary_len(mrb_state *mrb, mrb_value ary)
}
void
mrb_ary_decref
(
mrb_state
*
mrb
,
struct
mrb_shared_array
*
shared
)
mrb_ary_decref
(
mrb_state
*
mrb
,
mrb_shared_array
*
shared
)
{
shared
->
refcnt
--
;
if
(
shared
->
refcnt
==
0
)
{
...
...
src/etc.c
View file @
e4231a0a
...
...
@@ -11,19 +11,19 @@
#include "mruby/data.h"
struct
RData
*
mrb_data_object_alloc
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
void
*
ptr
,
const
struct
mrb_data_type
*
type
)
mrb_data_object_alloc
(
mrb_state
*
mrb
,
struct
RClass
*
klass
,
void
*
ptr
,
const
mrb_data_type
*
type
)
{
struct
RData
*
data
;
data
=
(
struct
RData
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_DATA
,
klass
);
data
->
data
=
ptr
;
data
->
type
=
(
struct
mrb_data_type
*
)
type
;
data
->
type
=
(
mrb_data_type
*
)
type
;
return
data
;
}
void
*
mrb_get_datatype
(
mrb_state
*
mrb
,
mrb_value
obj
,
const
struct
mrb_data_type
*
type
)
mrb_get_datatype
(
mrb_state
*
mrb
,
mrb_value
obj
,
const
mrb_data_type
*
type
)
{
if
(
mrb_special_const_p
(
obj
)
||
(
mrb_type
(
obj
)
!=
MRB_TT_DATA
))
{
return
NULL
;
...
...
@@ -35,7 +35,7 @@ mrb_get_datatype(mrb_state *mrb, mrb_value obj, const struct mrb_data_type *type
}
void
*
mrb_check_datatype
(
mrb_state
*
mrb
,
mrb_value
obj
,
const
struct
mrb_data_type
*
type
)
mrb_check_datatype
(
mrb_state
*
mrb
,
mrb_value
obj
,
const
mrb_data_type
*
type
)
{
static
const
char
mesg
[]
=
"wrong argument type %s (expected %s)"
;
...
...
src/range.c
View file @
e4231a0a
...
...
@@ -40,7 +40,7 @@ mrb_range_new(mrb_state *mrb, mrb_value beg, mrb_value end, int excl)
r
=
(
struct
RRange
*
)
mrb_obj_alloc
(
mrb
,
MRB_TT_RANGE
,
RANGE_CLASS
);
range_check
(
mrb
,
beg
,
end
);
r
->
edges
=
(
struct
mrb_range_edges
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_range_edges
));
r
->
edges
=
(
mrb_range_edges
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_range_edges
));
r
->
edges
->
beg
=
beg
;
r
->
edges
->
end
=
end
;
r
->
excl
=
excl
;
...
...
@@ -103,7 +103,7 @@ range_init(mrb_state *mrb, mrb_value range, mrb_value beg, mrb_value end, int ex
range_check
(
mrb
,
beg
,
end
);
r
->
excl
=
exclude_end
;
if
(
!
r
->
edges
)
{
r
->
edges
=
(
struct
mrb_range_edges
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_range_edges
));
r
->
edges
=
(
mrb_range_edges
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_range_edges
));
}
r
->
edges
->
beg
=
beg
;
r
->
edges
->
end
=
end
;
...
...
src/string.c
View file @
e4231a0a
...
...
@@ -35,7 +35,7 @@ _obj_classname(mrb_state *mrb, mrb_value obj)
}
void
mrb_str_decref
(
mrb_state
*
mrb
,
struct
mrb_shared_string
*
shared
)
mrb_str_decref
(
mrb_state
*
mrb
,
mrb_shared_string
*
shared
)
{
shared
->
refcnt
--
;
if
(
shared
->
refcnt
==
0
)
{
...
...
@@ -48,7 +48,7 @@ static void
str_modify
(
mrb_state
*
mrb
,
struct
RString
*
s
)
{
if
(
s
->
flags
&
MRB_STR_SHARED
)
{
struct
mrb_shared_string
*
shared
=
s
->
aux
.
shared
;
mrb_shared_string
*
shared
=
s
->
aux
.
shared
;
if
(
shared
->
refcnt
==
1
&&
s
->
ptr
==
shared
->
ptr
)
{
s
->
ptr
=
shared
->
ptr
;
...
...
@@ -275,7 +275,7 @@ static void
str_make_shared
(
mrb_state
*
mrb
,
struct
RString
*
s
)
{
if
(
!
(
s
->
flags
&
MRB_STR_SHARED
))
{
struct
mrb_shared_string
*
shared
=
(
struct
mrb_shared_string
*
)
mrb_malloc
(
mrb
,
sizeof
(
struct
mrb_shared_string
));
mrb_shared_string
*
shared
=
(
mrb_shared_string
*
)
mrb_malloc
(
mrb
,
sizeof
(
mrb_shared_string
));
shared
->
refcnt
=
1
;
if
(
s
->
aux
.
capa
>
s
->
len
)
{
...
...
@@ -301,7 +301,7 @@ mrb_value
mrb_str_literal
(
mrb_state
*
mrb
,
mrb_value
str
)
{
struct
RString
*
s
,
*
orig
;
struct
mrb_shared_string
*
shared
;
mrb_shared_string
*
shared
;
s
=
str_alloc
(
mrb
,
mrb
->
string_class
);
orig
=
mrb_str_ptr
(
str
);
...
...
@@ -1161,7 +1161,7 @@ static mrb_value
mrb_str_subseq
(
mrb_state
*
mrb
,
mrb_value
str
,
int
beg
,
int
len
)
{
struct
RString
*
orig
,
*
s
;
struct
mrb_shared_string
*
shared
;
mrb_shared_string
*
shared
;
orig
=
mrb_str_ptr
(
str
);
str_make_shared
(
mrb
,
orig
);
...
...
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