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/06/20 21:51:16 UTC

[lucy-commits] svn commit: r1137760 - in /incubator/lucy/trunk/clownfish: include/CFC.h lib/Clownfish.xs lib/Clownfish/Binding/Core/Method.pm src/CFCBindMethod.c src/CFCBindMethod.h

Author: marvin
Date: Mon Jun 20 19:51:16 2011
New Revision: 1137760

URL: http://svn.apache.org/viewvc?rev=1137760&view=rev
Log:
Start porting Clownfish::Binding::Core::Method to C.

Added:
    incubator/lucy/trunk/clownfish/src/CFCBindMethod.c   (with props)
    incubator/lucy/trunk/clownfish/src/CFCBindMethod.h   (with props)
Modified:
    incubator/lucy/trunk/clownfish/include/CFC.h
    incubator/lucy/trunk/clownfish/lib/Clownfish.xs
    incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm

Modified: incubator/lucy/trunk/clownfish/include/CFC.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/include/CFC.h?rev=1137760&r1=1137759&r2=1137760&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/include/CFC.h (original)
+++ incubator/lucy/trunk/clownfish/include/CFC.h Mon Jun 20 19:51:16 2011
@@ -31,3 +31,5 @@
 #include "CFCVariable.h"
 
 #include "CFCBindFunction.h"
+#include "CFCBindMethod.h"
+

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish.xs
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish.xs?rev=1137760&r1=1137759&r2=1137760&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish.xs (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish.xs Mon Jun 20 19:51:16 2011
@@ -1680,3 +1680,17 @@ CODE:
 }
 OUTPUT: RETVAL
 
+MODULE = Clownfish   PACKAGE = Clownfish::Binding::Core::Method
+
+SV*
+typedef_dec(unused, meth)
+    SV *unused;
+    CFCMethod *meth;
+CODE:
+{
+    char *declaration = CFCBindMeth_typdef_dec(meth);
+    RETVAL = newSVpvn(declaration, strlen(declaration));
+    FREEMEM(declaration);
+}
+OUTPUT: RETVAL
+

Modified: incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm?rev=1137760&r1=1137759&r2=1137760&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm (original)
+++ incubator/lucy/trunk/clownfish/lib/Clownfish/Binding/Core/Method.pm Mon Jun 20 19:51:16 2011
@@ -84,17 +84,6 @@ sub _final_method_def {
 END_STUFF
 }
 
-sub typedef_dec {
-    my ( undef, $method ) = @_;
-    my $params      = $method->get_param_list->to_c;
-    my $return_type = $method->get_return_type->to_c;
-    my $typedef     = $method->full_typedef;
-    return <<END_STUFF;
-typedef $return_type
-(*$typedef)($params);
-END_STUFF
-}
-
 sub callback_dec {
     my ( undef, $method ) = @_;
     my $callback_sym = $method->full_callback_sym;

Added: incubator/lucy/trunk/clownfish/src/CFCBindMethod.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindMethod.c?rev=1137760&view=auto
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindMethod.c (added)
+++ incubator/lucy/trunk/clownfish/src/CFCBindMethod.c Mon Jun 20 19:51:16 2011
@@ -0,0 +1,42 @@
+/* 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 <stdio.h>
+#include <string.h>
+#include "CFCBindMethod.h"
+#include "CFCUtil.h"
+#include "CFCMethod.h"
+#include "CFCFunction.h"
+#include "CFCParamList.h"
+#include "CFCType.h"
+
+char*
+CFCBindMeth_typdef_dec(struct CFCMethod *method) {
+    const char *params 
+        = CFCParamList_to_c(CFCFunction_get_param_list((CFCFunction*)method));
+    const char *ret_type
+        = CFCType_to_c(CFCFunction_get_return_type((CFCFunction*)method));
+    const char *full_typedef = CFCMethod_full_typedef(method);
+    size_t size = strlen(params)
+                  + strlen(ret_type)
+                  + strlen(full_typedef)
+                  + 20
+                  + sizeof("\0");
+    char *buf = (char*)MALLOCATE(size);
+    sprintf(buf, "typedef %s\n(*%s)(%s);\n", ret_type, full_typedef, params);
+    return buf;
+}
+

Propchange: incubator/lucy/trunk/clownfish/src/CFCBindMethod.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/lucy/trunk/clownfish/src/CFCBindMethod.h
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/src/CFCBindMethod.h?rev=1137760&view=auto
==============================================================================
--- incubator/lucy/trunk/clownfish/src/CFCBindMethod.h (added)
+++ incubator/lucy/trunk/clownfish/src/CFCBindMethod.h Mon Jun 20 19:51:16 2011
@@ -0,0 +1,35 @@
+/* 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_CFCBINDMETHOD
+#define H_CFCBINDMETHOD
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct CFCMethod;
+
+char*
+CFCBindMeth_typdef_dec(struct CFCMethod *method);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_CFCBINDMETHOD */
+
+

Propchange: incubator/lucy/trunk/clownfish/src/CFCBindMethod.h
------------------------------------------------------------------------------
    svn:eol-style = native