shithub: femtolisp

Download patch

ref: 1878642275a4b7d07a91dbcad32902a060466a62
parent: d54805db1b8a0ef22f88b8a1db902618550ba53c
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Tue Dec 24 11:34:29 EST 2024

remove remnants of interfacing with C

--- a/cvalues.c
+++ b/cvalues.c
@@ -415,16 +415,6 @@
 	return 0;
 }
 
-BUILTIN("enum", enum)
-{
-	argcount(nargs, 2);
-	value_t type = fl_list2(FL(enumsym), args[0]);
-	fltype_t *ft = get_type(type);
-	value_t cv = cvalue(ft, sizeof(int32_t));
-	cvalue_enum_init(ft, args[1], cp_data((cprim_t*)ptr(cv)));
-	return cv;
-}
-
 int
 isarray(value_t v)
 {
@@ -566,49 +556,6 @@
 	return cv_len(cv)/cv_class(cv)->elsz;
 }
 
-static size_t
-cvalue_struct_offs(value_t type, value_t field, int computeTotal, int *palign)
-{
-	value_t fld = car(cdr_(type));
-	size_t fsz, ssz = 0;
-	int al;
-	*palign = 0;
-
-	while(iscons(fld)){
-		fsz = ctype_sizeof(car(cdr(car_(fld))), &al);
-
-		ssz = ALIGNED(ssz, al);
-		if(al > *palign)
-			*palign = al;
-
-		if(!computeTotal && field == car_(car_(fld))) // found target field
-			return ssz;
-
-		ssz += fsz;
-		fld = cdr_(fld);
-	}
-	return ALIGNED(ssz, *palign);
-}
-
-static size_t
-cvalue_union_size(value_t type, int *palign)
-{
-	value_t fld = car(cdr_(type));
-	size_t fsz, usz = 0;
-	int al;
-	*palign = 0;
-
-	while(iscons(fld)){
-		fsz = ctype_sizeof(car(cdr(car_(fld))), &al);
-		if(al > *palign)
-			*palign = al;
-		if(fsz > usz)
-			usz = fsz;
-		fld = cdr_(fld);
-	}
-	return ALIGNED(usz, *palign);
-}
-
 // *palign is an output argument giving the alignment required by type
 size_t
 ctype_sizeof(value_t type, int *palign)
@@ -622,14 +569,6 @@
 
 	if(iscons(type)){
 		value_t hed = car_(type);
-		if(hed == FL(structsym))
-			return cvalue_struct_offs(type, FL_nil, 1, palign);
-		if(hed == FL(unionsym))
-			return cvalue_union_size(type, palign);
-		if(hed == FL(pointersym) || hed == FL(cfunctionsym)){
-			*palign = offsetof(struct{ char a; void *i; }, i);
-			return sizeof(void*);
-		}
 		if(hed == FL(arraysym)){
 			value_t t = car(cdr_(type));
 			if(!iscons(cdr_(cdr_(type))))
@@ -638,10 +577,6 @@
 			size_t sz = tosize(n);
 			return sz * ctype_sizeof(t, palign);
 		}
-		if(hed == FL(enumsym)){
-			*palign = offsetof(struct{ char c; numerictype_t e; }, e);
-			return sizeof(numerictype_t);
-		}
 	}
 
 	lerrorf(FL(ArgError), "invalid c type");
@@ -1457,12 +1392,6 @@
 	ctor_cv_intern(double, T_DOUBLE, double);
 
 	ctor_cv_intern(array, NONNUMERIC, int);
-	ctor_cv_intern(enum, NONNUMERIC, int);
-	cv_intern(pointer);
-	cv_intern(struct);
-	cv_intern(union);
-	cv_intern(void);
-	FL(cfunctionsym) = symbol("c-function", false);
 
 	FL(stringtypesym) = symbol("*string-type*", false);
 	set(FL(stringtypesym), fl_list2(FL(arraysym), FL(bytesym)));
--- a/flisp.h
+++ b/flisp.h
@@ -400,10 +400,9 @@
 
 	value_t int8sym, uint8sym, int16sym, uint16sym, int32sym, uint32sym;
 	value_t int64sym, uint64sym, bignumsym;
-	value_t longsym, ulongsym, bytesym, runesym;
-	value_t structsym, arraysym, enumsym, cfunctionsym, voidsym, pointersym;
+	value_t bytesym, runesym, floatsym, doublesym;
 	value_t stringtypesym, runestringtypesym;
-	value_t unionsym, floatsym, doublesym;
+	value_t arraysym;
 
 	htable_t TypeTable;
 	htable_t reverse_dlsym_lookup_table;
--- a/print.c
+++ b/print.c
@@ -793,22 +793,6 @@
 				data = (char*)data + elsize;
 			}
 			outc(')', f);
-		}else if(car_(type) == FL(enumsym)){
-			int n = *(int*)data;
-			value_t syms = car(cdr_(type));
-			assert(isvector(syms));
-			if(!weak){
-				outsn("#enum(", f, 6);
-				fl_print_child(f, syms);
-				outc(' ', f);
-			}
-			if(n >= (int)vector_size(syms)){
-				cvalue_printdata(f, data, len, FL(int32sym), 1);
-			}else{
-				fl_print_child(f, vector_elt(syms, n));
-			}
-			if(!weak)
-				outc(')', f);
 		}
 	}
 }
--- a/types.c
+++ b/types.c
@@ -45,9 +45,6 @@
 			ft->eltype = eltype;
 			ft->init = cvalue_array_init;
 			//eltype->artype = ft; -- this is a bad idea since some types carry array sizes
-		}else if(car_(t) == FL(enumsym)){
-			ft->numtype = T_INT32;
-			ft->init = cvalue_enum_init;
 		}
 	}
 	*bp = ft;