diff options
author | Keisuke Nishida <kxn30@po.cwru.edu> | 2000-12-07 12:04:48 +0000 |
---|---|---|
committer | Keisuke Nishida <kxn30@po.cwru.edu> | 2000-12-07 12:04:48 +0000 |
commit | 7c58e21b087b4b73835a6365045377d7dd1d22f3 (patch) | |
tree | 1ff09dd1a184f5a9f4ad711410a34a9569b054ba | |
parent | 68b069240f6039116c62a62c51ca0ea32e6ff92f (diff) | |
download | guile-7c58e21b087b4b73835a6365045377d7dd1d22f3.tar.gz |
Deprecated scm_make_smob_type_mfpe and scm_set_smob_mfpe.
Some optimization on applicable smobs. (Thanks to Dirk Herrmann)
-rw-r--r-- | libguile/ChangeLog | 12 | ||||
-rw-r--r-- | libguile/smob.c | 91 | ||||
-rw-r--r-- | libguile/smob.h | 29 |
3 files changed, 64 insertions, 68 deletions
diff --git a/libguile/ChangeLog b/libguile/ChangeLog index 25cfb5d63..814a4f180 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,5 +1,17 @@ 2000-12-07 Keisuke Nishida <kxn30@po.cwru.edu> + * smob.h (scm_smob_apply_0, scm_smob_apply_1, scm_smob_apply_2, + scm_smob_apply_3): Removed declarations. + (scm_set_smob_apply): Takes unsigned integers. + (scm_make_smob_type_mfpe, scm_set_smob_mfpe): Deprecated. + * smob.c (scm_smob_apply_0_000, scm_smob_apply_1_010, + scm_smob_apply_2_020): Removed. + (scm_set_smob_apply): Takes unsigned integers + some optimization. + (Thanks to Dirk Herrmann) + (scm_make_smob_type_mfpe, scm_set_smob_mfpe): Deprecated. + +2000-12-07 Keisuke Nishida <kxn30@po.cwru.edu> + * smob.h (SCM_SMOB_APPLICABLE_P, SCM_SMOB_APPLY_0, SCM_SMOB_APPLY_1, SCM_SMOB_APPLY_2, SCM_SMOB_APPLY_3): New macros. * eval.c (SCM_CEVAL, SCM_APPLY): Use macros above. diff --git a/libguile/smob.c b/libguile/smob.c index ca23373bb..5b9a0703c 100644 --- a/libguile/smob.c +++ b/libguile/smob.c @@ -135,12 +135,6 @@ scm_smob_print (SCM exp, SCM port, scm_print_state *pstate) SCM_SMOB_DESCRIPTOR (SMOB).apply (SMOB, A1, A2, A3) static SCM -scm_smob_apply_0_000 (SCM smob) -{ - return SCM_SMOB_APPLY0 (smob); -} - -static SCM scm_smob_apply_0_010 (SCM smob) { return SCM_SMOB_APPLY1 (smob, SCM_UNDEFINED); @@ -183,12 +177,6 @@ scm_smob_apply_0_error (SCM smob) } static SCM -scm_smob_apply_1_010 (SCM smob, SCM a1) -{ - return SCM_SMOB_APPLY1 (smob, a1); -} - -static SCM scm_smob_apply_1_020 (SCM smob, SCM a1) { return SCM_SMOB_APPLY2 (smob, a1, SCM_UNDEFINED); @@ -225,12 +213,6 @@ scm_smob_apply_1_error (SCM smob, SCM a1) } static SCM -scm_smob_apply_2_020 (SCM smob, SCM a1, SCM a2) -{ - return SCM_SMOB_APPLY2 (smob, a1, a2); -} - -static SCM scm_smob_apply_2_030 (SCM smob, SCM a1, SCM a2) { return SCM_SMOB_APPLY3 (smob, a1, a2, SCM_UNDEFINED); @@ -240,7 +222,7 @@ static SCM scm_smob_apply_2_001 (SCM smob, SCM a1, SCM a2) { return SCM_SMOB_APPLY1 (smob, SCM_LIST2 (a1, a2)); - } +} static SCM scm_smob_apply_2_011 (SCM smob, SCM a1, SCM a2) @@ -333,18 +315,6 @@ scm_make_smob_type (char *name, scm_sizet size) return scm_tc7_smob + (scm_numsmob - 1) * 256; } -long -scm_make_smob_type_mfpe (char *name, scm_sizet size, - SCM (*mark) (SCM), - scm_sizet (*free) (SCM), - int (*print) (SCM, SCM, scm_print_state *), - SCM (*equalp) (SCM, SCM)) -{ - long answer = scm_make_smob_type (name, size); - scm_set_smob_mfpe (answer, mark, free, print, equalp); - return answer; -} - void scm_set_smob_mark (long tc, SCM (*mark) (SCM)) { @@ -370,7 +340,8 @@ scm_set_smob_equalp (long tc, SCM (*equalp) (SCM, SCM)) } void -scm_set_smob_apply (long tc, SCM (*apply) (), int req, int opt, int rst) +scm_set_smob_apply (long tc, SCM (*apply) (), + unsigned int req, unsigned int opt, unsigned int rst) { SCM (*apply_0) (SCM); SCM (*apply_1) (SCM, SCM); @@ -378,8 +349,7 @@ scm_set_smob_apply (long tc, SCM (*apply) (), int req, int opt, int rst) SCM (*apply_3) (SCM, SCM, SCM, SCM); int type = SCM_GSUBR_MAKTYPE (req, opt, rst); - if (!(req >= 0 && opt >= 0 && (rst == 0 || rst == 1) - && req + opt + rst <= 3)) + if (rst > 1 || req + opt + rst > 3) { puts ("Unsupported smob application type"); abort (); @@ -388,7 +358,7 @@ scm_set_smob_apply (long tc, SCM (*apply) (), int req, int opt, int rst) switch (type) { case SCM_GSUBR_MAKTYPE (0, 0, 0): - apply_0 = scm_smob_apply_0_000; break; + apply_0 = apply; break; case SCM_GSUBR_MAKTYPE (0, 1, 0): apply_0 = scm_smob_apply_0_010; break; case SCM_GSUBR_MAKTYPE (0, 2, 0): @@ -409,7 +379,7 @@ scm_set_smob_apply (long tc, SCM (*apply) (), int req, int opt, int rst) { case SCM_GSUBR_MAKTYPE (1, 0, 0): case SCM_GSUBR_MAKTYPE (0, 1, 0): - apply_1 = scm_smob_apply_1_010; break; + apply_1 = apply; break; case SCM_GSUBR_MAKTYPE (1, 1, 0): case SCM_GSUBR_MAKTYPE (0, 2, 0): apply_1 = scm_smob_apply_1_020; break; @@ -433,7 +403,7 @@ scm_set_smob_apply (long tc, SCM (*apply) (), int req, int opt, int rst) case SCM_GSUBR_MAKTYPE (2, 0, 0): case SCM_GSUBR_MAKTYPE (1, 1, 0): case SCM_GSUBR_MAKTYPE (0, 2, 0): - apply_2 = scm_smob_apply_2_020; break; + apply_2 = apply; break; case SCM_GSUBR_MAKTYPE (2, 1, 0): case SCM_GSUBR_MAKTYPE (1, 2, 0): case SCM_GSUBR_MAKTYPE (0, 3, 0): @@ -479,20 +449,6 @@ scm_set_smob_apply (long tc, SCM (*apply) (), int req, int opt, int rst) scm_smobs[SCM_TC2SMOBNUM (tc)].gsubr_type = type; } -void -scm_set_smob_mfpe (long tc, - SCM (*mark) (SCM), - scm_sizet (*free) (SCM), - int (*print) (SCM, SCM, scm_print_state *), - SCM (*equalp) (SCM, SCM)) -{ - if (mark) scm_set_smob_mark (tc, mark); - if (free) scm_set_smob_free (tc, free); - if (print) scm_set_smob_print (tc, print); - if (equalp) scm_set_smob_equalp (tc, equalp); -} - - SCM scm_make_smob (long tc) { @@ -515,6 +471,39 @@ scm_make_smob (long tc) } +/* {Deprecated stuff} + */ + +#if (SCM_DEBUG_DEPRECATED == 0) + +long +scm_make_smob_type_mfpe (char *name, scm_sizet size, + SCM (*mark) (SCM), + scm_sizet (*free) (SCM), + int (*print) (SCM, SCM, scm_print_state *), + SCM (*equalp) (SCM, SCM)) +{ + long answer = scm_make_smob_type (name, size); + scm_set_smob_mfpe (answer, mark, free, print, equalp); + return answer; +} + +void +scm_set_smob_mfpe (long tc, + SCM (*mark) (SCM), + scm_sizet (*free) (SCM), + int (*print) (SCM, SCM, scm_print_state *), + SCM (*equalp) (SCM, SCM)) +{ + if (mark) scm_set_smob_mark (tc, mark); + if (free) scm_set_smob_free (tc, free); + if (print) scm_set_smob_print (tc, print); + if (equalp) scm_set_smob_equalp (tc, equalp); +} + +#endif /* SCM_DEBUG_DEPRECATED == 0 */ + + /* {Initialization for i/o types, float, bignum, the type of free cells} */ diff --git a/libguile/smob.h b/libguile/smob.h index 437eaccc9..878bd62e8 100644 --- a/libguile/smob.h +++ b/libguile/smob.h @@ -136,11 +136,6 @@ extern scm_sizet scm_free0 (SCM ptr); extern scm_sizet scm_smob_free (SCM obj); extern int scm_smob_print (SCM exp, SCM port, scm_print_state *pstate); -extern SCM scm_smob_apply_0 (SCM smob); -extern SCM scm_smob_apply_1 (SCM smob, SCM a1); -extern SCM scm_smob_apply_2 (SCM smob, SCM a1, SCM a2); -extern SCM scm_smob_apply_3 (SCM smob, SCM a1, SCM a2, SCM rest); - /* The following set of functions is the standard way to create new * SMOB types. * @@ -157,14 +152,19 @@ extern void scm_set_smob_print (long tc, int (*print) (SCM, SCM, scm_print_state*)); extern void scm_set_smob_equalp (long tc, SCM (*equalp) (SCM, SCM)); -extern void scm_set_smob_apply (long tc, SCM (*apply) (), int req, int opt, int rst); +extern void scm_set_smob_apply (long tc, SCM (*apply) (), + unsigned int req, + unsigned int opt, + unsigned int rst); +/* Function for creating smobs */ -/* Functions for registering multiple handler functions simultaneously. - * - * (There is a discussion among the developers whether or not these - * should be deprecated in the future.) - */ +extern SCM scm_make_smob (long tc); +extern void scm_smob_prehistory (void); + + + +#if (SCM_DEBUG_DEPRECATED == 0) extern long scm_make_smob_type_mfpe (char *name, scm_sizet size, SCM (*mark) (SCM), @@ -178,12 +178,7 @@ extern void scm_set_smob_mfpe (long tc, int (*print) (SCM, SCM, scm_print_state*), SCM (*equalp) (SCM, SCM)); -/* Function for creating smobs */ - -extern SCM scm_make_smob (long tc); -extern void scm_smob_prehistory (void); - - +#endif /* SCM_DEBUG_DEPRECATED == 0 */ #endif /* SMOBH */ |