interface: SEOperatorOverloadCallback
public Boolean operatorOverload(SEContext se,short op);
ScriptEase implements operator overloading. Whenever an object is used as the left-hand operand, this callback is invoked. The op parameter will be the operator being overloaded, according to this table:
SE.OP_PREINC
|
++expr
|
SE.OP_POSTING
|
expr++
|
SE.OP_PREDEC
|
--expr
|
SE.OP_POSTDEC
|
expr--
|
SE.OP_ASSIGN
|
lhs = expr
|
SE.OP_NOT
|
!expr
|
SE.OP_UNARY_PLUS
|
+expr
|
SE.OP_UNARY_MINUS
|
-expr
|
SE.OP_BITNOT
|
~expr
|
SE.OP_EQUAL
|
expr==expr
|
SE.OP_NOTEQUAL
|
expr!=expr
|
SE.OP_STRICT_EQUAL
|
expr===expr
|
SE.OP_STRING_NOTEQUAL
|
expr!==expr
|
SE.OP_LESS
|
expr<expr
|
SE.OP_LESS_EQUAL
|
expr<=expr
|
SE.OP_GREATER
|
expr>expr
|
SE.OP_GREATER_EQUAL
|
expr>=expr
|
SE.OP_SUBTRACT
|
expr-expr
|
SE.OP_ADD
|
expr+expr
|
SE.OP_MULTIPLY
|
expr*expr
|
SE.OP_DIVIDE
|
expr/expr
|
SE.OP_MOD
|
expr%expr
|
SE.OP_SHIFTLEFT
|
expr<<expr
|
SE.OP_SHIFTRIGHT
|
expr>>expr
|
SE.OP_USHIFTRIGHT
|
expr>>>expr
|
SE.OP_OR
|
expr|expr
|
SE.OP_XOR
|
expr^expr
|
SE.OP_AND
|
expr&expr
|
The assign operators, such as *=, are performed as two separate operations, as if written expr = expr * expr instead of expr *= expr.
The right-hand side of the operator is to be found in SE.ARGS,SE.NUM(0). The result of the operation should be returned in the SE.RETURN object with a return from the function of true. A return of false will do the normal operation which will involve converting the object to a primitive type compatible with the other operand and doing the JavaScript operation.
Note that the operator overload will be called with the op SE.OP_ASSIGN if the object is assigned to. Normally, this operation is ignored since you cannot assign to an object directly. In a script, you can write:
some_obj = 10;
but this just discards the object in the given variable and replaces it with 10. If the object has operator overloading, this will call the overload callback instead. If you return false, the normal changing of some_obj's value takes place. If you return true, it does not. Be careful, you can make a variable whose value the user can never change in this way.
inteface: SEGetByIndexCallback