Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added non-working initial c api for embedding

  • Loading branch information...
commit 0d4b7b71826e18d313e36d43433a1c7f69bd6b6c 1 parent 151932a
@gaffo gaffo authored committed
Showing with 74 additions and 0 deletions.
  1. +39 −0 vm/api/embed.h
  2. +23 −0 vm/embed.c
  3. +12 −0 vm/test/test_embedding.hpp
View
39 vm/api/embed.h
@@ -0,0 +1,39 @@
+#include "environment.hpp"
+
+typedef Environment* rbx_ctx;
+
+extern "C"{
+/**
+ * Create a embedded rubinius environment
+ */
+rbx_ctx rbx_create_context();
+
+/**
+ * Requires a ruby file (like require 'file' in ruby)
+ *
+ * Returns true if it executed without exception, false if there was an error.
+ * Finding out what went wrong will be defined later.
+ */
+bool rbx_require_file(rbx_ctx ctx, const char * file);
+
+/**
+ * Evaulate a ruby file
+ *
+ * Returns true if it executed without exception, false if there was an error.
+ * Finding out what went wrong will be defined later.
+ */
+bool rbx_eval_file(rbx_ctx ctx, const char * file);
+
+/**
+ * Evaluate a ruby string
+ *
+ * Returns true if it executed without exception, false if there was an error.
+ * Finding out what went wrong will be defined later.
+ */
+bool rbx_eval(rbx_ctx ctx, const char * code);
+
+/**
+ * Clean up a context
+ */
+void rbx_close_ctx(rbx_ctx ctx);
+}
View
23 vm/embed.c
@@ -0,0 +1,23 @@
+#include "api/embed.h"
+
+#include "stdio.h"
+
+rbx_ctx rbx_create_context(){
+
+}
+
+bool rbx_require_file(rbx_ctx ctx, const char * file){
+
+}
+
+bool rbx_eval_file(rbx_ctx ctx, const char * file){
+
+}
+
+bool rbx_eval(rbx_ctx ctx, const char * code){
+
+}
+
+void rbx_close_ctx(rbx_ctx ctx){
+
+}
View
12 vm/test/test_embedding.hpp
@@ -0,0 +1,12 @@
+#include "vm/test/test.hpp"
+#include "api/embed.h"
+
+class TestEmbedding : public CxxTest::TestSuite, public VMTest {
+public:
+
+ void test_create_and_close_context() {
+ rbx_ctx ctx = rbx_create_context();
+ TS_ASSERT_DIFFERS(NULL, ctx);
+ rbx_close_ctx(ctx);
+ }
+};
Please sign in to comment.
Something went wrong with that request. Please try again.