[uim-commit] r1327 - in branches/r5rs: sigscheme uim

yamaken at freedesktop.org yamaken at freedesktop.org
Thu Aug 25 23:21:47 PDT 2005


Author: yamaken
Date: 2005-08-25 23:21:45 -0700 (Thu, 25 Aug 2005)
New Revision: 1327

Modified:
   branches/r5rs/sigscheme/sigschemetype.h
   branches/r5rs/uim/uim-scm.c
Log:
* sigscheme/sigschemetype.h
  - Add some comments about the abstraction of internal object
    represenation. See the comments added in the file
  - Reorganize sections
  - Move SigScm_* special constants to the section "Internal
    Declarations For Special Constants". See the comment in the section
  - (ScmFuncType): Move to "Struct Declarations" section. Although the
    section name is inappropriate, it's more appropriate than
    "Accessors For Scheme Objects" section
* uim/uim-scm.c
  - Replace all SigScm_null, SigScm_true, SigScm_false and
    SigScm_quote with SCM_NULL, SCM_TRUE, SCM_FALSE and SCM_QUOTE in
    accordance with the comments added in sigschemetype.h


Modified: branches/r5rs/sigscheme/sigschemetype.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h	2005-08-26 05:05:45 UTC (rev 1326)
+++ branches/r5rs/sigscheme/sigschemetype.h	2005-08-26 06:21:45 UTC (rev 1327)
@@ -47,6 +47,18 @@
 /*=======================================
    Struct Declarations
 =======================================*/
+/*
+ * Internal representation of these types MUST NOT directly touched by libsscm
+ * users. What libsscm users allowed is referring the types and constant values
+ * in declarations and definitions.
+ *
+ * All operations touching the internal representation such as accessing a
+ * member of a struct must be performed through the accessor macros defined in
+ * the section "Accessors For Scheme Objects" below. Otherwise the client code
+ * of libsscm will be broken when SigScheme has change internal object
+ * representations. The macros abstract the difference.
+ */
+
 /* Scheme Object Type */
 enum ScmObjType {
     ScmInt          = 0,
@@ -222,6 +234,12 @@
     } obj;
 };
 
+/* C Function */
+typedef ScmObj (*ScmFuncType) (void);
+
+/*=======================================
+   Accessors For Scheme Objects
+=======================================*/
 #define SCM_TYPE(a)       ((a)->type)
 #define SCM_ENTYPE(a, objtype) ((a)->type = (objtype))
 #define SCM_MARK(a) ((a)->gcmark)
@@ -266,7 +284,6 @@
 #define SCM_STRING_LEN(a) (SCM_STRING(a)->obj.string.len)
 #define SCM_STRING_SET_LEN(a, len) (SCM_STRING_LEN(a) = (len))
 
-typedef ScmObj (*ScmFuncType) (void);
 #define SCM_FUNCP(a) (SCM_TYPE(a) == ScmFunc)
 #define SCM_FUNC(a) (sigassert(SCM_FUNCP(a)), (a))
 #define SCM_ENTYPE_FUNC(a)     (SCM_ENTYPE((a), ScmFunc))
@@ -335,7 +352,7 @@
 #define SCM_VALUEPACKET_SET_VALUES(a, v) (SCM_VALUEPACKET_VALUES(a) = (v))
 
 /*============================================================================
-  Etcetra variables (Special Symbols like NULL)
+  Etcetra Variables (Special Constants like SCM_NULL)
 ============================================================================*/
 #define SCM_ETCP(a) (SCM_TYPE(a) == ScmEtc)
 #define SCM_ETC(a) (sigassert(SCM_ETCP(a)), (a))
@@ -349,7 +366,7 @@
     } while(0)
 
 /*============================================================================
-  For C-Interface
+  C Pointer Object
 ============================================================================*/
 #define SCM_C_POINTERP(a) (SCM_TYPE(a) == ScmCPointer)
 #define SCM_C_POINTER(a)  (sigassert(SCM_C_POINTERP(a)), (a))
@@ -363,10 +380,9 @@
 #define SCM_C_FUNCPOINTER_VALUE(a) (SCM_C_FUNCPOINTER(a)->obj.c_func_pointer.func)
 #define SCM_C_FUNCPOINTER_SET_VALUE(a, funcptr) (SCM_C_FUNCPOINTER_VALUE(a) = funcptr)
 
-extern ScmObj SigScm_null, SigScm_true, SigScm_false, SigScm_eof;
-extern ScmObj SigScm_quote, SigScm_quasiquote, SigScm_unquote, SigScm_unquote_splicing;
-extern ScmObj SigScm_unbound, SigScm_undef;
-
+/*============================================================================
+  Special Constants
+============================================================================*/
 #define SCM_NULL             SigScm_null
 #define SCM_TRUE             SigScm_true
 #define SCM_FALSE            SigScm_false
