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
2bfb8882
Commit
2bfb8882
authored
Feb 23, 2013
by
Masaki Muranaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors caused by stdio.h dependent code.
parent
58b9e767
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
6 deletions
+36
-6
include/mruby/dump.h
include/mruby/dump.h
+10
-4
src/dump.c
src/dump.c
+4
-0
src/load.c
src/load.c
+22
-2
No files found.
include/mruby/dump.h
View file @
2bfb8882
...
@@ -12,16 +12,22 @@ extern "C" {
...
@@ -12,16 +12,22 @@ extern "C" {
#endif
#endif
#include "mruby.h"
#include "mruby.h"
#ifdef ENABLE_STDIO
#include <stdio.h>
#include <stdio.h>
#endif
#include <stdint.h>
#include <stdint.h>
#ifdef ENABLE_STDIO
int
mrb_dump_irep
(
mrb_state
*
,
int
,
FILE
*
);
int
mrb_dump_irep
(
mrb_state
*
,
int
,
FILE
*
);
int
mrb_read_irep
(
mrb_state
*
,
const
char
*
);
int
mrb_bdump_irep
(
mrb_state
*
mrb
,
int
n
,
FILE
*
f
,
const
char
*
initname
);
int
mrb_read_irep_file
(
mrb_state
*
,
FILE
*
);
int
mrb_read_irep_file
(
mrb_state
*
,
FILE
*
);
/* mrb_value mrb_load_irep(mrb_state*,const char*); */
/* declared in <irep.h> */
#endif
mrb_value
mrb_load_irep_file
(
mrb_state
*
,
FILE
*
);
int
mrb_read_irep
(
mrb_state
*
,
const
char
*
);
int
mrb_bdump_irep
(
mrb_state
*
mrb
,
int
n
,
FILE
*
f
,
const
char
*
initname
);
#ifdef ENABLE_STDIO
mrb_value
mrb_load_irep_file
(
mrb_state
*
,
FILE
*
);
#endif
/* dump type */
/* dump type */
#define DUMP_TYPE_CODE 0
#define DUMP_TYPE_CODE 0
...
...
src/dump.c
View file @
2bfb8882
...
@@ -50,6 +50,8 @@ enum {
...
@@ -50,6 +50,8 @@ enum {
DUMP_SECTION_NUM
,
DUMP_SECTION_NUM
,
};
};
#ifdef ENABLE_STDIO
uint16_t
calc_crc_16_ccitt
(
unsigned
char
*
,
int
);
uint16_t
calc_crc_16_ccitt
(
unsigned
char
*
,
int
);
static
inline
int
uint8_dump
(
uint8_t
,
char
*
,
int
);
static
inline
int
uint8_dump
(
uint8_t
,
char
*
,
int
);
static
inline
int
uint16_dump
(
uint16_t
,
char
*
,
int
);
static
inline
int
uint16_dump
(
uint16_t
,
char
*
,
int
);
...
@@ -742,3 +744,5 @@ mrb_bdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname)
...
@@ -742,3 +744,5 @@ mrb_bdump_irep(mrb_state *mrb, int n, FILE *f,const char *initname)
return
rc
;
return
rc
;
}
}
#endif
/* ENABLE_STDIO */
src/load.c
View file @
2bfb8882
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
#include "mruby/proc.h"
#include "mruby/proc.h"
#include "mruby/irep.h"
#include "mruby/irep.h"
#ifdef ENABLE_STDIO
typedef
struct
_RiteFILE
typedef
struct
_RiteFILE
{
{
FILE
*
fp
;
FILE
*
fp
;
...
@@ -18,6 +19,7 @@ typedef struct _RiteFILE
...
@@ -18,6 +19,7 @@ typedef struct _RiteFILE
int
cnt
;
int
cnt
;
int
readlen
;
int
readlen
;
}
RiteFILE
;
}
RiteFILE
;
#endif
const
char
hex2bin
[
256
]
=
{
const
char
hex2bin
[
256
]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//00-0f
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
//00-0f
...
@@ -38,15 +40,18 @@ static uint16_t hex_to_uint16(unsigned char*);
...
@@ -38,15 +40,18 @@ static uint16_t hex_to_uint16(unsigned char*);
static
uint32_t
hex_to_uint32
(
unsigned
char
*
);
static
uint32_t
hex_to_uint32
(
unsigned
char
*
);
static
char
*
hex_to_str
(
char
*
,
char
*
,
uint16_t
*
);
static
char
*
hex_to_str
(
char
*
,
char
*
,
uint16_t
*
);
uint16_t
calc_crc_16_ccitt
(
unsigned
char
*
,
int
);
uint16_t
calc_crc_16_ccitt
(
unsigned
char
*
,
int
);
#ifdef ENABLE_STDIO
static
unsigned
char
rite_fgetcSub
(
RiteFILE
*
);
static
unsigned
char
rite_fgetcSub
(
RiteFILE
*
);
static
unsigned
char
rite_fgetc
(
RiteFILE
*
,
int
);
static
unsigned
char
rite_fgetc
(
RiteFILE
*
,
int
);
static
unsigned
char
*
rite_fgets
(
RiteFILE
*
,
unsigned
char
*
,
int
,
int
);
static
unsigned
char
*
rite_fgets
(
RiteFILE
*
,
unsigned
char
*
,
int
,
int
);
static
int
load_rite_header
(
FILE
*
,
rite_binary_header
*
,
unsigned
char
*
);
static
int
load_rite_header
(
FILE
*
,
rite_binary_header
*
,
unsigned
char
*
);
static
int
load_rite_irep_record
(
mrb_state
*
,
RiteFILE
*
,
unsigned
char
*
,
uint32_t
*
);
static
int
load_rite_irep_record
(
mrb_state
*
,
RiteFILE
*
,
unsigned
char
*
,
uint32_t
*
);
#endif
static
int
read_rite_header
(
mrb_state
*
,
unsigned
char
*
,
rite_binary_header
*
);
static
int
read_rite_header
(
mrb_state
*
,
unsigned
char
*
,
rite_binary_header
*
);
static
int
read_rite_irep_record
(
mrb_state
*
,
unsigned
char
*
,
uint32_t
*
);
static
int
read_rite_irep_record
(
mrb_state
*
,
unsigned
char
*
,
uint32_t
*
);
#ifdef ENABLE_STDIO
static
unsigned
char
static
unsigned
char
rite_fgetcSub
(
RiteFILE
*
rfp
)
rite_fgetcSub
(
RiteFILE
*
rfp
)
{
{
...
@@ -65,7 +70,9 @@ rite_fgetcSub(RiteFILE* rfp)
...
@@ -65,7 +70,9 @@ rite_fgetcSub(RiteFILE* rfp)
}
}
return
rfp
->
buf
[(
rfp
->
cnt
)
++
];
return
rfp
->
buf
[(
rfp
->
cnt
)
++
];
}
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
static
unsigned
char
static
unsigned
char
rite_fgetc
(
RiteFILE
*
rfp
,
int
ignorecomment
)
rite_fgetc
(
RiteFILE
*
rfp
,
int
ignorecomment
)
{
{
...
@@ -87,7 +94,9 @@ rite_fgetc(RiteFILE* rfp, int ignorecomment)
...
@@ -87,7 +94,9 @@ rite_fgetc(RiteFILE* rfp, int ignorecomment)
}
}
}
}
}
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
static
unsigned
char
*
static
unsigned
char
*
rite_fgets
(
RiteFILE
*
rfp
,
unsigned
char
*
dst
,
int
len
,
int
ignorecomment
)
rite_fgets
(
RiteFILE
*
rfp
,
unsigned
char
*
dst
,
int
len
,
int
ignorecomment
)
{
{
...
@@ -100,7 +109,9 @@ rite_fgets(RiteFILE* rfp, unsigned char* dst, int len, int ignorecomment)
...
@@ -100,7 +109,9 @@ rite_fgets(RiteFILE* rfp, unsigned char* dst, int len, int ignorecomment)
}
}
return
dst
;
return
dst
;
}
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
static
int
static
int
load_rite_header
(
FILE
*
fp
,
rite_binary_header
*
bin_header
,
unsigned
char
*
hcrc
)
load_rite_header
(
FILE
*
fp
,
rite_binary_header
*
bin_header
,
unsigned
char
*
hcrc
)
{
{
...
@@ -128,7 +139,9 @@ load_rite_header(FILE* fp, rite_binary_header* bin_header, unsigned char* hcrc)
...
@@ -128,7 +139,9 @@ load_rite_header(FILE* fp, rite_binary_header* bin_header, unsigned char* hcrc)
return
MRB_DUMP_OK
;
return
MRB_DUMP_OK
;
}
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
static
int
static
int
load_rite_irep_record
(
mrb_state
*
mrb
,
RiteFILE
*
rfp
,
unsigned
char
*
dst
,
uint32_t
*
len
)
load_rite_irep_record
(
mrb_state
*
mrb
,
RiteFILE
*
rfp
,
unsigned
char
*
dst
,
uint32_t
*
len
)
{
{
...
@@ -152,8 +165,10 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
...
@@ -152,8 +165,10 @@ load_rite_irep_record(mrb_state *mrb, RiteFILE* rfp, unsigned char* dst, uint32_
//IREP HEADER BLOCK
//IREP HEADER BLOCK
*
dst
=
rite_fgetc
(
rfp
,
TRUE
);
//record identifier
*
dst
=
rite_fgetc
(
rfp
,
TRUE
);
//record identifier
if
(
*
dst
!=
RITE_IREP_IDENFIFIER
)
if
(
*
dst
!=
RITE_IREP_IDENFIFIER
)
{
return
MRB_DUMP_INVALID_IREP
;
result
=
MRB_DUMP_INVALID_IREP
;
goto
error_exit
;
}
dst
+=
sizeof
(
unsigned
char
);
dst
+=
sizeof
(
unsigned
char
);
*
dst
=
rite_fgetc
(
rfp
,
TRUE
);
//class or module
*
dst
=
rite_fgetc
(
rfp
,
TRUE
);
//class or module
dst
+=
sizeof
(
unsigned
char
);
dst
+=
sizeof
(
unsigned
char
);
...
@@ -247,7 +262,9 @@ error_exit:
...
@@ -247,7 +262,9 @@ error_exit:
return
result
;
return
result
;
}
}
#endif
/* ENABLE_STDIO */
#ifdef ENABLE_STDIO
int
int
mrb_read_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
mrb_read_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
{
...
@@ -306,6 +323,7 @@ error_exit:
...
@@ -306,6 +323,7 @@ error_exit:
return
ret
;
return
ret
;
}
}
#endif
/* ENABLE_STDIO */
static
int
static
int
read_rite_header
(
mrb_state
*
mrb
,
unsigned
char
*
bin
,
rite_binary_header
*
bin_header
)
read_rite_header
(
mrb_state
*
mrb
,
unsigned
char
*
bin
,
rite_binary_header
*
bin_header
)
...
@@ -668,6 +686,7 @@ irep_error(mrb_state *mrb, int n)
...
@@ -668,6 +686,7 @@ irep_error(mrb_state *mrb, int n)
mrb
->
exc
=
(
struct
RObject
*
)
mrb_object
(
mrb_exc_new
(
mrb
,
E_SCRIPT_ERROR
,
msg
,
sizeof
(
msg
)
-
1
));
mrb
->
exc
=
(
struct
RObject
*
)
mrb_object
(
mrb_exc_new
(
mrb
,
E_SCRIPT_ERROR
,
msg
,
sizeof
(
msg
)
-
1
));
}
}
#ifdef ENABLE_STDIO
mrb_value
mrb_value
mrb_load_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
mrb_load_irep_file
(
mrb_state
*
mrb
,
FILE
*
fp
)
{
{
...
@@ -679,6 +698,7 @@ mrb_load_irep_file(mrb_state *mrb, FILE* fp)
...
@@ -679,6 +698,7 @@ mrb_load_irep_file(mrb_state *mrb, FILE* fp)
}
}
return
mrb_run
(
mrb
,
mrb_proc_new
(
mrb
,
mrb
->
irep
[
n
]),
mrb_top_self
(
mrb
));
return
mrb_run
(
mrb
,
mrb_proc_new
(
mrb
,
mrb
->
irep
[
n
]),
mrb_top_self
(
mrb
));
}
}
#endif
mrb_value
mrb_value
mrb_load_irep
(
mrb_state
*
mrb
,
const
char
*
bin
)
mrb_load_irep
(
mrb_state
*
mrb
,
const
char
*
bin
)
...
...
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