Hello!
I'm having trouble passing an object to a beanscript interpreter, then calling a method from that object from within a beanscript file.
I have a class named "Pattern", and I'm trying to send in an object of this class into the Interpreter using the bsh.Interpreter::set(String,Object) method.
Here's "my" code. (Most of it is copied from an Interpreter wrapper that was posted as part of an example for live coding.)
Here's the basics of the Interpreter wrapper.
Code:
class Interpreter {
bsh.Interpreter ip = null;
Interpreter(){
ip = new bsh.Interpreter();
ip.eval("import processing.core.*;");
}
public void setPattern(String name, Pattern obj){
try{
ip.set(name, obj);
}
catch(bsh.EvalError e){
println(e);
}
}
}
Here's my code that calls it:
Code:
File setupScript = new File(dataPath("setup.bsh"));
// draft_sequencer1.get_pattern() returns a Pattern object
ip.setPattern("p1", draft_sequencer1.get_pattern());
ip.call(setupScript);
Here's setup.bsh (my beanscript):
Code:
p1.shrink(5); // shrink is a method of Pattern
Here's the error that I keep getting:
Code:
Sourced file: C:\Documents and Settings\Bret Truchan\My Documents\Processing\Quotile\data\setup.bsh : Error in method invocation: Method shrink( int ) not found in class'Quotile$Pattern' : at Line: 1 : in file: C:\Documents and Settings\Bret Truchan\My Documents\Processing\Quotile\data\setup.bsh : p1 .shrink ( 5 )
Just for giggles, here's a portion of class Pattern:
Code:
class Pattern
{
void shrink(int percentage)
{
this.stretch(-1 * percentage);
}
}
Any ideas why beanscript is unable to locate the shrink method in p1?