You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2012/04/14 16:05:41 UTC

[lucy-commits] svn commit: r1326108 - in /lucy/trunk/core: Lucy.c Lucy/Object/Num.c Lucy/Object/Num.cfh

Author: nwellnhof
Date: Sat Apr 14 14:05:40 2012
New Revision: 1326108

URL: http://svn.apache.org/viewvc?rev=1326108&view=rev
Log:
Create BoolNum singletons during run-time

Modified:
    lucy/trunk/core/Lucy.c
    lucy/trunk/core/Lucy/Object/Num.c
    lucy/trunk/core/Lucy/Object/Num.cfh

Modified: lucy/trunk/core/Lucy.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy.c?rev=1326108&r1=1326107&r2=1326108&view=diff
==============================================================================
--- lucy/trunk/core/Lucy.c (original)
+++ lucy/trunk/core/Lucy.c Sat Apr 14 14:05:40 2012
@@ -14,7 +14,10 @@
  * limitations under the License.
  */
 
+#include "Lucy/Object/Num.h"
+
 void
 lucy_init_parcel() {
+    lucy_Bool_init_class();
 }
 

Modified: lucy/trunk/core/Lucy/Object/Num.c
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Object/Num.c?rev=1326108&r1=1326107&r2=1326108&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Object/Num.c (original)
+++ lucy/trunk/core/Lucy/Object/Num.c Sat Apr 14 14:05:40 2012
@@ -361,12 +361,19 @@ Int64_deserialize(Integer64 *self, InStr
 
 /***************************************************************************/
 
-static ViewCharBuf true_string  = { VIEWCHARBUF, {1}, "true",  4, 0 };
-static ViewCharBuf false_string = { VIEWCHARBUF, {1}, "false", 5, 0 };
-static BoolNum true_obj  = { BOOLNUM, {1}, true, &true_string };
-static BoolNum false_obj = { BOOLNUM, {1}, false, &false_string };
-BoolNum *Bool_true_singleton  = &true_obj;
-BoolNum *Bool_false_singleton = &false_obj;
+
+BoolNum *Bool_true_singleton;
+BoolNum *Bool_false_singleton;
+
+void
+Bool_init_class() {
+    Bool_true_singleton          = (BoolNum*)VTable_Make_Obj(BOOLNUM);
+    Bool_true_singleton->value   = true;
+    Bool_true_singleton->string  = CB_newf("true");
+    Bool_false_singleton         = (BoolNum*)VTable_Make_Obj(BOOLNUM);
+    Bool_false_singleton->value  = false;
+    Bool_false_singleton->string = CB_newf("false");
+}
 
 BoolNum*
 Bool_singleton(bool_t value) {
@@ -413,7 +420,7 @@ Bool_hash_sum(BoolNum *self) {
 
 CharBuf*
 Bool_to_string(BoolNum *self) {
-    return (CharBuf*)ViewCB_Inc_RefCount(self->string);
+    return (CharBuf*)CB_Inc_RefCount(self->string);
 }
 
 bool_t

Modified: lucy/trunk/core/Lucy/Object/Num.cfh
URL: http://svn.apache.org/viewvc/lucy/trunk/core/Lucy/Object/Num.cfh?rev=1326108&r1=1326107&r2=1326108&view=diff
==============================================================================
--- lucy/trunk/core/Lucy/Object/Num.cfh (original)
+++ lucy/trunk/core/Lucy/Object/Num.cfh Sat Apr 14 14:05:40 2012
@@ -243,11 +243,14 @@ class Lucy::Object::Integer64 cnick Int6
  */
 class Lucy::Object::BoolNum cnick Bool inherits Lucy::Object::IntNum {
     bool_t value;
-    ViewCharBuf *string;
+    CharBuf *string;
 
     inert BoolNum *true_singleton;
     inert BoolNum *false_singleton;
 
+    inert void
+    init_class();
+
     /** Return either CFISH_TRUE or CFISH_FALSE depending on the supplied
      * value.
      */