/// <summary> /// Utility method to construct type error to indicate incompatible call /// when converting script thisObj to a particular type is not possible. /// </summary> /// <remarks> /// Utility method to construct type error to indicate incompatible call /// when converting script thisObj to a particular type is not possible. /// Possible usage would be to have a private function like realThis: /// <pre> /// private static NativeSomething realThis(Scriptable thisObj, /// IdFunctionObject f) /// { /// if (!(thisObj instanceof NativeSomething)) /// throw incompatibleCallError(f); /// return (NativeSomething)thisObj; /// } /// </pre> /// Note that although such function can be implemented universally via /// java.lang.Class.isInstance(), it would be much more slower. /// </remarks> /// <param name="f"> /// function that is attempting to convert 'this' /// object. /// </param> /// <returns> /// Scriptable object suitable for a check by the instanceof /// operator. /// </returns> /// <exception cref="System.Exception">if no more instanceof target can be found</exception> protected internal static EcmaError IncompatibleCallError(IdFunctionObject f) { throw ScriptRuntime.TypeError1("msg.incompat.call", f.GetFunctionName()); }
private Rhino.BaseFunction RealFunction(Scriptable thisObj, IdFunctionObject f) { object x = thisObj.GetDefaultValue(ScriptRuntime.FunctionClass); if (x is Delegator) { x = ((Delegator)x).GetDelegee(); } if (x is Rhino.BaseFunction) { return (Rhino.BaseFunction)x; } throw ScriptRuntime.TypeError1("msg.incompat.call", f.GetFunctionName()); }