mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-13 15:57:36 +02:00
Converting integer_type returning primitives
This commit is contained in:
parent
b670dacddb
commit
735bd910b6
2 changed files with 25 additions and 48 deletions
|
@ -125,7 +125,7 @@ object Cyc_get_cvar(object var);
|
|||
object Cyc_set_cvar(object var, object value);
|
||||
object apply(void *data, object cont, object func, object args);
|
||||
void Cyc_apply(void *data, int argc, closure cont, object prim, ...);
|
||||
integer_type Cyc_string_cmp(void *data, object str1, object str2);
|
||||
object Cyc_string_cmp(void *data, object str1, object str2);
|
||||
object Cyc_string_cmp2(void *data, object str1, object str2);
|
||||
void dispatch_string_91append(void *data, int argc, object clo, object cont, object str1, ...);
|
||||
list mcons(object,object);
|
||||
|
@ -150,9 +150,9 @@ object Cyc_eq(object x, object y);
|
|||
object Cyc_set_car(void *, object l, object val) ;
|
||||
object Cyc_set_cdr(void *, object l, object val) ;
|
||||
integer_type Cyc_length(void *d, object l);
|
||||
integer_type Cyc_vector_length(void *data, object v);
|
||||
object Cyc_length2(void *d, object l);
|
||||
object Cyc_vector_length(void *data, object v);
|
||||
object Cyc_vector_length2(void *data, object v);
|
||||
object Cyc_length2(void *d, object l);
|
||||
object Cyc_vector_ref(void *d, object v, object k);
|
||||
object Cyc_vector_set(void *d, object v, object k, object obj);
|
||||
object Cyc_make_vector(void *data, object cont, object len, object fill);
|
||||
|
@ -167,16 +167,16 @@ int binstr2int(const char *str);
|
|||
int octstr2int(const char *str);
|
||||
int hexstr2int(const char *str);
|
||||
object Cyc_string_append(void *data, object cont, int argc, object str1, ...);
|
||||
integer_type Cyc_string_length(void *data, object str);
|
||||
object Cyc_string_length(void *data, object str);
|
||||
object Cyc_string_length2(void *data, object str);
|
||||
object Cyc_substring(void *data, object cont, object str, object start, object end);
|
||||
object Cyc_string_ref(void *data, object str, object k);
|
||||
object Cyc_string_set(void *data, object str, object k, object chr);
|
||||
object Cyc_installation_dir(void *data, object cont, object type);
|
||||
object Cyc_command_line_arguments(void *data, object cont);
|
||||
integer_type Cyc_system(object cmd);
|
||||
object Cyc_system(object cmd);
|
||||
object Cyc_system2(object cmd);
|
||||
integer_type Cyc_char2integer(object chr);
|
||||
object Cyc_char2integer(object chr);
|
||||
object Cyc_char2integer2(object chr);
|
||||
object Cyc_integer2char(void *data, object n);
|
||||
void Cyc_halt(closure);
|
||||
|
|
61
runtime.c
61
runtime.c
|
@ -977,13 +977,6 @@ object Cyc_vector_ref(void *data, object v, object k) {
|
|||
return ((vector)v)->elts[idx];
|
||||
}
|
||||
|
||||
integer_type Cyc_vector_length(void *data, object v) {
|
||||
if (!nullp(v) && !is_value_type(v) && ((list)v)->tag == vector_tag) {
|
||||
make_int(len, ((vector)v)->num_elt);
|
||||
return len;
|
||||
}
|
||||
Cyc_rt_raise_msg(data, "vector-length - invalid parameter, expected vector\n"); }
|
||||
|
||||
integer_type Cyc_length(void *data, object l){
|
||||
make_int(len, 0);
|
||||
while(!nullp(l)){
|
||||
|
@ -996,12 +989,15 @@ integer_type Cyc_length(void *data, object l){
|
|||
return len;
|
||||
}
|
||||
|
||||
object Cyc_vector_length2(void *data, object v) {
|
||||
object Cyc_vector_length(void *data, object v) {
|
||||
if (!nullp(v) && !is_value_type(v) && ((list)v)->tag == vector_tag) {
|
||||
return obj_int2obj(((vector)v)->num_elt);
|
||||
}
|
||||
Cyc_rt_raise_msg(data, "vector-length - invalid parameter, expected vector\n"); }
|
||||
|
||||
object Cyc_vector_length2(void *data, object v) {
|
||||
return Cyc_vector_length(data, v); }
|
||||
|
||||
object Cyc_length2(void *data, object l){
|
||||
int len = 0;
|
||||
while(!nullp(l)){
|
||||
|
@ -1157,23 +1153,16 @@ int hexstr2int(const char *str)
|
|||
return num;
|
||||
}
|
||||
|
||||
integer_type Cyc_string_cmp(void *data, object str1, object str2) {
|
||||
Cyc_check_str(data, str1);
|
||||
Cyc_check_str(data, str2);
|
||||
{
|
||||
make_int(cmp, strcmp(((string_type *)str1)->str,
|
||||
((string_type *)str2)->str));
|
||||
return cmp;
|
||||
}
|
||||
}
|
||||
|
||||
object Cyc_string_cmp2(void *data, object str1, object str2) {
|
||||
object Cyc_string_cmp(void *data, object str1, object str2) {
|
||||
Cyc_check_str(data, str1);
|
||||
Cyc_check_str(data, str2);
|
||||
return obj_int2obj( strcmp(((string_type *)str1)->str,
|
||||
((string_type *)str2)->str) );
|
||||
}
|
||||
|
||||
object Cyc_string_cmp2(void *data, object str1, object str2) {
|
||||
return Cyc_string_cmp(data, str1, str2); }
|
||||
|
||||
#define Cyc_string_append_va_list(data, argc) { \
|
||||
int i = 0, total_len = 1; \
|
||||
int *len = alloca(sizeof(int) * argc); \
|
||||
|
@ -1215,17 +1204,14 @@ object Cyc_string_append(void *data, object cont, int _argc, object str1, ...) {
|
|||
Cyc_string_append_va_list(data, _argc);
|
||||
}
|
||||
|
||||
integer_type Cyc_string_length(void *data, object str) {
|
||||
Cyc_check_obj(data, string_tag, str);
|
||||
Cyc_check_str(data, str);
|
||||
{ make_int(len, strlen(string_str(str)));
|
||||
return len; }}
|
||||
|
||||
object Cyc_string_length2(void *data, object str) {
|
||||
object Cyc_string_length(void *data, object str) {
|
||||
Cyc_check_obj(data, string_tag, str);
|
||||
Cyc_check_str(data, str);
|
||||
return obj_int2obj(strlen(string_str(str))); }
|
||||
|
||||
object Cyc_string_length2(void *data, object str) {
|
||||
return Cyc_string_length(data, str); }
|
||||
|
||||
object Cyc_string_set(void *data, object str, object k, object chr) {
|
||||
char *raw;
|
||||
int idx, len;
|
||||
|
@ -1393,31 +1379,22 @@ object Cyc_list2vector(void *data, object cont, object l) {
|
|||
return_closcall1(data, cont, v);
|
||||
}
|
||||
|
||||
integer_type Cyc_system(object cmd) {
|
||||
if (nullp(cmd) || is_value_type(cmd) || type_of(cmd) != string_tag) {
|
||||
make_int(n, -1);
|
||||
return n;
|
||||
} else {
|
||||
make_int(n, system(((string_type *)cmd)->str));
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
object Cyc_system2(object cmd) {
|
||||
object Cyc_system(object cmd) {
|
||||
if (nullp(cmd) || is_value_type(cmd) || type_of(cmd) != string_tag) {
|
||||
return obj_int2obj(-1);
|
||||
}
|
||||
return obj_int2obj(system(((string_type *)cmd)->str));
|
||||
}
|
||||
|
||||
integer_type Cyc_char2integer(object chr){
|
||||
make_int(n, obj_obj2char(chr));
|
||||
return n;
|
||||
object Cyc_system2(object cmd) {
|
||||
return Cyc_system(cmd); }
|
||||
|
||||
object Cyc_char2integer(object chr){
|
||||
return obj_int2obj(obj_obj2char(chr));
|
||||
}
|
||||
|
||||
object Cyc_char2integer2(object chr){
|
||||
return obj_int2obj(obj_obj2char(chr));
|
||||
}
|
||||
return Cyc_char2integer(chr); }
|
||||
|
||||
object Cyc_integer2char(void *data, object n){
|
||||
int val = 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue