lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Eliminate "will never be null" warnings in smobs.tcc. (issue 153970043 b


From: nine . fierce . ballads
Subject: Eliminate "will never be null" warnings in smobs.tcc. (issue 153970043 by address@hidden)
Date: Sat, 04 Oct 2014 04:12:14 +0000

Reviewers: ,

Message:
It's verbose, but it does the trick portably (I think).

Description:
Eliminate "will never be null" warnings in smobs.tcc.

Please review this at https://codereview.appspot.com/153970043/

Affected files (+41, -6 lines):
  M lily/include/smobs.tcc


Index: lily/include/smobs.tcc
diff --git a/lily/include/smobs.tcc b/lily/include/smobs.tcc
index c2616b321692ec431f4c0dea55370872b0ab976f..eb634cd2acbabd0597dddde356ebdd35e779abdc 100644
--- a/lily/include/smobs.tcc
+++ b/lily/include/smobs.tcc
@@ -85,6 +85,44 @@ Scm_init Smob_base<Super>::scm_init_ = init;
 template <class Super>
 string Smob_base<Super>::smob_name_;

+static inline void set_smob_free (scm_t_bits smob_tag,
+                                  size_t (*free_smob) (SCM))
+{
+  scm_set_smob_free (smob_tag, free_smob);
+}
+
+static inline void set_smob_free (scm_t_bits, ...)
+{
+ // nothing to do because the last argument is not the right kind of procedure
+}
+
+static inline void set_smob_print (scm_t_bits smob_tag,
+                                   int (*print_smob) (SCM, SCM,
+                                                      scm_print_state *))
+{
+  scm_set_smob_print (smob_tag, print_smob);
+}
+
+static inline void set_smob_print (scm_t_bits, ...)
+{
+ // nothing to do because the last argument is not the right kind of procedure
+}
+
+static inline void set_smob_binary_op (void (*setter) (scm_t_bits,
+ SCM ( *) (SCM, SCM)),
+                                       scm_t_bits smob_tag,
+                                       SCM (*op) (SCM, SCM))
+{
+  (*setter) (smob_tag, op);
+}
+
+static inline void set_smob_binary_op (void ( *) (scm_t_bits,
+                                                  SCM ( *) (SCM, SCM)),
+                                       scm_t_bits, ...)
+{
+ // nothing to do because the last argument is not the right kind of procedure
+}
+
 template <class Super>
 void Smob_base<Super>::init ()
 {
@@ -103,14 +141,11 @@ void Smob_base<Super>::init ()
   // While that's not a consideration for type_p_name_, it's easier
   // doing it like the rest.

-  if (Super::free_smob != 0)
-    scm_set_smob_free (smob_tag_, Super::free_smob);
+  set_smob_free (smob_tag_, Super::free_smob);
   if (&Super::mark_smob != &Smob_base<Super>::mark_smob)
     scm_set_smob_mark (smob_tag_, Super::mark_trampoline);
-  if (Super::print_smob != 0)
-    scm_set_smob_print (smob_tag_, Super::print_smob);
-  if (Super::equal_p != 0)
-    scm_set_smob_equalp (smob_tag_, Super::equal_p);
+  set_smob_print (smob_tag_, Super::print_smob);
+  set_smob_binary_op (scm_set_smob_equalp, smob_tag_, Super::equal_p);
   if (Super::type_p_name_ != 0)
     {
       SCM subr = scm_c_define_gsubr (Super::type_p_name_, 1, 0, 0,





reply via email to

[Prev in Thread] Current Thread [Next in Thread]