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 2014/07/25 14:22:17 UTC

git commit: Copy Clownfish part of example-lang from Lucy

Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 157cad1bf -> 4e8f13076


Copy Clownfish part of example-lang from Lucy

Also adjust for some interface changes.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/4e8f1307
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/4e8f1307
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/4e8f1307

Branch: refs/heads/master
Commit: 4e8f13076b1923001abd4fc4182a6600d3804cab
Parents: 157cad1
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri Jul 25 14:19:33 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Fri Jul 25 14:21:21 2014 +0200

----------------------------------------------------------------------
 runtime/example-lang/README                     | 28 +++++++++
 runtime/example-lang/src/CFBind.c               | 19 ++++++
 runtime/example-lang/src/CFBind.h               | 51 ++++++++++++++++
 runtime/example-lang/src/Clownfish/Class.c      | 62 ++++++++++++++++++++
 runtime/example-lang/src/Clownfish/Err.c        | 60 +++++++++++++++++++
 .../src/Clownfish/LockFreeRegistry.c            | 28 +++++++++
 runtime/example-lang/src/Clownfish/Obj.c        | 45 ++++++++++++++
 7 files changed, 293 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/4e8f1307/runtime/example-lang/README
----------------------------------------------------------------------
diff --git a/runtime/example-lang/README b/runtime/example-lang/README
new file mode 100644
index 0000000..438499f
--- /dev/null
+++ b/runtime/example-lang/README
@@ -0,0 +1,28 @@
+The "example-lang" directory contains a template for adding a language binding
+to Clownfish. To get started, copy "example-lang" to a directory named after
+the language you'd like to bind to:
+
+    cp -R example-lang xyz
+
+Most of the C files within the "example-lang/src" directory contain stubs for
+routines whose interfaces are defined within "core".
+
+    core/Clownfish/Obj.cfh            # Declares interface.
+    core/Clownfish/Obj.c              # all except language-dependent
+    example-lang/src/Clownfish/Obj.c  # only language-dependent
+
+Once all the stubs have been implemented correctly, Clownfish will
+theoretically build and pass its tests.
+
+There is one pair of files with an interface *not* defined in core.
+
+    example-lang/src/CFBind.h
+    example-lang/src/CFBind.c
+
+The CFBind files are there to hold conversion routines which are specific to a
+language binding.  Since it is impractical to impose a generic interface, they
+are not defined in core.
+
+You may wish to start by referencing a finished language binding to get a feel
+for what should go in the CFBind files.
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/4e8f1307/runtime/example-lang/src/CFBind.c
----------------------------------------------------------------------
diff --git a/runtime/example-lang/src/CFBind.c b/runtime/example-lang/src/CFBind.c
new file mode 100644
index 0000000..772b065
--- /dev/null
+++ b/runtime/example-lang/src/CFBind.c
@@ -0,0 +1,19 @@
+/* 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 "CFBind.h"
+
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/4e8f1307/runtime/example-lang/src/CFBind.h
----------------------------------------------------------------------
diff --git a/runtime/example-lang/src/CFBind.h b/runtime/example-lang/src/CFBind.h
new file mode 100644
index 0000000..5c56aed
--- /dev/null
+++ b/runtime/example-lang/src/CFBind.h
@@ -0,0 +1,51 @@
+/* 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.
+ */
+
+/* CFBind.h -- Functions to help bind Clownfish to [LANGUAGE_X].
+ */
+
+#ifndef H_CFISH_CFBIND
+#define H_CFISH_CFBIND 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "charmony.h"
+#include "Clownfish/Obj.h"
+#include "Clownfish/ByteBuf.h"
+#include "Clownfish/String.h"
+#include "Clownfish/Err.h"
+#include "Clownfish/Hash.h"
+#include "Clownfish/Num.h"
+#include "Clownfish/VArray.h"
+#include "Clownfish/Class.h"
+
+/* Strip the prefix from some common symbols where we know there's no
+ * conflict.  It's a little inconsistent to do this rather than leave all
+ * symbols at full size, but the succinctness is worth it.
+ */
+#define THROW                CFISH_THROW
+#define WARN                 CFISH_WARN
+#define UNREACHABLE_RETURN   CFISH_UNREACHABLE_RETURN
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // H_CFISH_CFBIND
+
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/4e8f1307/runtime/example-lang/src/Clownfish/Class.c
----------------------------------------------------------------------
diff --git a/runtime/example-lang/src/Clownfish/Class.c b/runtime/example-lang/src/Clownfish/Class.c
new file mode 100644
index 0000000..19abca4
--- /dev/null
+++ b/runtime/example-lang/src/Clownfish/Class.c
@@ -0,0 +1,62 @@
+/* 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.
+ */
+
+#define C_CFISH_OBJ
+#define C_CFISH_CLASS
+
+#include "CFBind.h"
+
+cfish_Obj*
+CFISH_Class_Make_Obj_IMP(cfish_Class *self) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(cfish_Obj*);
+}
+
+cfish_Obj*
+CFISH_Class_Init_Obj_IMP(cfish_Class *self, void *allocation) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(cfish_Obj*);
+}
+
+cfish_Obj*
+CFISH_Class_Foster_Obj_IMP(cfish_Class *self, void *host_obj) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(cfish_Obj*);
+}
+
+void
+cfish_Class_register_with_host(cfish_Class *singleton, cfish_Class *parent) {
+    THROW(CFISH_ERR, "TODO");
+}
+
+cfish_VArray*
+cfish_Class_fresh_host_methods(const cfish_String *class_name) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(cfish_VArray*);
+}
+
+cfish_String*
+cfish_Class_find_parent_class(const cfish_String *class_name) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(cfish_String*);
+}
+
+void*
+CFISH_Class_To_Host_IMP(cfish_Class *self) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(void*);
+}
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/4e8f1307/runtime/example-lang/src/Clownfish/Err.c
----------------------------------------------------------------------
diff --git a/runtime/example-lang/src/Clownfish/Err.c b/runtime/example-lang/src/Clownfish/Err.c
new file mode 100644
index 0000000..6cb5027
--- /dev/null
+++ b/runtime/example-lang/src/Clownfish/Err.c
@@ -0,0 +1,60 @@
+/* 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 "CFBind.h"
+
+void
+cfish_Err_init_class() {
+}
+
+cfish_Err*
+cfish_Err_get_error() {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(cfish_Err*);
+}
+
+void
+cfish_Err_set_error(cfish_Err *error) {
+    THROW(CFISH_ERR, "TODO");
+}
+
+void
+cfish_Err_do_throw(cfish_Err *err) {
+    THROW(CFISH_ERR, "TODO");
+}
+
+void*
+CFISH_Err_To_Host_IMP(cfish_Err *self) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(void*);
+}
+
+void
+cfish_Err_throw_mess(cfish_Class *klass, cfish_String *message) {
+    THROW(CFISH_ERR, "TODO");
+}
+
+void
+cfish_Err_warn_mess(cfish_String *message) {
+    THROW(CFISH_ERR, "TODO");
+}
+
+cfish_Err*
+cfish_Err_trap(CFISH_Err_Attempt_t routine, void *context) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(cfish_Err*);
+}
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/4e8f1307/runtime/example-lang/src/Clownfish/LockFreeRegistry.c
----------------------------------------------------------------------
diff --git a/runtime/example-lang/src/Clownfish/LockFreeRegistry.c b/runtime/example-lang/src/Clownfish/LockFreeRegistry.c
new file mode 100644
index 0000000..cbc0c60
--- /dev/null
+++ b/runtime/example-lang/src/Clownfish/LockFreeRegistry.c
@@ -0,0 +1,28 @@
+/* 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.
+ */
+
+#define C_CFISH_LOCKFREEREGISTRY
+
+#include "CFBind.h"
+#include "Clownfish/LockFreeRegistry.h"
+
+void*
+CFISH_LFReg_To_Host_IMP(cfish_LockFreeRegistry *self) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(void*);
+}
+
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/4e8f1307/runtime/example-lang/src/Clownfish/Obj.c
----------------------------------------------------------------------
diff --git a/runtime/example-lang/src/Clownfish/Obj.c b/runtime/example-lang/src/Clownfish/Obj.c
new file mode 100644
index 0000000..f8679c8
--- /dev/null
+++ b/runtime/example-lang/src/Clownfish/Obj.c
@@ -0,0 +1,45 @@
+/* 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.
+ */
+
+#define C_CFISH_OBJ
+
+#include "CFBind.h"
+
+uint32_t
+CFISH_Obj_Get_RefCount_IMP(cfish_Obj *self) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(uint32_t);
+}
+
+cfish_Obj*
+CFISH_Obj_Inc_RefCount_IMP(cfish_Obj *self) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(cfish_Obj*);
+}
+
+uint32_t
+CFISH_Obj_Dec_RefCount_IMP(cfish_Obj *self) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(uint32_t);
+}
+
+void*
+CFISH_Obj_To_Host_IMP(cfish_Obj *self) {
+    THROW(CFISH_ERR, "TODO");
+    UNREACHABLE_RETURN(void*);
+}
+
+