Menu

#3 Convenience syntax for custom objects

None
closed
nobody
None
5
2018-08-01
2002-11-01
No

i suggest insert
such object which will redefine convenience syntax for
self, overload operations(+,-,*,(cast operation)..), and will
receive interpreter in constructor as parameter
It will be used for customizing beanshell script for
custom systems without rewriting source code

This object can have the next syntax:

abstract class CustomObject {
public CustomObject(Interpreter interpreter);

/** replace this + rightOperand string in script text*/
Object add(Object rightOperand) throw Exception;

/** replace this * rightOperand string in script text*/
Object multiply(Object rightOperand) throw Exception;
...

/** resolves next token
example myObject.a.b.c
if(myObject instanceof CustomObject)
try {
return ((CustomObject)myObject).point("a");
} catch (FieldNotFoundException e) {
other field resolving methods
}
*/
Object point(String fieldName) throw
FieldNotFoundException, Exception;

/**
* cast operations (CustomObject)value implementation
*/
CustomObject cast(Object value) throw
NotPossibleCast, Exception;
}

or other case than exists 2 object one have method for
operation on another object

public interface CustomObject {
protected Adapter getAdapter();
}

public interface Adapter {
protected Object add(CustomObject a, Object b);
protected Object subtr
}

Discussion

  • nickl-

    nickl- - 2018-08-01

    Ticket has been migrated to github.
    Please follow up on this over here: https://github.com/beanshell/beanshell/issues/92

     
  • nickl-

    nickl- - 2018-08-01
    • status: open --> closed
    • Group: -->
     

Log in to post a comment.