You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/02/26 16:30:42 UTC

[lucy-commits] svn commit: r1074869 - in /incubator/lucy/trunk/clownfish: include/CFC.h lib/Clownfish.xs lib/Clownfish/Dumpable.pm src/CFCDumpable.c src/CFCDumpable.h typemap

Author: marvin
Date: Sat Feb 26 15:30:42 2011
New Revision: 1074869

URL: http://svn.apache.org/viewvc?rev=1074869&view=rev
Log:
Change Clownfish::Dumpable to an inside-out Perl object implementation.

Added:
    incubator/lucy/trunk/clownfish/src/CFCDumpable.c
    incubator/lucy/trunk/clownfish/src/CFCDumpable.h
Modified:
    incubator/lucy/trunk/clownfish/include/CFC.h
    incubator/lucy/trunk/clownfish/lib/Clownfish.xs
    incubator/lucy/trunk/clownfish/lib/Clownfish/Dumpable.pm
    incubator/lucy/trunk/clownfish/typemap

Modified: incubator/lucy/trunk/clownfish/include/CFC.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/include/CFC.h?rev=1074869&r1=1074868&r2=1074869&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/include/CFC.h (original)
+++ incubator/lucy/trunk/clownfish/include/CFC.h Sat Feb 26 15:30:42 2011
@@ -18,6 +18,7 @@
 #include "CFCCBlock.h"
 #include "CFCClass.h"
 #include "CFCDocuComment.h"
+#include "CFCDumpable.h"
 #include "CFCFile.h"
 #include "CFCFunction.h"
 #include "CFCHierarchy.h"

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish.xs
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish.xs?rev=1074869&r1=1074868&r2=1074869&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish.xs (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish.xs Sat Feb 26 15:30:42 2011
@@ -387,6 +387,23 @@ PPCODE:
     END_SET_OR_GET_SWITCH
 }
 
+MODULE = Clownfish    PACKAGE = Clownfish::Dumpable
+
+SV*
+_new(klass)
+    const char *klass;
+CODE:
+    CFCDumpable *self = CFCDumpable_new();
+    RETVAL = newRV(CFCBase_get_perl_obj((CFCBase*)self));
+    CFCBase_decref((CFCBase*)self);
+OUTPUT: RETVAL
+
+void
+DESTROY(self)
+    CFCDumpable *self;
+PPCODE:
+    CFCDumpable_destroy(self);
+
 
 MODULE = Clownfish    PACKAGE = Clownfish::File
 

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Dumpable.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Dumpable.pm?rev=1074869&r1=1074868&r2=1074869&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Dumpable.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Dumpable.pm Sat Feb 26 15:30:42 2011
@@ -25,7 +25,8 @@ use Clownfish::Variable;
 
 sub new {
     my $either = shift;
-    return bless {}, ref($either) || $either;
+    my $package = ref($either) || $either;
+    return $either->_new();
 }
 
 sub add_dumpables {

Added: incubator/lucy/trunk/clownfish/src/CFCDumpable.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCDumpable.c?rev=1074869&view=auto
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCDumpable.c (added)
+++ incubator/lucy/trunk/clownfish/src/CFCDumpable.c Sat Feb 26 15:30:42 2011
@@ -0,0 +1,50 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#define CFC_NEED_BASE_STRUCT_DEF
+#include "CFCBase.h"
+#include "CFCDumpable.h"
+#include "CFCUtil.h"
+
+struct CFCDumpable {
+    CFCBase base;
+};
+
+CFCDumpable*
+CFCDumpable_new(void)
+{
+    CFCDumpable *self = (CFCDumpable*)CFCBase_allocate(sizeof(CFCDumpable),
+        "Clownfish::Dumpable");
+    return CFCDumpable_init(self);
+}
+
+CFCDumpable*
+CFCDumpable_init(CFCDumpable *self)
+{
+    return self;
+}
+
+void
+CFCDumpable_destroy(CFCDumpable *self)
+{
+    CFCBase_destroy((CFCBase*)self);
+}
+

Added: incubator/lucy/trunk/clownfish/src/CFCDumpable.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCDumpable.h?rev=1074869&view=auto
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCDumpable.h (added)
+++ incubator/lucy/trunk/clownfish/src/CFCDumpable.h Sat Feb 26 15:30:42 2011
@@ -0,0 +1,32 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef H_CFCDUMPABLE
+#define H_CFCDUMPABLE
+
+typedef struct CFCDumpable CFCDumpable;
+
+CFCDumpable*
+CFCDumpable_new(void);
+
+CFCDumpable*
+CFCDumpable_init(CFCDumpable *self);
+
+void
+CFCDumpable_destroy(CFCDumpable *self);
+
+#endif /* H_CFCDUMPABLE */
+

Modified: incubator/lucy/trunk/clownfish/typemap
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/typemap?rev=1074869&r1=1074868&r2=1074869&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/typemap (original)
+++ incubator/lucy/trunk/clownfish/typemap Sat Feb 26 15:30:42 2011
@@ -18,6 +18,7 @@ CFCBase*	CLOWNFISH_TYPE
 CFCCBlock*	CLOWNFISH_TYPE
 CFCClass*	CLOWNFISH_TYPE
 CFCDocuComment*	CLOWNFISH_TYPE
+CFCDumpable*	CLOWNFISH_TYPE
 CFCFile*	CLOWNFISH_TYPE
 CFCFunction*	CLOWNFISH_TYPE
 CFCHierarchy*	CLOWNFISH_TYPE