Commits

ariovistus committed e16213c

give InterpContext a mechanism to pass things from d to python and vice versa

  • Participants
  • Parent commits 2b08c1e

Comments (0)

Files changed (3)

File examples/pyd_unittests/embedded.d

             "import testing\n"
             "assert testing.a == \"doctor!\""
             );
+}
 
+unittest {
+    InterpContext c = new InterpContext();
+    c.locals["i"] = py(1);
+    c.j = py(2);
+    c.k = 4;
+    c.py_stmts(
+        "assert i == 1;"
+        "assert j == 2;"
+        "assert k == 4"
+        );
+   // (*^&^&* broken @property
+   // static assert(is(typeof(c.unicode("abc")) == PydObject));
 }
 
 void main() {}

File examples/pyd_unittests/embedded3.d

 
 }
 
+unittest {
+    InterpContext c = new InterpContext();
+    c.locals["i"] = py(1);
+    c.j = py(2);
+    c.k = 4;
+    c.py_stmts(
+        "assert i == 1;"
+        "assert j == 2;"
+        "assert k == 4"
+        );
+   // (*^&^&* broken @property
+   // static assert(is(typeof(c.unicode("abc")) == PydObject));
+}
+
 void main() {}

File infrastructure/pyd/embedded.d

             handle_exception(file,line);
         }
     }
+
+    @property PydObject opDispatch(string id)() {
+        return this.locals[id];
+    }
+
+    @property void opDispatch(string id, T)(T t) {
+        static if(is(T == PydObject)) {
+            alias t s;
+        }else{
+            PydObject s = py(t);
+        }
+        this.locals[id] = py(s);
+    }
 }
 
 /++