libgeda
|
Scheme representations of gEDA C structures. More...
#include <config.h>
#include "libgeda_priv.h"
#include "libgedaguile_priv.h"
#include "scheme_smob.x"
Go to the source code of this file.
Functions | |
static void | smob_weakref_notify (void *target, void *smob) |
Weak reference notify function for gEDA smobs. | |
static void | smob_weakref2_notify (void *target, void *smob) |
Weak reference notify function for double-length gEDA smobs. | |
static size_t | smob_free (SCM smob) |
Free a gEDA smob. | |
static int | smob_print (SCM smob, SCM port, scm_print_state *pstate) |
Print a representation of a gEDA smob. | |
static SCM | smob_equalp (SCM obj1, SCM obj2) |
Check gEDA smobs for equality. | |
SCM | edascm_from_toplevel (TOPLEVEL *toplevel) |
Get the smob for a TOPLEVEL. | |
SCM | edascm_from_page (PAGE *page) |
Get a smob for a page. | |
PAGE * | edascm_to_page (SCM smob) |
Get a page from a smob. | |
SCM | edascm_from_object (OBJECT *object) |
Get a smob for a schematic object. | |
OBJECT * | edascm_to_object (SCM smob) |
Get a schematic object from a smob. | |
void | edascm_c_set_gc (SCM smob, int gc) |
Set whether a gEDA object may be garbage collected. | |
int | edascm_is_object (SCM smob) |
Test whether a smob is a OBJECT instance. | |
int | edascm_is_page (SCM smob) |
Test whether a smob is a PAGE instance. | |
SCM_DEFINE (page_p,"%page?", 1, 0, 0,(SCM page_smob),"Test whether the value is a gEDA PAGE instance.") | |
Test whether a smob is a PAGE instance. | |
SCM_DEFINE (object_p,"%object?", 1, 0, 0,(SCM object_smob),"Test whether the value is a gEDA OBJECT instance.") | |
Test whether a smob is an OBJECT instance. | |
static void | init_module_geda_core_smob () |
Create the (geda core smob) Scheme module. | |
void | edascm_init_smob () |
Initialise the basic gEDA smob types. | |
Variables | |
scm_t_bits | geda_smob_tag |
In order for Scheme code to be able to manipulate libgeda data structures, it is convenient for it to be able to get handles to several of the different C structures that libgeda uses, in particular TOPLEVEL, PAGE and OBJECT.
A particular issue is that, in principle, Guile can stash a variable somewhere and only try and access it much later, possibly after the underlying C structure has already been freed.
In order to avoid this situation causing a segmentation fault, weak references are used. In the case of PAGE and TOPLEVEL handles, the usage is quite straightforward; Scheme code can never create or destroy a TOPLEVEL; and although a PAGE can be created by Scheme code, it must explicitly be destroyed if the Scheme code doesn't want the PAGE to hang around after it returns.
OBJECT handles are a more complex case. It's possible that Scheme code may legitimately want to create an OBJECT and do something with it (or, similarly, pull an OBJECT out of a PAGE), without needing to carefully keep track of the OBJECT to avoid dropping it on the floor. In that case, users should be able to rely on the garbage collector.
For that reason, an OBJECT is marked to be destroyed by garbage-collection in two cases:
Definition in file scheme_smob.c.
static void smob_weakref_notify | ( | void * | target, |
void * | smob | ||
) | [static] |
Definition at line 70 of file scheme_smob.c.
static void smob_weakref2_notify | ( | void * | target, |
void * | smob | ||
) | [static] |
Definition at line 83 of file scheme_smob.c.
static size_t smob_free | ( | SCM | smob | ) | [static] |
Used internally to Guile.
Definition at line 95 of file scheme_smob.c.
static int smob_print | ( | SCM | smob, |
SCM | port, | ||
scm_print_state * | pstate | ||
) | [static] |
Used internally to Guile.
Definition at line 162 of file scheme_smob.c.
static SCM smob_equalp | ( | SCM | obj1, |
SCM | obj2 | ||
) | [static] |
Used internally to Guile.
Definition at line 207 of file scheme_smob.c.
SCM_DEFINE | ( | page_p | , |
"%page?" | , | ||
1 | , | ||
0 | , | ||
0 | , | ||
(SCM page_smob) | , | ||
"Test whether the value is a gEDA PAGE instance." | |||
) |
[in] | page_smob | Guile value to test. |
Definition at line 403 of file scheme_smob.c.
SCM_DEFINE | ( | object_p | , |
"%object?" | , | ||
1 | , | ||
0 | , | ||
0 | , | ||
(SCM object_smob) | , | ||
"Test whether the value is a gEDA OBJECT instance." | |||
) |
[in] | object_smob | Guile value to test. |
Definition at line 422 of file scheme_smob.c.
static void init_module_geda_core_smob | ( | ) | [static] |
Definition at line 436 of file scheme_smob.c.
void edascm_init_smob | ( | ) |
Definition at line 455 of file scheme_smob.c.
scm_t_bits geda_smob_tag |
The tag used to identify gEDA data structures in Scheme.
Definition at line 63 of file scheme_smob.c.