@@ -386,4 +402,20 @@
 #define SCM_NFALSEP(a) (SCM_NEQ((a), SCM_FALSE))
 #define SCM_EOFP(a)    (SCM_EQ((a),  SCM_EOF))
 
+/*============================================================================
+  Internal Declarations For Special Constants
+============================================================================*/
+/*
+ * These declarations are dedicated to internal use. libsscm users MUST NOT
+ * refer these internal representations directly.
+ *
+ * It may be changed when SigScheme's internal storage model or accessing
+ * method for the constants has been changed. To avoid suffering code
+ * incompatibility from it, use the abstract macro such as SCM_NULL defined
+ * above. They safely hides the internal model against such change.
+ */
+extern ScmObj SigScm_null, SigScm_true, SigScm_false, SigScm_eof;
+extern ScmObj SigScm_quote, SigScm_quasiquote, SigScm_unquote, SigScm_unquote_splicing;
+extern ScmObj SigScm_unbound, SigScm_undef;
+
 #endif /* __SIGSCMTYPE_H */

Modified: branches/r5rs/uim/uim-scm.c
===================================================================
--- branches/r5rs/uim/uim-scm.c	2005-08-26 05:05:45 UTC (rev 1326)
+++ branches/r5rs/uim/uim-scm.c	2005-08-26 06:21:45 UTC (rev 1327)
@@ -229,19 +229,19 @@
 uim_lisp
 uim_scm_t(void)
 {
-  return (uim_lisp)SigScm_true;
+  return (uim_lisp)SCM_TRUE;
 }
 
 uim_lisp
 uim_scm_f(void)
 {
-  return (uim_lisp)SigScm_false;
+  return (uim_lisp)SCM_FALSE;
 }
 
 uim_lisp
 uim_scm_null_list(void)
 {
-  return (uim_lisp)SigScm_null;
+  return (uim_lisp)SCM_NULL;
 }
 
 uim_bool
@@ -283,7 +283,7 @@
 uim_bool
 uim_scm_eq(uim_lisp a, uim_lisp b)
 {
-  if (SCM_EQ(ScmOp_eqp((ScmObj) a, (ScmObj) b), SigScm_true))
+  if (SCM_EQ(ScmOp_eqp((ScmObj) a, (ScmObj) b), SCM_TRUE))
     return UIM_TRUE;
 
   return UIM_FALSE;
@@ -292,7 +292,7 @@
 uim_bool
 uim_scm_string_equal(uim_lisp a, uim_lisp b)
 {
-  if(SCM_EQ(ScmOp_string_equal((ScmObj)a, (ScmObj)b), SigScm_true))
+  if(SCM_EQ(ScmOp_string_equal((ScmObj)a, (ScmObj)b), SCM_TRUE))
     return UIM_TRUE;
 
   return UIM_FALSE;
@@ -305,7 +305,7 @@
   uim_lisp stack_start;
 
   uim_scm_gc_protect_stack(&stack_start);
-  ret = (uim_lisp)ScmOp_eval((ScmObj)obj, SigScm_null);
+  ret = (uim_lisp)ScmOp_eval((ScmObj)obj, SCM_NULL);
   uim_scm_gc_unprotect_stack(&stack_start);
   return ret;
 }
@@ -315,17 +315,17 @@
 uim_scm_apply(uim_lisp proc, uim_lisp args)
 {
   return (uim_lisp)ScmOp_apply(Scm_NewCons((ScmObj)proc,
-					   Scm_NewCons((ScmObj)args, SigScm_null)),	
-			       SigScm_null);
+					   Scm_NewCons((ScmObj)args, SCM_NULL)),	
+			       SCM_NULL);
 }
 
 uim_lisp
 uim_scm_quote(uim_lisp obj)
 {
   /* TODO : fixme Kazuki Ohta <mover at hct.zaq.ne.jp> */
-  return (uim_lisp)Scm_NewCons(SigScm_quote,
+  return (uim_lisp)Scm_NewCons(SCM_QUOTE,
 			       Scm_NewCons((ScmObj)obj,
-					   SigScm_null));
+					   SCM_NULL));
 }
 #endif  /* UIM_SCM_EXTENDED_API */
 
@@ -516,8 +516,8 @@
   }
 
   SigScm_Initialize();
-  true_sym  = (uim_lisp)SigScm_true;
-  false_sym = (uim_lisp)SigScm_false;
+  true_sym  = (uim_lisp)SCM_TRUE;
+  false_sym = (uim_lisp)SCM_FALSE;
   protected_arg0 = uim_scm_f();
 }
 



More information about the uim-commit mailing list