As far as I can tell a C object's pointer value is safe to change,
which can be useful to do after realloc etc. so there's no need to
create a whole new object (and then propagate that out to anything
referring to the object in scheme; eugh).

I considered changing it for C pointer objects too for the sake of
symmetry, but I'm not sure if it makes as much sense there.

The patch is obvious and included below. Please let me know if
there's some good reason not to do this because my code does it.
Does the value stick around after being saved by those d_*_ok
functions?

I understand this is different from c-object-set which seems to be
a way of assigning a scheme setter on the object but that appears
to be undocumented.

Matthew

diff --git a/s7.c b/s7.c
index 363caf3..2f53a8a 100644
--- a/s7.c
+++ b/s7.c
@@ -48952,6 +48952,8 @@ void *s7_c_object_value_checked(s7_pointer obj, s7_int 
type)
   return(NULL);
 }
 
+void s7_c_object_set_value(s7_pointer obj, void *value) {c_object_value(obj) = 
value;}
+
 static s7_pointer make_c_object_with_let(s7_scheme *sc, s7_int type, void 
*value, s7_pointer let, bool with_gc)
 {
   s7_pointer obj;
diff --git a/s7.h b/s7.h
index aab4a5c..08b394a 100644
--- a/s7.h
+++ b/s7.h
@@ -705,6 +705,7 @@ bool s7_is_c_object(s7_pointer p);
 s7_int s7_c_object_type(s7_pointer obj);
 void *s7_c_object_value(s7_pointer obj);
 void *s7_c_object_value_checked(s7_pointer obj, s7_int type);
+void s7_c_object_set_value(s7_pointer obj, void *value);
 s7_pointer s7_make_c_object(s7_scheme *sc, s7_int type, void *value);
 s7_pointer s7_make_c_object_with_let(s7_scheme *sc, s7_int type, void *value, 
s7_pointer let);
 s7_pointer s7_make_c_object_without_gc(s7_scheme *sc, s7_int type, void 
*value);

_______________________________________________
Cmdist mailing list
[email protected]
https://cm-mail.stanford.edu/mailman/listinfo/cmdist

Reply via email to