/*! \brief Check gEDA smobs for equality. * \par Function description * Returns SCM_BOOL_T if \a obj1 represents the same gEDA structure as * \a obj2 does. Otherwise, returns SCM_BOOL_F. * * Used internally to Guile. */ static SCM smob_equalp (SCM obj1, SCM obj2) { EDASCM_ASSERT_SMOB_VALID (obj1); EDASCM_ASSERT_SMOB_VALID (obj2); if (SCM_SMOB_DATA (obj1) == SCM_SMOB_DATA (obj2)) { return SCM_BOOL_T; } else { return SCM_BOOL_F; } }
/*! \brief Get a configuration context from a smob. * \ingroup guile_c_iface * \par Function Description * Return the #EdaConfig represented by \a smob. * * \param [in] smob Guile value to retrieve #EdaConfig from. * \return the #EdaConfig represented by \a smob. * * \since 1.10. */ EdaConfig * edascm_to_config (SCM smob) { #ifndef NDEBUG SCM_ASSERT (EDASCM_CONFIGP (smob), smob, SCM_ARG1, "edascm_to_object"); #endif EDASCM_ASSERT_SMOB_VALID (smob); return EDA_CONFIG (SCM_SMOB_DATA (smob)); }
/*! \brief Get a schematic object from a smob. * \ingroup guile_c_iface * \par Function Description * Return the #OBJECT represented by \a smob. * * \param [in] smob Guile value to retrieve #OBJECT from. * \return the #OBJECT represented by \a smob. */ OBJECT * edascm_to_object (SCM smob) { #ifndef NDEBUG SCM_ASSERT (EDASCM_OBJECTP (smob), smob, SCM_ARG1, "edascm_to_object"); #endif EDASCM_ASSERT_SMOB_VALID (smob); return (OBJECT *) SCM_SMOB_DATA (smob); }
/*! \brief Get a page from a smob. * \ingroup guile_c_iface * \par Function Description * Return the #PAGE represented by \a smob. * * \param [in] smob Guile value to retrieve #PAGE from. * \return the #PAGE represented by \a smob. */ PAGE * edascm_to_page (SCM smob) { #ifndef NDEBUG SCM_ASSERT (EDASCM_PAGEP (smob), smob, SCM_ARG1, "edascm_to_page"); #endif EDASCM_ASSERT_SMOB_VALID (smob); return (PAGE *) SCM_SMOB_DATA (smob); }
/*! \brief Set whether a gEDA object may be garbage collected. * \ingroup guile_c_iface * \par Function Description * If \a gc is non-zero, allow the structure represented by \a smob to * be destroyed when \a smob is garbage-collected. * * \param [in,out] smob Smob for which to set garbage-collection * permission. * \param [in] gc If non-zero, permit garbage collection. */ void edascm_c_set_gc (SCM smob, int gc) { EDASCM_ASSERT_SMOB_VALID (smob); int current = EDASCM_SMOB_GCP (smob); /* Ensure that when smob becomes garbage-collectible, it's removed * from the Scheme value cache, and that when it stops being * garbage-collectible it's cached for re-use. */ if (gc && !current) smob_cache_remove ((void *) SCM_SMOB_DATA (smob)); if (!gc && current) smob_cache_add ((void *) SCM_SMOB_DATA (smob), smob); EDASCM_SMOB_SET_GC (smob, gc); }
/*! \brief Set whether a gEDA object may be garbage collected. * \ingroup guile_c_iface * \par Function Description * If \a gc is non-zero, allow the structure represented by \a smob to * be destroyed when \a smob is garbage-collected. * * \param [in,out] smob Smob for which to set garbage-collection * permission. * \param [in] gc If non-zero, permit garbage collection. */ void edascm_c_set_gc (SCM smob, int gc) { EDASCM_ASSERT_SMOB_VALID (smob); EDASCM_SMOB_SET_GC (smob, gc); }