Class Sanitizer

Provides methods that can sanitize function for a particular widget.

That includes all call-ins and any call that cross widget boundaries, due to proxy object or events. The sanitization itself means that various errors are reported through Logger.error and it causes the appropriate widget to fail.

Functions

Sanitizer.forCurrentWidget () Creates a sanitizer for a widget that is closest to this call in the call chain.
Sanitizer.forWidget (widget) Creates a sanitizer for the specified widget.
Sanitizer.ignore (f) Marks the specified function as not needing to be sanitized.
Sanitizer.sanitize (f) Sanitizes the specified function automatically.
Sanitizer.sanitizeWidget (widget) Sanitizes all function and call-ins of the widget.

Methods

Sanitizer:AsHandler (f) Alias to Sanitizer:Sanitize.
Sanitizer:Export (t) Exports a table, as in creates a copy of it, that when first passed through Sanitizer:Import is safe to use over widget boundaries.
Sanitizer:Import (foreign) Imports an object previously exported using Sanitizer:Export so that it can be safely used within the widget the Sanitizer was created for.
Sanitizer:Sanitize (f) Sanitizes the function.
Sanitizer:SanitizeWidget () Alias to Sanitizer.sanitizeWidget.


Functions

Sanitizer.forCurrentWidget ()
Creates a sanitizer for a widget that is closest to this call in the call chain.

Returns:

    Sanitizer the created sanitizer

See also:

Sanitizer.forWidget (widget)
Creates a sanitizer for the specified widget.

Parameters:

  • widget widget The widget for which to create the sanitizer.

Returns:

    Sanitizer the created sanitizer
Sanitizer.ignore (f)
Marks the specified function as not needing to be sanitized.

Parameters:

  • f func The function to ignore.

Returns:

    func The function f marked as sanitized.
Sanitizer.sanitize (f)
Sanitizes the specified function automatically. It uses the environment that we get through getfenv to find out which widget the function is coming from.

Remarks:

    When the sanitized enclosure is passed in as f, it is directly returned and does not enclose it again.

Parameters:

  • f func The function to sanitize.

Returns:

    func The sanitized eclosure of function f.
Sanitizer.sanitizeWidget (widget)
Sanitizes all function and call-ins of the widget. It makes sure that any errors generated by the widget are reported to Logger, as opposed to the standard error handling of SpringRTS's widget system.

Remarks:

    It should be called only after all other widget setup code gets executed, which usually means the end of the script.

Parameters:

  • widget widget The widget that should be sanitized.

Methods

Sanitizer:AsHandler (f)
Alias to Sanitizer:Sanitize.

Parameters:

Returns:

    See Sanitizer:Sanitize
Sanitizer:Export (t)
Exports a table, as in creates a copy of it, that when first passed through Sanitizer:Import is safe to use over widget boundaries. Useful when making interface objects.

Parameters:

  • t tab Table to be exported.

Returns:

    A so-called foreign copy of t.

Usage:

    WG.MyInterfaceObject = sanitizer:Export(MyInterfaceObject)
Sanitizer:Import (foreign)
Imports an object previously exported using Sanitizer:Export so that it can be safely used within the widget the Sanitizer was created for.

Parameters:

  • foreign A so-called foreign copy of an object created through a call to Sanitizer:Export (using a different Sanitizer instance)

Returns:

    Imported object with all of the methods and functionality (e.g. Sentry) of the previously exported object.

Usage:

     local MyInterfaceObject
     ...
     MyInterfaceObject = sanitizer:Import(WG.MyInterfaceObject)
Sanitizer:Sanitize (f)
Sanitizes the function.

Parameters:

  • f func The function to be sanitized

Returns:

    func The sanitized eclosure of function f.
Sanitizer:SanitizeWidget ()
Alias to Sanitizer.sanitizeWidget.
generated by LDoc 1.4.3 Last updated 2017-06-01 23:07:48