SWIGINTERN SCM SWIG_Guile_NewPointerObj(void *ptr, swig_type_info *type, int owner) { if (ptr == NULL) return SCM_EOL; else { SCM smob; swig_guile_clientdata *cdata = (swig_guile_clientdata *) type->clientdata; if (owner) SCM_NEWSMOB2(smob, swig_collectable_tag, ptr, (void *) type); else SCM_NEWSMOB2(smob, swig_tag, ptr, (void *) type); if (!cdata || SCM_NULLP(cdata->goops_class) || swig_make_func == SCM_EOL ) { return smob; } else { /* the scm_make() C function only handles the creation of gf, methods and classes (no instances) the (make ...) function is later redefined in goops.scm. So we need to call that Scheme function. */ return scm_apply(swig_make_func, scm_list_3(cdata->goops_class, swig_keyword, smob), SCM_EOL); } } }
/*! \brief Get a smob for a C closure. * \par Function Description * Create a new smob representing a C closure. * * \warning Do not call this function from user code; use * edascm_c_make_closure() instead. * * \param func C function to make closure around. * \param user_data User data for function. * \return a C closure smob. */ SCM edascm_from_closure (SCM (*func)(SCM, gpointer), gpointer user_data) { SCM smob; SCM_NEWSMOB2 (smob, geda_smob_tag, func, user_data); SCM_SET_SMOB_FLAGS (smob, GEDA_SMOB_CLOSURE); return smob; }
SWIGINTERN SCM SWIG_Guile_NewMemberObj(void *ptr, size_t sz, swig_type_info *type, const char *func_name) { SCM smob; void *copy = malloc(sz); memcpy(copy, ptr, sz); SCM_NEWSMOB2(smob, swig_member_function_tag, copy, (void *) type); return smob; }
/*! \brief Get a smob for a schematic object. * \ingroup guile_c_iface * \par Function Description * Create a new smob representing \a object. * * \warning The returned smob is initially marked as owned by the C * code. If it should be permitted to be garbage-collected, you * should set the garbage-collectable flag by calling: * * \code * SCM x = edascm_from_object (object); * edascm_c_set_gc (x, 1); * \endcode * * \note We currently have to bake a TOPLEVEL pointer into the smob, * so that if the object becomes garbage-collectable we can obtain a * TOPLEVEL to use for deleting the smob without accessing the * TOPLEVEL fluid and potentially causing a race condition (see bug * 909358). * * \param object #OBJECT to create a smob for. * \return a smob representing \a object. */ SCM edascm_from_object (OBJECT *object) { SCM smob; TOPLEVEL *toplevel = edascm_c_current_toplevel (); SCM_NEWSMOB2 (smob, geda_smob_tag, object, toplevel); SCM_SET_SMOB_FLAGS (smob, GEDA_SMOB_OBJECT); /* Set weak references */ s_object_weak_ref (object, smob_weakref_notify, smob); s_toplevel_weak_ref (toplevel, smob_weakref2_notify, smob); return smob; }
/*! \brief Get a smob for a schematic object. * \ingroup guile_c_iface * \par Function Description * Create a new smob representing \a object. * * \warning The returned smob is initially marked as owned by the C * code. If it should be permitted to be garbage-collected, you * should set the garbage-collectable flag by calling: * * \code * SCM x = edascm_from_object (object); * edascm_c_set_gc (x, 1); * \endcode * * \note We currently have to bake a TOPLEVEL pointer into the smob, * so that if the object becomes garbage-collectable we can obtain a * TOPLEVEL to use for deleting the smob without accessing the * TOPLEVEL fluid and potentially causing a race condition (see bug * 909358). * * \param object #OBJECT to create a smob for. * \return a smob representing \a object. */ SCM edascm_from_object (OBJECT *object) { SCM smob = smob_cache_lookup (object); if (EDASCM_OBJECTP (smob)) { return smob; } TOPLEVEL *toplevel = edascm_c_current_toplevel (); SCM_NEWSMOB2 (smob, geda_smob_tag, object, toplevel); SCM_SET_SMOB_FLAGS (smob, GEDA_SMOB_OBJECT); /* Set weak references */ s_object_weak_ref (object, smob_weakref2_notify, unpack_as_pointer (smob)); smob_cache_add (object, smob); return smob; }