-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
499c1dd
commit 0e80a1f
Showing
5 changed files
with
101 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/main/java/xyz/wagyourtail/jsmacrosjython/functions/FConsumerJython.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package xyz.wagyourtail.jsmacrosjython.functions; | ||
|
||
import java.util.List; | ||
|
||
import org.python.core.PyFunction; | ||
|
||
import xyz.wagyourtail.jsmacros.extensionbase.Functions; | ||
import xyz.wagyourtail.jsmacros.extensionbase.IFConsumer; | ||
import xyz.wagyourtail.jsmacros.extensionbase.MethodWrapper; | ||
|
||
public class FConsumerJython extends Functions implements IFConsumer<PyFunction, PyFunction, PyFunction> { | ||
|
||
|
||
public FConsumerJython(String libName) { | ||
super(libName); | ||
} | ||
|
||
public FConsumerJython(String libName, List<String> exclude) { | ||
super(libName, exclude); | ||
} | ||
|
||
|
||
@Override | ||
public MethodWrapper<Object, Object> autoWrap(PyFunction c) { | ||
return new MethodWrapper<Object, Object>() { | ||
|
||
private void acceptInt(Object...args) { | ||
Thread t = new Thread(() -> { | ||
c._jcall(args); | ||
}); | ||
t.start(); | ||
} | ||
|
||
@Override | ||
public void accept(Object arg0) { | ||
acceptInt(arg0); | ||
|
||
} | ||
|
||
@Override | ||
public void accept(Object arg0, Object arg1) { | ||
acceptInt(arg0, arg1); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public MethodWrapper<Object, Object> autoWrapAsync(PyFunction c) { | ||
return new MethodWrapper<Object, Object>() { | ||
|
||
private void acceptInt(Object...args) { | ||
Thread t = new Thread(() -> { | ||
c._jcall(args); | ||
}); | ||
t.start(); | ||
} | ||
|
||
@Override | ||
public void accept(Object arg0) { | ||
acceptInt(arg0); | ||
|
||
} | ||
|
||
@Override | ||
public void accept(Object arg0, Object arg1) { | ||
acceptInt(arg0, arg1); | ||
} | ||
}; | ||
} | ||
|
||
|
||
@Override | ||
public MethodWrapper<Object, Object> toConsumer(PyFunction c) { | ||
return autoWrap(c); | ||
} | ||
|
||
@Override | ||
public MethodWrapper<Object, Object> toBiConsumer(PyFunction c) { | ||
return autoWrap(c); | ||
} | ||
|
||
@Override | ||
public MethodWrapper<Object, Object> toAsyncConsumer(PyFunction c) { | ||
return autoWrapAsync(c); | ||
} | ||
|
||
@Override | ||
public MethodWrapper<Object, Object> toAsyncBiConsumer(PyFunction c) { | ||
return autoWrapAsync(c); | ||
} | ||
|
||
} |
52 changes: 0 additions & 52 deletions
52
src/main/java/xyz/wagyourtail/jsmacrosjython/functions/consumerFunctions.java
This file was deleted.
Oops, something went wrong.