libgeda

libgedaguile_priv.h

Go to the documentation of this file.
00001 /* gEDA - GPL Electronic Design Automation
00002  * libgeda - gEDA's library - Scheme API
00003  * Copyright (C) 2010-2012 Peter Brett <peter@peter-b.co.uk>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
00018  */
00019 
00086 #include <missing.h>
00087 #include <libgeda/libgedaguile.h>
00088 
00089 void edascm_init_smob ();
00090 void edascm_init_toplevel ();
00091 void edascm_init_object ();
00092 void edascm_init_complex ();
00093 void edascm_init_page ();
00094 void edascm_init_attrib ();
00095 void edascm_init_os ();
00096 void edascm_init_deprecated ();
00097 
00098 /* ---------------------------------------- */
00099 
00100 /* Macros and constants for working with the geda smob type. These are
00101  * for the convenience of the other C functions used by the Scheme
00102  * API. */
00103 
00105 extern scm_t_bits geda_smob_tag;
00106 
00108 enum geda_smob_flags {
00109   GEDA_SMOB_TOPLEVEL = 0,
00110   GEDA_SMOB_PAGE = 1,
00111   GEDA_SMOB_OBJECT = 2,
00112   GEDA_SMOB_TYPE_MASK = 0xf,
00113   GEDA_SMOB_GC_FLAG = 0x100,
00114 };
00115 
00117 #define EDASCM_SMOB_TYPE(x) (SCM_SMOB_FLAGS (x) & GEDA_SMOB_TYPE_MASK)
00118 
00124 #define EDASCM_SMOB_TYPEP(x, type) \
00125   (SCM_SMOB_PREDICATE (geda_smob_tag, x) && (EDASCM_SMOB_TYPE (x) == type))
00126 
00132 #define EDASCM_SMOB_VALIDP(x) \
00133   (SCM_SMOB_PREDICATE (geda_smob_tag, x) && ((void *)SCM_SMOB_DATA (x) != NULL))
00134 
00139 #ifdef NDEBUG
00140 #  define EDASCM_ASSERT_SMOB_VALID(x)
00141 #else
00142 #  define EDASCM_ASSERT_SMOB_VALID(x) \
00143   do { if (!EDASCM_SMOB_VALIDP(x)) {                                    \
00144       scm_misc_error (NULL, "Found invalid gEDA smob ~S", scm_list_1 (x)); \
00145     } } while (0)
00146 #endif
00147 
00148 /* Create a Guile value from a TOPLEVEL structure. */
00149 SCM edascm_from_toplevel (TOPLEVEL *toplevel);
00150 
00152 #define EDASCM_TOPLEVELP(x) EDASCM_SMOB_TYPEP(x, GEDA_SMOB_TOPLEVEL)
00153 
00155 #define EDASCM_PAGEP(x) EDASCM_SMOB_TYPEP(x, GEDA_SMOB_PAGE)
00156 
00158 #define EDASCM_OBJECTP(x) EDASCM_SMOB_TYPEP(x, GEDA_SMOB_OBJECT)
00159 
00167 #define EDASCM_SMOB_GCP(x) \
00168   (SCM_SMOB_PREDICATE (geda_smob_tag, x) && ((SCM_SMOB_FLAGS (x) & GEDA_SMOB_GC_FLAG) != 0))
00169 
00180 #define EDASCM_SMOB_SET_GC(x, gc) \
00181   SCM_SET_SMOB_FLAGS (x, gc ? (SCM_SMOB_FLAGS (x) | GEDA_SMOB_GC_FLAG) \
00182                             : (SCM_SMOB_FLAGS (x) & ~GEDA_SMOB_GC_FLAG))
00183 
00184 /* ---------------------------------------- */
00185 
00186 GList *edascm_to_object_glist (SCM objs, const char *subr)
00187   G_GNUC_WARN_UNUSED_RESULT;
00188 SCM edascm_from_object_glist (const GList *objs);
00189 int edascm_is_object_type (SCM smob, int type);
00190 
00191 
00193 extern inline void o_page_changed (TOPLEVEL *t, OBJECT *o);
00194 
00195 /* ---------------------------------------- */
00196 
00197 extern SCM edascm_object_state_sym;
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines