Skip to content

Commit

Permalink
Fix for groovy 4.0 change, should no longer require 'def'
Browse files Browse the repository at this point in the history
  • Loading branch information
xpdota committed Feb 5, 2024
1 parent 29d3610 commit 6c19ee8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ final class SandboxInterceptor extends GroovyInterceptor {
if (whitelist.permitsMethod(setPropertyMethod, receiver, propertyValueArgs)) {
return super.onSetProperty(invoker, receiver, property, value);
} else if (rejector == null) {
rejector = () -> StaticWhitelist.rejectMethod(setPropertyMethod, receiver.getClass().getName() + "." + property);
rejector = () -> StaticWhitelist.rejectMethod(setPropertyMethod, receiver.getClass().getName() + '.' + property);
}
}
final Field instanceField = GroovyCallSiteSelector.field(receiver, property);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import gg.xp.xivsupport.speech.CalloutEvent;
import gg.xp.xivsupport.speech.HasCalloutTrackingKey;
import gg.xp.xivsupport.speech.ProcessedCalloutEvent;
import groovy.lang.Binding;
import groovy.lang.Closure;
import groovy.lang.DelegatesTo;
import groovy.lang.GString;
Expand Down Expand Up @@ -218,11 +219,13 @@ private void finish() {
// This doesn't work right unless we clone
if (concurrencyMode == SequentialTriggerConcurrencyMode.CONCURRENT) {
Closure<?> clonedSqHandler = (Closure<?>) rawSqHandler.clone();
clonedSqHandler.setResolveStrategy(Closure.DELEGATE_FIRST);
clonedSqHandler.setDelegate(new GroovySqHelper<>(s));
clonedSqHandler.call(e1, s);
}
else {
rawSqHandler.setDelegate(new GroovySqHelper<>(s));
rawSqHandler.setResolveStrategy(Closure.DELEGATE_FIRST);
sq.accept(e1, s);
}
}
Expand Down Expand Up @@ -282,10 +285,12 @@ private <X> Supplier<X> wrapSupplier(Supplier<X> supplier) {
*/
public class GroovySqHelper<X extends BaseEvent> extends GroovyObjectSupport {
private final SequentialTriggerController<X> controller;
private final Binding binding;
private HasCalloutTrackingKey last;

public GroovySqHelper(SequentialTriggerController<X> controller) {
this.controller = controller;
this.binding = new Binding();
}

public CalloutEvent callout(@DelegatesTo(GroovyCalloutBuilder.class) Closure<?> closure) {
Expand Down Expand Up @@ -327,6 +332,19 @@ public void waitMs(int ms) {
public Object invokeMethod(String name, Object args) {
return super.invokeMethod(name, args);
}

@Override
public Object getProperty(String propertyName) {
if (binding.hasVariable(propertyName)) {
return binding.getVariable(propertyName);
}
return super.getProperty(propertyName);
}

@Override
public void setProperty(String propertyName, Object newValue) {
binding.setVariable(propertyName, newValue);
}
}

public class GroovyCalloutBuilder extends GroovyObjectSupport {
Expand Down

0 comments on commit 6c19ee8

Please sign in to comment.