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
b7d6b4d0
Commit
b7d6b4d0
authored
Aug 14, 2013
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
define allocation method for Time class; close #1474
parent
0dfda0c9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
mrbgems/mruby-time/src/time.c
mrbgems/mruby-time/src/time.c
+11
-3
No files found.
mrbgems/mruby-time/src/time.c
View file @
b7d6b4d0
...
@@ -147,7 +147,7 @@ mrb_time_wrap(mrb_state *mrb, struct RClass *tc, struct mrb_time *tm)
...
@@ -147,7 +147,7 @@ mrb_time_wrap(mrb_state *mrb, struct RClass *tc, struct mrb_time *tm)
/* Allocates a mrb_time object and initializes it. */
/* Allocates a mrb_time object and initializes it. */
static
struct
mrb_time
*
static
struct
mrb_time
*
mrb_
time_alloc
(
mrb_state
*
mrb
,
double
sec
,
double
usec
,
enum
mrb_timezone
timezone
)
time_alloc
(
mrb_state
*
mrb
,
double
sec
,
double
usec
,
enum
mrb_timezone
timezone
)
{
{
struct
mrb_time
*
tm
;
struct
mrb_time
*
tm
;
...
@@ -171,7 +171,14 @@ mrb_time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezo
...
@@ -171,7 +171,14 @@ mrb_time_alloc(mrb_state *mrb, double sec, double usec, enum mrb_timezone timezo
static
mrb_value
static
mrb_value
mrb_time_make
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
double
sec
,
double
usec
,
enum
mrb_timezone
timezone
)
mrb_time_make
(
mrb_state
*
mrb
,
struct
RClass
*
c
,
double
sec
,
double
usec
,
enum
mrb_timezone
timezone
)
{
{
return
mrb_time_wrap
(
mrb
,
c
,
mrb_time_alloc
(
mrb
,
sec
,
usec
,
timezone
));
return
mrb_time_wrap
(
mrb
,
c
,
time_alloc
(
mrb
,
sec
,
usec
,
timezone
));
}
/* Allocates a mrb_time object and initializes it. */
static
mrb_value
mrb_time_alloc
(
mrb_state
*
mrb
,
mrb_value
cv
)
{
return
mrb_time_make
(
mrb
,
mrb_class_ptr
(
cv
),
0
,
0
,
MRB_TIMEZONE_NONE
);
}
}
static
struct
mrb_time
*
static
struct
mrb_time
*
...
@@ -253,7 +260,7 @@ time_mktime(mrb_state *mrb, mrb_int ayear, mrb_int amonth, mrb_int aday,
...
@@ -253,7 +260,7 @@ time_mktime(mrb_state *mrb, mrb_int ayear, mrb_int amonth, mrb_int aday,
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"Not a valid time."
);
mrb_raise
(
mrb
,
E_ARGUMENT_ERROR
,
"Not a valid time."
);
}
}
return
mrb_
time_alloc
(
mrb
,
nowsecs
,
ausec
,
timezone
);
return
time_alloc
(
mrb
,
nowsecs
,
ausec
,
timezone
);
}
}
/* 15.2.19.6.2 */
/* 15.2.19.6.2 */
...
@@ -685,6 +692,7 @@ mrb_mruby_time_gem_init(mrb_state* mrb)
...
@@ -685,6 +692,7 @@ mrb_mruby_time_gem_init(mrb_state* mrb)
tc
=
mrb_define_class
(
mrb
,
"Time"
,
mrb
->
object_class
);
tc
=
mrb_define_class
(
mrb
,
"Time"
,
mrb
->
object_class
);
MRB_SET_INSTANCE_TT
(
tc
,
MRB_TT_DATA
);
MRB_SET_INSTANCE_TT
(
tc
,
MRB_TT_DATA
);
mrb_include_module
(
mrb
,
tc
,
mrb_class_get
(
mrb
,
"Comparable"
));
mrb_include_module
(
mrb
,
tc
,
mrb_class_get
(
mrb
,
"Comparable"
));
mrb_define_class_method
(
mrb
,
tc
,
"alloc"
,
mrb_time_alloc
,
MRB_ARGS_NONE
());
mrb_define_class_method
(
mrb
,
tc
,
"at"
,
mrb_time_at
,
MRB_ARGS_ANY
());
/* 15.2.19.6.1 */
mrb_define_class_method
(
mrb
,
tc
,
"at"
,
mrb_time_at
,
MRB_ARGS_ANY
());
/* 15.2.19.6.1 */
mrb_define_class_method
(
mrb
,
tc
,
"gm"
,
mrb_time_gm
,
MRB_ARGS_ARG
(
1
,
6
));
/* 15.2.19.6.2 */
mrb_define_class_method
(
mrb
,
tc
,
"gm"
,
mrb_time_gm
,
MRB_ARGS_ARG
(
1
,
6
));
/* 15.2.19.6.2 */
mrb_define_class_method
(
mrb
,
tc
,
"local"
,
mrb_time_local
,
MRB_ARGS_ARG
(
1
,
6
));
/* 15.2.19.6.3 */
mrb_define_class_method
(
mrb
,
tc
,
"local"
,
mrb_time_local
,
MRB_ARGS_ARG
(
1
,
6
));
/* 15.2.19.6.3 */
...
...
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