mildew.types.func

This module implements the ScriptFunction class, which holds script defined functions as well as native D functions or delegates with the correct signature.

────────────────────────────────────────────────────────────────────────────────

Copyright (C) 2021 pillager86.rf.gd

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Members

Aliases

NativeDelegate
alias NativeDelegate = ScriptAny delegate(Environment, ScriptAny* thisObj, ScriptAny[] args, ref NativeFunctionError)

native delegate signature to be usable by scripting language

NativeFunction
alias NativeFunction = ScriptAny function(Environment, ScriptAny* thisObj, ScriptAny[] args, ref NativeFunctionError)

native function signature to be usable by scripting language

Classes

ScriptFunction
class ScriptFunction

This class encapsulates all types of script functions including native D functions and delegates. A native function must first be wrapped in this class before it can be given to a ScriptAny assignment. When an object is created with "new FunctionName()" its __proto__ is assigned to the function's "prototype" field. This allows OOP in the scripting language and is analogous to JavaScript.

Enums

NativeFunctionError
enum NativeFunctionError

When a native function or delegate encounters an error with the arguments sent, the last reference parameter should be set to the appropriate enum value. A specific exception can be thrown by setting the flag to RETURN_VALUE_IS_EXCEPTION and returning a string. If an exception is thrown directly inside a native function, the user will not be able to see a traceback of the script source code lines where the error occurred.

Meta