remove pic_ prefix from pic_*_ptr family
This commit is contained in:
parent
7f430e000b
commit
16dafdd032
|
@ -22,10 +22,11 @@ pic_blob_value(pic_state *pic, const unsigned char *buf, int len)
|
||||||
unsigned char *
|
unsigned char *
|
||||||
pic_blob(pic_state *pic, pic_value blob, int *len)
|
pic_blob(pic_state *pic, pic_value blob, int *len)
|
||||||
{
|
{
|
||||||
|
struct blob *bv = blob_ptr(pic, blob);
|
||||||
if (len) {
|
if (len) {
|
||||||
*len = pic_blob_ptr(pic, blob)->len;
|
*len = bv->len;
|
||||||
}
|
}
|
||||||
return pic_blob_ptr(pic, blob)->data;
|
return bv->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
|
|
@ -11,13 +11,13 @@ pic_data_p(pic_state *pic, pic_value obj, const pic_data_type *type)
|
||||||
if (pic_type(pic, obj) != PIC_TYPE_DATA) {
|
if (pic_type(pic, obj) != PIC_TYPE_DATA) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return type == NULL || pic_data_ptr(pic, obj)->type == type;
|
return type == NULL || data_ptr(pic, obj)->type == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
pic_data(pic_state *PIC_UNUSED(pic), pic_value data)
|
pic_data(pic_state *PIC_UNUSED(pic), pic_value data)
|
||||||
{
|
{
|
||||||
return pic_data_ptr(pic, data)->data;
|
return data_ptr(pic, data)->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
|
|
|
@ -45,7 +45,7 @@ pic_print_error(pic_state *pic, pic_value port, pic_value err)
|
||||||
struct error *e;
|
struct error *e;
|
||||||
pic_value elem, it;
|
pic_value elem, it;
|
||||||
|
|
||||||
e = pic_error_ptr(pic, err);
|
e = error_ptr(pic, err);
|
||||||
if (! pic_eq_p(pic, obj_value(pic, e->type), pic_intern_lit(pic, ""))) {
|
if (! pic_eq_p(pic, obj_value(pic, e->type), pic_intern_lit(pic, ""))) {
|
||||||
pic_fprintf(pic, port, "~s-", obj_value(pic, e->type));
|
pic_fprintf(pic, port, "~s-", obj_value(pic, e->type));
|
||||||
}
|
}
|
||||||
|
|
20
lib/dict.c
20
lib/dict.c
|
@ -20,10 +20,10 @@ pic_make_dict(pic_state *pic)
|
||||||
pic_value
|
pic_value
|
||||||
pic_dict_ref(pic_state *pic, pic_value dict, pic_value key)
|
pic_dict_ref(pic_state *pic, pic_value dict, pic_value key)
|
||||||
{
|
{
|
||||||
khash_t(dict) *h = &pic_dict_ptr(pic, dict)->hash;
|
khash_t(dict) *h = &dict_ptr(pic, dict)->hash;
|
||||||
int it;
|
int it;
|
||||||
|
|
||||||
it = kh_get(dict, h, pic_sym_ptr(pic, key));
|
it = kh_get(dict, h, sym_ptr(pic, key));
|
||||||
if (it == kh_end(h)) {
|
if (it == kh_end(h)) {
|
||||||
pic_error(pic, "element not found for given key", 1, key);
|
pic_error(pic, "element not found for given key", 1, key);
|
||||||
}
|
}
|
||||||
|
@ -33,35 +33,35 @@ pic_dict_ref(pic_state *pic, pic_value dict, pic_value key)
|
||||||
void
|
void
|
||||||
pic_dict_set(pic_state *pic, pic_value dict, pic_value key, pic_value val)
|
pic_dict_set(pic_state *pic, pic_value dict, pic_value key, pic_value val)
|
||||||
{
|
{
|
||||||
khash_t(dict) *h = &pic_dict_ptr(pic, dict)->hash;
|
khash_t(dict) *h = &dict_ptr(pic, dict)->hash;
|
||||||
int ret;
|
int ret;
|
||||||
int it;
|
int it;
|
||||||
|
|
||||||
it = kh_put(dict, h, pic_sym_ptr(pic, key), &ret);
|
it = kh_put(dict, h, sym_ptr(pic, key), &ret);
|
||||||
kh_val(h, it) = val;
|
kh_val(h, it) = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pic_dict_size(pic_state *PIC_UNUSED(pic), pic_value dict)
|
pic_dict_size(pic_state *PIC_UNUSED(pic), pic_value dict)
|
||||||
{
|
{
|
||||||
return kh_size(&pic_dict_ptr(pic, dict)->hash);
|
return kh_size(&dict_ptr(pic, dict)->hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pic_dict_has(pic_state *pic, pic_value dict, pic_value key)
|
pic_dict_has(pic_state *pic, pic_value dict, pic_value key)
|
||||||
{
|
{
|
||||||
khash_t(dict) *h = &pic_dict_ptr(pic, dict)->hash;
|
khash_t(dict) *h = &dict_ptr(pic, dict)->hash;
|
||||||
|
|
||||||
return kh_get(dict, h, pic_sym_ptr(pic, key)) != kh_end(h);
|
return kh_get(dict, h, sym_ptr(pic, key)) != kh_end(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_dict_del(pic_state *pic, pic_value dict, pic_value key)
|
pic_dict_del(pic_state *pic, pic_value dict, pic_value key)
|
||||||
{
|
{
|
||||||
khash_t(dict) *h = &pic_dict_ptr(pic, dict)->hash;
|
khash_t(dict) *h = &dict_ptr(pic, dict)->hash;
|
||||||
int it;
|
int it;
|
||||||
|
|
||||||
it = kh_get(dict, h, pic_sym_ptr(pic, key));
|
it = kh_get(dict, h, sym_ptr(pic, key));
|
||||||
if (it == kh_end(h)) {
|
if (it == kh_end(h)) {
|
||||||
pic_error(pic, "element not found for given key", 1, key);
|
pic_error(pic, "element not found for given key", 1, key);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ pic_dict_del(pic_state *pic, pic_value dict, pic_value key)
|
||||||
bool
|
bool
|
||||||
pic_dict_next(pic_state *PIC_UNUSED(pic), pic_value dict, int *iter, pic_value *key, pic_value *val)
|
pic_dict_next(pic_state *PIC_UNUSED(pic), pic_value dict, int *iter, pic_value *key, pic_value *val)
|
||||||
{
|
{
|
||||||
khash_t(dict) *h = &pic_dict_ptr(pic, dict)->hash;
|
khash_t(dict) *h = &dict_ptr(pic, dict)->hash;
|
||||||
int it = *iter;
|
int it = *iter;
|
||||||
|
|
||||||
for (it = *iter; it != kh_end(h); ++it) {
|
for (it = *iter; it != kh_end(h); ++it) {
|
||||||
|
|
12
lib/error.c
12
lib/error.c
|
@ -88,10 +88,10 @@ pic_make_error(pic_state *pic, const char *type, const char *msg, pic_value irrs
|
||||||
stack = pic_get_backtrace(pic);
|
stack = pic_get_backtrace(pic);
|
||||||
|
|
||||||
e = (struct error *)pic_obj_alloc(pic, sizeof(struct error), PIC_TYPE_ERROR);
|
e = (struct error *)pic_obj_alloc(pic, sizeof(struct error), PIC_TYPE_ERROR);
|
||||||
e->type = pic_sym_ptr(pic, ty);
|
e->type = sym_ptr(pic, ty);
|
||||||
e->msg = pic_str_ptr(pic, pic_cstr_value(pic, msg));
|
e->msg = str_ptr(pic, pic_cstr_value(pic, msg));
|
||||||
e->irrs = irrs;
|
e->irrs = irrs;
|
||||||
e->stack = pic_str_ptr(pic, stack);
|
e->stack = str_ptr(pic, stack);
|
||||||
|
|
||||||
return obj_value(pic, e);
|
return obj_value(pic, e);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ pic_error_error_object_message(pic_state *pic)
|
||||||
|
|
||||||
TYPE_CHECK(pic, e, error);
|
TYPE_CHECK(pic, e, error);
|
||||||
|
|
||||||
return obj_value(pic, pic_error_ptr(pic, e)->msg);
|
return obj_value(pic, error_ptr(pic, e)->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -240,7 +240,7 @@ pic_error_error_object_irritants(pic_state *pic)
|
||||||
|
|
||||||
TYPE_CHECK(pic, e, error);
|
TYPE_CHECK(pic, e, error);
|
||||||
|
|
||||||
return pic_error_ptr(pic, e)->irrs;
|
return error_ptr(pic, e)->irrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -252,7 +252,7 @@ pic_error_error_object_type(pic_state *pic)
|
||||||
|
|
||||||
TYPE_CHECK(pic, e, error);
|
TYPE_CHECK(pic, e, error);
|
||||||
|
|
||||||
return obj_value(pic, pic_error_ptr(pic, e)->type);
|
return obj_value(pic, error_ptr(pic, e)->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -535,7 +535,7 @@ index_global(pic_state *pic, codegen_context *cxt, pic_value name)
|
||||||
|
|
||||||
check_pool_size(pic, cxt);
|
check_pool_size(pic, cxt);
|
||||||
pidx = (int)cxt->plen++;
|
pidx = (int)cxt->plen++;
|
||||||
cxt->pool[pidx] = (struct object *)pic_sym_ptr(pic, name);
|
cxt->pool[pidx] = (struct object *)sym_ptr(pic, name);
|
||||||
|
|
||||||
return pidx;
|
return pidx;
|
||||||
}
|
}
|
||||||
|
|
|
@ -531,8 +531,8 @@ read_label_set(pic_state *pic, pic_value port, int i, struct reader_control *p)
|
||||||
kh_val(h, it) = val = pic_cons(pic, pic_undef_value(pic), pic_undef_value(pic));
|
kh_val(h, it) = val = pic_cons(pic, pic_undef_value(pic), pic_undef_value(pic));
|
||||||
|
|
||||||
tmp = read_value(pic, port, c, p);
|
tmp = read_value(pic, port, c, p);
|
||||||
pic_pair_ptr(pic, val)->car = pic_car(pic, tmp);
|
pair_ptr(pic, val)->car = pic_car(pic, tmp);
|
||||||
pic_pair_ptr(pic, val)->cdr = pic_cdr(pic, tmp);
|
pair_ptr(pic, val)->cdr = pic_cdr(pic, tmp);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
@ -552,8 +552,8 @@ read_label_set(pic_state *pic, pic_value port, int i, struct reader_control *p)
|
||||||
kh_val(h, it) = val = pic_make_vec(pic, 0, NULL);
|
kh_val(h, it) = val = pic_make_vec(pic, 0, NULL);
|
||||||
|
|
||||||
tmp = read_value(pic, port, c, p);
|
tmp = read_value(pic, port, c, p);
|
||||||
PIC_SWAP(pic_value *, pic_vec_ptr(pic, tmp)->data, pic_vec_ptr(pic, val)->data);
|
PIC_SWAP(pic_value *, vec_ptr(pic, tmp)->data, vec_ptr(pic, val)->data);
|
||||||
PIC_SWAP(int, pic_vec_ptr(pic, tmp)->len, pic_vec_ptr(pic, val)->len);
|
PIC_SWAP(int, vec_ptr(pic, tmp)->len, vec_ptr(pic, val)->len);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
10
lib/object.h
10
lib/object.h
|
@ -233,11 +233,11 @@ obj_value(pic_state *PIC_UNUSED(pic), void *ptr)
|
||||||
|
|
||||||
#endif /* NAN_BOXING */
|
#endif /* NAN_BOXING */
|
||||||
|
|
||||||
#define DEFPTR(name,type) \
|
#define DEFPTR(name,type) \
|
||||||
PIC_STATIC_INLINE type * \
|
PIC_STATIC_INLINE type * \
|
||||||
pic_##name##_ptr(pic_state *PIC_UNUSED(pic), pic_value o) { \
|
name##_ptr(pic_state *PIC_UNUSED(pic), pic_value o) { \
|
||||||
assert(pic_##name##_p(pic,o)); \
|
assert(pic_##name##_p(pic,o)); \
|
||||||
return (type *) obj_ptr(pic, o); \
|
return (type *) obj_ptr(pic, o); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define pic_data_p(pic,o) (pic_data_p(pic,o,NULL))
|
#define pic_data_p(pic,o) (pic_data_p(pic,o,NULL))
|
||||||
|
|
14
lib/pair.c
14
lib/pair.c
|
@ -23,7 +23,7 @@ pic_car(pic_state *pic, pic_value obj)
|
||||||
if (! pic_pair_p(pic, obj)) {
|
if (! pic_pair_p(pic, obj)) {
|
||||||
pic_error(pic, "car: pair required", 1, obj);
|
pic_error(pic, "car: pair required", 1, obj);
|
||||||
}
|
}
|
||||||
return pic_pair_ptr(pic, obj)->car;
|
return pair_ptr(pic, obj)->car;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
|
@ -32,7 +32,7 @@ pic_cdr(pic_state *pic, pic_value obj)
|
||||||
if (! pic_pair_p(pic, obj)) {
|
if (! pic_pair_p(pic, obj)) {
|
||||||
pic_error(pic, "cdr: pair required", 1, obj);
|
pic_error(pic, "cdr: pair required", 1, obj);
|
||||||
}
|
}
|
||||||
return pic_pair_ptr(pic, obj)->cdr;
|
return pair_ptr(pic, obj)->cdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -41,7 +41,7 @@ pic_set_car(pic_state *pic, pic_value obj, pic_value val)
|
||||||
if (! pic_pair_p(pic, obj)) {
|
if (! pic_pair_p(pic, obj)) {
|
||||||
pic_error(pic, "pair required", 0);
|
pic_error(pic, "pair required", 0);
|
||||||
}
|
}
|
||||||
pic_pair_ptr(pic, obj)->car = val;
|
pair_ptr(pic, obj)->car = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -50,7 +50,7 @@ pic_set_cdr(pic_state *pic, pic_value obj, pic_value val)
|
||||||
if (! pic_pair_p(pic, obj)) {
|
if (! pic_pair_p(pic, obj)) {
|
||||||
pic_error(pic, "pair required", 0);
|
pic_error(pic, "pair required", 0);
|
||||||
}
|
}
|
||||||
pic_pair_ptr(pic, obj)->cdr = val;
|
pair_ptr(pic, obj)->cdr = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
|
@ -91,7 +91,7 @@ pic_list_p(pic_state *pic, pic_value obj)
|
||||||
/* advance rapid fast-forward; runs 2x faster than local */
|
/* advance rapid fast-forward; runs 2x faster than local */
|
||||||
for (i = 0; i < 2; ++i) {
|
for (i = 0; i < 2; ++i) {
|
||||||
if (pic_pair_p(pic, rapid)) {
|
if (pic_pair_p(pic, rapid)) {
|
||||||
rapid = pic_pair_ptr(pic, rapid)->cdr;
|
rapid = pair_ptr(pic, rapid)->cdr;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return pic_nil_p(pic, rapid);
|
return pic_nil_p(pic, rapid);
|
||||||
|
@ -99,7 +99,7 @@ pic_list_p(pic_state *pic, pic_value obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* advance local */
|
/* advance local */
|
||||||
local = pic_pair_ptr(pic, local)->cdr;
|
local = pair_ptr(pic, local)->cdr;
|
||||||
|
|
||||||
if (pic_eq_p(pic, local, rapid)) {
|
if (pic_eq_p(pic, local, rapid)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -153,7 +153,7 @@ pic_list_ref(pic_state *pic, pic_value list, int i)
|
||||||
void
|
void
|
||||||
pic_list_set(pic_state *pic, pic_value list, int i, pic_value obj)
|
pic_list_set(pic_state *pic, pic_value list, int i, pic_value obj)
|
||||||
{
|
{
|
||||||
pic_pair_ptr(pic, pic_list_tail(pic, list, i))->car = obj;
|
pair_ptr(pic, pic_list_tail(pic, list, i))->car = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
|
|
38
lib/port.c
38
lib/port.c
|
@ -16,7 +16,7 @@ pic_port_p(pic_state *pic, pic_value obj, const pic_port_type *type)
|
||||||
if (pic_type(pic, obj) != PIC_TYPE_PORT) {
|
if (pic_type(pic, obj) != PIC_TYPE_PORT) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return type == NULL || pic_port_ptr(pic, obj)->file.vtable == type;
|
return type == NULL || port_ptr(pic, obj)->file.vtable == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
|
@ -37,7 +37,7 @@ pic_funopen(pic_state *pic, void *cookie, const pic_port_type *type)
|
||||||
int
|
int
|
||||||
pic_fclose(pic_state *pic, pic_value port)
|
pic_fclose(pic_state *pic, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
|
|
||||||
if (fp->flag == 0)
|
if (fp->flag == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -51,7 +51,7 @@ pic_fclose(pic_state *pic, pic_value port)
|
||||||
void
|
void
|
||||||
pic_clearerr(pic_state *PIC_UNUSED(pic), pic_value port)
|
pic_clearerr(pic_state *PIC_UNUSED(pic), pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
|
|
||||||
fp->flag &= ~(FILE_EOF | FILE_ERR);
|
fp->flag &= ~(FILE_EOF | FILE_ERR);
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ pic_clearerr(pic_state *PIC_UNUSED(pic), pic_value port)
|
||||||
int
|
int
|
||||||
pic_feof(pic_state *PIC_UNUSED(pic), pic_value port)
|
pic_feof(pic_state *PIC_UNUSED(pic), pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
|
|
||||||
return (fp->flag & FILE_EOF) != 0;
|
return (fp->flag & FILE_EOF) != 0;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ pic_feof(pic_state *PIC_UNUSED(pic), pic_value port)
|
||||||
int
|
int
|
||||||
pic_ferror(pic_state *PIC_UNUSED(pic), pic_value port)
|
pic_ferror(pic_state *PIC_UNUSED(pic), pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
|
|
||||||
return (fp->flag & FILE_ERR) != 0;
|
return (fp->flag & FILE_ERR) != 0;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ flushbuf(pic_state *pic, int x, struct file *fp)
|
||||||
int
|
int
|
||||||
pic_fflush(pic_state *pic, pic_value port)
|
pic_fflush(pic_state *pic, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = 0;
|
retval = 0;
|
||||||
|
@ -188,7 +188,7 @@ pic_fflush(pic_state *pic, pic_value port)
|
||||||
int
|
int
|
||||||
pic_fputc(pic_state *pic, int x, pic_value port)
|
pic_fputc(pic_state *pic, int x, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
|
|
||||||
return putc_(pic, x, fp);
|
return putc_(pic, x, fp);
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ pic_fputc(pic_state *pic, int x, pic_value port)
|
||||||
int
|
int
|
||||||
pic_fgetc(pic_state *pic, pic_value port)
|
pic_fgetc(pic_state *pic, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
|
|
||||||
return getc_(pic, fp);
|
return getc_(pic, fp);
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ pic_fgetc(pic_state *pic, pic_value port)
|
||||||
int
|
int
|
||||||
pic_fputs(pic_state *pic, const char *s, pic_value port)
|
pic_fputs(pic_state *pic, const char *s, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
|
|
||||||
const char *ptr = s;
|
const char *ptr = s;
|
||||||
while(*ptr != '\0') {
|
while(*ptr != '\0') {
|
||||||
|
@ -218,7 +218,7 @@ pic_fputs(pic_state *pic, const char *s, pic_value port)
|
||||||
char *
|
char *
|
||||||
pic_fgets(pic_state *pic, char *s, int size, pic_value port)
|
pic_fgets(pic_state *pic, char *s, int size, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ pic_fgets(pic_state *pic, char *s, int size, pic_value port)
|
||||||
int
|
int
|
||||||
pic_ungetc(pic_state *PIC_UNUSED(pic), int c, pic_value port)
|
pic_ungetc(pic_state *PIC_UNUSED(pic), int c, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
unsigned char uc = c;
|
unsigned char uc = c;
|
||||||
|
|
||||||
if (c == EOF || fp->base == fp->ptr) {
|
if (c == EOF || fp->base == fp->ptr) {
|
||||||
|
@ -253,7 +253,7 @@ pic_ungetc(pic_state *PIC_UNUSED(pic), int c, pic_value port)
|
||||||
size_t
|
size_t
|
||||||
pic_fread(pic_state *pic, void *ptr, size_t size, size_t count, pic_value port)
|
pic_fread(pic_state *pic, void *ptr, size_t size, size_t count, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
char *bptr = ptr;
|
char *bptr = ptr;
|
||||||
long nbytes;
|
long nbytes;
|
||||||
int c;
|
int c;
|
||||||
|
@ -279,7 +279,7 @@ pic_fread(pic_state *pic, void *ptr, size_t size, size_t count, pic_value port)
|
||||||
size_t
|
size_t
|
||||||
pic_fwrite(pic_state *pic, const void *ptr, size_t size, size_t count, pic_value port)
|
pic_fwrite(pic_state *pic, const void *ptr, size_t size, size_t count, pic_value port)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
const char *bptr = ptr;
|
const char *bptr = ptr;
|
||||||
long nbytes;
|
long nbytes;
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ pic_fwrite(pic_state *pic, const void *ptr, size_t size, size_t count, pic_value
|
||||||
long
|
long
|
||||||
pic_fseek(pic_state *pic, pic_value port, long offset, int whence)
|
pic_fseek(pic_state *pic, pic_value port, long offset, int whence)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
long s;
|
long s;
|
||||||
|
|
||||||
pic_fflush(pic, port);
|
pic_fflush(pic, port);
|
||||||
|
@ -520,7 +520,7 @@ pic_fmemopen(pic_state *pic, const char *data, int size, const char *mode)
|
||||||
int
|
int
|
||||||
pic_fgetbuf(pic_state *pic, pic_value port, const char **buf, int *len)
|
pic_fgetbuf(pic_state *pic, pic_value port, const char **buf, int *len)
|
||||||
{
|
{
|
||||||
struct file *fp = &pic_port_ptr(pic, port)->file;
|
struct file *fp = &port_ptr(pic, port)->file;
|
||||||
xbuf_t *s;
|
xbuf_t *s;
|
||||||
|
|
||||||
pic_fflush(pic, port);
|
pic_fflush(pic, port);
|
||||||
|
@ -541,7 +541,7 @@ pic_port_input_port_p(pic_state *pic)
|
||||||
|
|
||||||
pic_get_args(pic, "o", &v);
|
pic_get_args(pic, "o", &v);
|
||||||
|
|
||||||
if (pic_port_p(pic, v, NULL) && (pic_port_ptr(pic, v)->file.flag & FILE_READ) != 0) {
|
if (pic_port_p(pic, v, NULL) && (port_ptr(pic, v)->file.flag & FILE_READ) != 0) {
|
||||||
return pic_true_value(pic);
|
return pic_true_value(pic);
|
||||||
} else {
|
} else {
|
||||||
return pic_false_value(pic);
|
return pic_false_value(pic);
|
||||||
|
@ -555,7 +555,7 @@ pic_port_output_port_p(pic_state *pic)
|
||||||
|
|
||||||
pic_get_args(pic, "o", &v);
|
pic_get_args(pic, "o", &v);
|
||||||
|
|
||||||
if (pic_port_p(pic, v, NULL) && (pic_port_ptr(pic, v)->file.flag & FILE_WRITE) != 0) {
|
if (pic_port_p(pic, v, NULL) && (port_ptr(pic, v)->file.flag & FILE_WRITE) != 0) {
|
||||||
return pic_true_value(pic);
|
return pic_true_value(pic);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -598,7 +598,7 @@ pic_port_port_open_p(pic_state *pic)
|
||||||
|
|
||||||
pic_get_args(pic, "p", &port);
|
pic_get_args(pic, "p", &port);
|
||||||
|
|
||||||
return pic_bool_value(pic, pic_port_ptr(pic, port)->file.flag != 0);
|
return pic_bool_value(pic, port_ptr(pic, port)->file.flag != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -614,7 +614,7 @@ pic_port_close_port(pic_state *pic)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define assert_port_profile(port, flags, caller) do { \
|
#define assert_port_profile(port, flags, caller) do { \
|
||||||
int flag = pic_port_ptr(pic, port)->file.flag; \
|
int flag = port_ptr(pic, port)->file.flag; \
|
||||||
if ((flag & (flags)) != (flags)) { \
|
if ((flag & (flags)) != (flags)) { \
|
||||||
switch (flags) { \
|
switch (flags) { \
|
||||||
case FILE_WRITE: \
|
case FILE_WRITE: \
|
||||||
|
|
10
lib/proc.c
10
lib/proc.c
|
@ -268,10 +268,10 @@ pic_closure_ref(pic_state *pic, int n)
|
||||||
{
|
{
|
||||||
pic_value self = GET_PROC(pic);
|
pic_value self = GET_PROC(pic);
|
||||||
|
|
||||||
if (n < 0 || pic_proc_ptr(pic, self)->u.f.localc <= n) {
|
if (n < 0 || proc_ptr(pic, self)->u.f.localc <= n) {
|
||||||
pic_error(pic, "pic_closure_ref: index out of range", 1, pic_int_value(pic, n));
|
pic_error(pic, "pic_closure_ref: index out of range", 1, pic_int_value(pic, n));
|
||||||
}
|
}
|
||||||
return pic_proc_ptr(pic, self)->locals[n];
|
return proc_ptr(pic, self)->locals[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -279,10 +279,10 @@ pic_closure_set(pic_state *pic, int n, pic_value v)
|
||||||
{
|
{
|
||||||
pic_value self = GET_PROC(pic);
|
pic_value self = GET_PROC(pic);
|
||||||
|
|
||||||
if (n < 0 || pic_proc_ptr(pic, self)->u.f.localc <= n) {
|
if (n < 0 || proc_ptr(pic, self)->u.f.localc <= n) {
|
||||||
pic_error(pic, "pic_closure_ref: index out of range", 1, pic_int_value(pic, n));
|
pic_error(pic, "pic_closure_ref: index out of range", 1, pic_int_value(pic, n));
|
||||||
}
|
}
|
||||||
pic_proc_ptr(pic, self)->locals[n] = v;
|
proc_ptr(pic, self)->locals[n] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -525,7 +525,7 @@ pic_apply(pic_state *pic, pic_value proc, int argc, pic_value *argv)
|
||||||
if (! pic_proc_p(pic, x)) {
|
if (! pic_proc_p(pic, x)) {
|
||||||
pic_error(pic, "invalid application", 1, x);
|
pic_error(pic, "invalid application", 1, x);
|
||||||
}
|
}
|
||||||
proc = pic_proc_ptr(pic, x);
|
proc = proc_ptr(pic, x);
|
||||||
|
|
||||||
if (pic->sp >= pic->stend) {
|
if (pic->sp >= pic->stend) {
|
||||||
pic_panic(pic, "VM stack overflow");
|
pic_panic(pic, "VM stack overflow");
|
||||||
|
|
|
@ -20,13 +20,13 @@ pic_make_record(pic_state *pic, pic_value type, pic_value datum)
|
||||||
pic_value
|
pic_value
|
||||||
pic_record_type(pic_state *pic, pic_value rec)
|
pic_record_type(pic_state *pic, pic_value rec)
|
||||||
{
|
{
|
||||||
return pic_rec_ptr(pic, rec)->type;
|
return rec_ptr(pic, rec)->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_record_datum(pic_state *pic, pic_value rec)
|
pic_record_datum(pic_state *pic, pic_value rec)
|
||||||
{
|
{
|
||||||
return pic_rec_ptr(pic, rec)->datum;
|
return rec_ptr(pic, rec)->datum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
|
14
lib/string.c
14
lib/string.c
|
@ -192,9 +192,9 @@ flatten(pic_state *pic, struct rope *rope, struct rope *owner, char *buf)
|
||||||
static void
|
static void
|
||||||
str_update(pic_state *pic, pic_value dst, pic_value src)
|
str_update(pic_state *pic, pic_value dst, pic_value src)
|
||||||
{
|
{
|
||||||
pic_rope_incref(pic_str_ptr(pic, src)->rope);
|
pic_rope_incref(str_ptr(pic, src)->rope);
|
||||||
pic_rope_decref(pic, pic_str_ptr(pic, dst)->rope);
|
pic_rope_decref(pic, str_ptr(pic, dst)->rope);
|
||||||
pic_str_ptr(pic, dst)->rope = pic_str_ptr(pic, src)->rope;
|
str_ptr(pic, dst)->rope = str_ptr(pic, src)->rope;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
|
@ -251,25 +251,25 @@ pic_vstrf_value(pic_state *pic, const char *fmt, va_list ap)
|
||||||
int
|
int
|
||||||
pic_str_len(pic_state *PIC_UNUSED(pic), pic_value str)
|
pic_str_len(pic_state *PIC_UNUSED(pic), pic_value str)
|
||||||
{
|
{
|
||||||
return pic_str_ptr(pic, str)->rope->weight;
|
return str_ptr(pic, str)->rope->weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_str_cat(pic_state *pic, pic_value a, pic_value b)
|
pic_str_cat(pic_state *pic, pic_value a, pic_value b)
|
||||||
{
|
{
|
||||||
return make_str(pic, merge(pic, pic_str_ptr(pic, a)->rope, pic_str_ptr(pic, b)->rope));
|
return make_str(pic, merge(pic, str_ptr(pic, a)->rope, str_ptr(pic, b)->rope));
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_str_sub(pic_state *pic, pic_value str, int s, int e)
|
pic_str_sub(pic_state *pic, pic_value str, int s, int e)
|
||||||
{
|
{
|
||||||
return make_str(pic, slice(pic, pic_str_ptr(pic, str)->rope, s, e));
|
return make_str(pic, slice(pic, str_ptr(pic, str)->rope, s, e));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
pic_str(pic_state *pic, pic_value str, int *len)
|
pic_str(pic_state *pic, pic_value str, int *len)
|
||||||
{
|
{
|
||||||
struct rope *rope = pic_str_ptr(pic, str)->rope, *r;
|
struct rope *rope = str_ptr(pic, str)->rope, *r;
|
||||||
|
|
||||||
if (len) {
|
if (len) {
|
||||||
*len = rope->weight;
|
*len = rope->weight;
|
||||||
|
|
|
@ -20,7 +20,7 @@ pic_intern(pic_state *pic, pic_value str)
|
||||||
int it;
|
int it;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
it = kh_put(oblist, h, pic_str_ptr(pic, str), &ret);
|
it = kh_put(oblist, h, str_ptr(pic, str), &ret);
|
||||||
if (ret == 0) { /* if exists */
|
if (ret == 0) { /* if exists */
|
||||||
sym = kh_val(h, it);
|
sym = kh_val(h, it);
|
||||||
pic_protect(pic, obj_value(pic, sym));
|
pic_protect(pic, obj_value(pic, sym));
|
||||||
|
@ -30,16 +30,16 @@ pic_intern(pic_state *pic, pic_value str)
|
||||||
kh_val(h, it) = NULL; /* dummy */
|
kh_val(h, it) = NULL; /* dummy */
|
||||||
|
|
||||||
sym = (struct symbol *)pic_obj_alloc(pic, sizeof(struct symbol), PIC_TYPE_SYMBOL);
|
sym = (struct symbol *)pic_obj_alloc(pic, sizeof(struct symbol), PIC_TYPE_SYMBOL);
|
||||||
sym->str = pic_str_ptr(pic, str);
|
sym->str = str_ptr(pic, str);
|
||||||
kh_val(h, it) = sym;
|
kh_val(h, it) = sym;
|
||||||
|
|
||||||
return obj_value(pic, sym);
|
return obj_value(pic, sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
pic_value
|
pic_value
|
||||||
pic_sym_name(pic_state *PIC_UNUSED(pic), pic_value sym)
|
pic_sym_name(pic_state *pic, pic_value sym)
|
||||||
{
|
{
|
||||||
return obj_value(pic, pic_sym_ptr(pic, sym)->str);
|
return obj_value(pic, sym_ptr(pic, sym)->str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
|
12
lib/vector.c
12
lib/vector.c
|
@ -27,19 +27,19 @@ pic_make_vec(pic_state *pic, int len, pic_value *argv)
|
||||||
pic_value
|
pic_value
|
||||||
pic_vec_ref(pic_state *PIC_UNUSED(pic), pic_value vec, int k)
|
pic_vec_ref(pic_state *PIC_UNUSED(pic), pic_value vec, int k)
|
||||||
{
|
{
|
||||||
return pic_vec_ptr(pic, vec)->data[k];
|
return vec_ptr(pic, vec)->data[k];
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pic_vec_set(pic_state *PIC_UNUSED(pic), pic_value vec, int k, pic_value val)
|
pic_vec_set(pic_state *PIC_UNUSED(pic), pic_value vec, int k, pic_value val)
|
||||||
{
|
{
|
||||||
pic_vec_ptr(pic, vec)->data[k] = val;
|
vec_ptr(pic, vec)->data[k] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pic_vec_len(pic_state *PIC_UNUSED(pic), pic_value vec)
|
pic_vec_len(pic_state *PIC_UNUSED(pic), pic_value vec)
|
||||||
{
|
{
|
||||||
return pic_vec_ptr(pic, vec)->len;
|
return vec_ptr(pic, vec)->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -142,7 +142,7 @@ pic_vec_vector_copy_i(pic_state *pic)
|
||||||
|
|
||||||
VALID_ATRANGE(pic, tolen, at, fromlen, start, end);
|
VALID_ATRANGE(pic, tolen, at, fromlen, start, end);
|
||||||
|
|
||||||
memmove(pic_vec_ptr(pic, to)->data + at, pic_vec_ptr(pic, from)->data + start, sizeof(pic_value) * (end - start));
|
memmove(vec_ptr(pic, to)->data + at, vec_ptr(pic, from)->data + start, sizeof(pic_value) * (end - start));
|
||||||
|
|
||||||
return pic_undef_value(pic);
|
return pic_undef_value(pic);
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ pic_vec_vector_copy(pic_state *pic)
|
||||||
|
|
||||||
VALID_RANGE(pic, fromlen, start, end);
|
VALID_RANGE(pic, fromlen, start, end);
|
||||||
|
|
||||||
return pic_make_vec(pic, end - start, pic_vec_ptr(pic, from)->data + start);
|
return pic_make_vec(pic, end - start, vec_ptr(pic, from)->data + start);
|
||||||
}
|
}
|
||||||
|
|
||||||
static pic_value
|
static pic_value
|
||||||
|
@ -188,7 +188,7 @@ pic_vec_vector_append(pic_state *pic)
|
||||||
len = 0;
|
len = 0;
|
||||||
for (i = 0; i < argc; ++i) {
|
for (i = 0; i < argc; ++i) {
|
||||||
int l = pic_vec_len(pic, argv[i]);
|
int l = pic_vec_len(pic, argv[i]);
|
||||||
memcpy(pic_vec_ptr(pic, vec)->data + len, pic_vec_ptr(pic, argv[i])->data, sizeof(pic_value) * l);
|
memcpy(vec_ptr(pic, vec)->data + len, vec_ptr(pic, argv[i])->data, sizeof(pic_value) * l);
|
||||||
len += l;
|
len += l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ pic_make_weak(pic_state *pic)
|
||||||
pic_value
|
pic_value
|
||||||
pic_weak_ref(pic_state *pic, pic_value weak, pic_value key)
|
pic_weak_ref(pic_state *pic, pic_value weak, pic_value key)
|
||||||
{
|
{
|
||||||
khash_t(weak) *h = &pic_weak_ptr(pic, weak)->hash;
|
khash_t(weak) *h = &weak_ptr(pic, weak)->hash;
|
||||||
int it;
|
int it;
|
||||||
|
|
||||||
it = kh_get(weak, h, obj_ptr(pic, key));
|
it = kh_get(weak, h, obj_ptr(pic, key));
|
||||||
|
@ -35,7 +35,7 @@ pic_weak_ref(pic_state *pic, pic_value weak, pic_value key)
|
||||||
void
|
void
|
||||||
pic_weak_set(pic_state *pic, pic_value weak, pic_value key, pic_value val)
|
pic_weak_set(pic_state *pic, pic_value weak, pic_value key, pic_value val)
|
||||||
{
|
{
|
||||||
khash_t(weak) *h = &pic_weak_ptr(pic, weak)->hash;
|
khash_t(weak) *h = &weak_ptr(pic, weak)->hash;
|
||||||
int ret;
|
int ret;
|
||||||
int it;
|
int it;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ pic_weak_set(pic_state *pic, pic_value weak, pic_value key, pic_value val)
|
||||||
bool
|
bool
|
||||||
pic_weak_has(pic_state *pic, pic_value weak, pic_value key)
|
pic_weak_has(pic_state *pic, pic_value weak, pic_value key)
|
||||||
{
|
{
|
||||||
khash_t(weak) *h = &pic_weak_ptr(pic, weak)->hash;
|
khash_t(weak) *h = &weak_ptr(pic, weak)->hash;
|
||||||
|
|
||||||
return kh_get(weak, h, obj_ptr(pic, key)) != kh_end(h);
|
return kh_get(weak, h, obj_ptr(pic, key)) != kh_end(h);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ pic_weak_has(pic_state *pic, pic_value weak, pic_value key)
|
||||||
void
|
void
|
||||||
pic_weak_del(pic_state *pic, pic_value weak, pic_value key)
|
pic_weak_del(pic_state *pic, pic_value weak, pic_value key)
|
||||||
{
|
{
|
||||||
khash_t(weak) *h = &pic_weak_ptr(pic, weak)->hash;
|
khash_t(weak) *h = &weak_ptr(pic, weak)->hash;
|
||||||
int it;
|
int it;
|
||||||
|
|
||||||
it = kh_get(weak, h, obj_ptr(pic, key));
|
it = kh_get(weak, h, obj_ptr(pic, key));
|
||||||
|
|
Loading…
Reference in New Issue