Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

allow JavaObjects to be used as EProc arguments

  • Loading branch information...
commit 9fe76d9cc1004404e82c3035e0705d403dc3e55e 1 parent 5e2a0ad
@jetztgradnet jetztgradnet authored krestenkrab committed
Showing with 36 additions and 2 deletions.
  1. +36 −2 src/main/java/erjang/EProc.java
View
38 src/main/java/erjang/EProc.java
@@ -30,6 +30,7 @@
import kilim.Pausable;
import erjang.m.erlang.ErlFun;
import erjang.m.erlang.ErlProc;
+import erjang.m.java.JavaObject;
/**
* An erlang process
@@ -97,6 +98,17 @@
public int sp = 0;
// double[] fregs = new double[16];
public EDouble[] fregs = new EDouble[16];
+
+ public EProc(EPID group_leader, EAtom m, EAtom f, Object[] a) {
+ self = new EInternalPID(this);
+
+ // if no group leader is given, we're our own group leader
+ this.group_leader = group_leader == null ? self : group_leader;
+
+ setTarget(m, f, a);
+
+ all_tasks.put(key(), this);
+ }
/**
* @param m
@@ -108,6 +120,30 @@ public EProc(EPID group_leader, EAtom m, EAtom f, ESeq a) {
// if no group leader is given, we're our own group leader
this.group_leader = group_leader == null ? self : group_leader;
+
+ setTarget(m, f, a);
+
+ all_tasks.put(key(), this);
+ }
+
+ protected void setTarget(EAtom m, EAtom f, Object[] args) {
+ // wrap any non-EObject argument in JavaObject
+ EObject[] eargs = new EObject[args.length];
+ for (int i = 0; i < args.length; i++) {
+ Object arg = args[i];
+ if (arg instanceof EObject) {
+ EObject earg = (EObject) arg;
+ eargs[i] = earg;
+ }
+ else {
+ // wrap in JavaObject
+ eargs[i] = JavaObject.box(this, arg);
+ }
+ }
+ setTarget(m, f, ESeq.fromArray(eargs));
+ }
+
+ protected void setTarget(EAtom m, EAtom f, ESeq a) {
this.spawn_mod = m;
this.spawn_fun = f;
this.spawn_args = a.length();
@@ -140,8 +176,6 @@ public EProc(EPID group_leader, EAtom m, EAtom f, ESeq a) {
this.arg0 = a.head(); a = a.tail();
case 0:
}
-
- all_tasks.put(key(), this);
}
private int key() {
Please sign in to comment.
Something went wrong with that request. Please try again.