Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Nov 7, 2020
1 parent 0e80a1f commit 0bc5882
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 22 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modImplementation name: "jsmacros-1.16.3-1.2.7-beta-21df5de-dev"
modImplementation name: "jsmacros-1.16.4-1.2.8-dev"

//partial fabric api
modImplementation "net.fabricmc.fabric-api:fabric-api-base:${project.api_base_version}"
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16.1
yarn_mappings=1.16.1+build.1
loader_version=0.8.8+build.202
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.1
loader_version=0.9.0+build.204

# Mod Properties
mod_version = 1.0.6
mod_version = 1.0.7
maven_group = xyz.wagyourtail
archives_base_name = jsmacros-jython

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.python.core.PyFunction;

import org.python.core.PyObject;
import xyz.wagyourtail.jsmacros.extensionbase.Functions;
import xyz.wagyourtail.jsmacros.extensionbase.IFConsumer;
import xyz.wagyourtail.jsmacros.extensionbase.MethodWrapper;
Expand All @@ -21,33 +22,104 @@ public FConsumerJython(String libName, List<String> 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();
public MethodWrapper<Object, Object, Object> autoWrap(PyFunction c) {
return new MethodWrapper<Object, Object, Object>() {

@Override
public Object get() {
return runInt().__tojava__(Object.class);
}

@Override
public boolean test(Object o) {
return (boolean) runInt(o).__tojava__(boolean.class);
}

@Override
public Object apply(Object o) {
return runInt(o).__tojava__(Object.class);
}

@Override
public boolean test(Object o, Object o2) {
return (boolean) runInt(o, o2).__tojava__(boolean.class);
}

@Override
public Object apply(Object o, Object o2) {
return runInt(o, o2).__tojava__(Object.class);
}

@Override
public int compare(Object o1, Object o2) {
return (int) runInt(o1, o2).__tojava__(int.class);
}

@Override
public void run() {
runInt();
}

private PyObject runInt(Object...args) {
return c._jcall(args);
}

@Override
public void accept(Object arg0) {
acceptInt(arg0);
runInt(arg0);

}

@Override
public void accept(Object arg0, Object arg1) {
acceptInt(arg0, arg1);
runInt(arg0, arg1);
}
};
}

@Override
public MethodWrapper<Object, Object> autoWrapAsync(PyFunction c) {
return new MethodWrapper<Object, Object>() {

public MethodWrapper<Object, Object, Object> autoWrapAsync(PyFunction c) {
return new MethodWrapper<Object, Object, Object>() {

@Override
public Object get() {
return runInt().__tojava__(Object.class);
}

@Override
public boolean test(Object o) {
return (boolean) runInt(o).__tojava__(boolean.class);
}

@Override
public Object apply(Object o) {
return runInt(o).__tojava__(Object.class);
}

@Override
public boolean test(Object o, Object o2) {
return (boolean) runInt(o, o2).__tojava__(boolean.class);
}

@Override
public Object apply(Object o, Object o2) {
return runInt(o, o2).__tojava__(Object.class);
}

@Override
public int compare(Object o1, Object o2) {
return (int) runInt(o1, o2).__tojava__(int.class);
}

@Override
public void run() {
acceptInt();
}

private PyObject runInt(Object...args) {
return c._jcall(args);
}

private void acceptInt(Object...args) {
Thread t = new Thread(() -> {
c._jcall(args);
Expand All @@ -70,22 +142,22 @@ public void accept(Object arg0, Object arg1) {


@Override
public MethodWrapper<Object, Object> toConsumer(PyFunction c) {
public MethodWrapper<Object, Object, Object> toConsumer(PyFunction c) {
return autoWrap(c);
}

@Override
public MethodWrapper<Object, Object> toBiConsumer(PyFunction c) {
public MethodWrapper<Object, Object, Object> toBiConsumer(PyFunction c) {
return autoWrap(c);
}

@Override
public MethodWrapper<Object, Object> toAsyncConsumer(PyFunction c) {
public MethodWrapper<Object, Object, Object> toAsyncConsumer(PyFunction c) {
return autoWrapAsync(c);
}

@Override
public MethodWrapper<Object, Object> toAsyncBiConsumer(PyFunction c) {
public MethodWrapper<Object, Object, Object> toAsyncBiConsumer(PyFunction c) {
return autoWrapAsync(c);
}

Expand Down

0 comments on commit 0bc5882

Please sign in to comment.