pic_get_args supports strings

This commit is contained in:
Yuichi Nishiwaki 2013-10-21 11:42:21 +09:00
parent ba78a00d5c
commit b02f81760c
1 changed files with 16 additions and 4 deletions

View File

@ -5,6 +5,7 @@
#include "picrin/pair.h" #include "picrin/pair.h"
#include "picrin/proc.h" #include "picrin/proc.h"
#include "picrin/irep.h" #include "picrin/irep.h"
#include "picrin/string.h"
void void
pic_get_args(pic_state *pic, const char *format, ...) pic_get_args(pic_state *pic, const char *format, ...)
@ -21,8 +22,7 @@ pic_get_args(pic_state *pic, const char *format, ...)
pic_value *p; pic_value *p;
p = va_arg(ap, pic_value*); p = va_arg(ap, pic_value*);
*p = pic->sp[i]; *p = pic->sp[i--];
i--;
} }
break; break;
case 'f': case 'f':
@ -30,8 +30,20 @@ pic_get_args(pic_state *pic, const char *format, ...)
double *f; double *f;
f = va_arg(ap, double *); f = va_arg(ap, double *);
*f = pic_float(pic->sp[i]); *f = pic_float(pic->sp[i--]);
i--; }
break;
case 's':
{
pic_value str;
char **cstr;
size_t *len;
cstr = va_arg(ap, char **);
len = va_arg(ap, size_t *);
str = pic->sp[i--];
*cstr = pic_str_ptr(str)->str;
*len = pic_str_ptr(str)->len;
} }
break; break;
} }