Catspeak Reference


struct CatspeakForeignInterface

function CatspeakForeignInterface() constructor { 
  // 3 fields omitted
}

Used by Catspeak code generators to expose foreign GML functions, constants, and properties to the generated Catspeak programs.

§ addBanList

static addBanList = function(
  ban : String,
)

Bans an array of symbols from being used by this interface. Any symbols in this list will be treated as though they do not exist. To unban a set of symbols, you should use the addPardonList method.

If a symbol was previously banned, this function will have no effect.

Arguments

  • ban

    The symbol to ban the usage of from within Catspeak.

§ addPardonList

static addPardonList = function(
  pardon : String,
)

Pardons an array of symbols within this interface.

If a symbol was not previously banned by addBanList, there will be no effect.

Arguments

  • pardon

    The symbol to pardon the usage of from within Catspeak.

§ exists

static exists = function(
  name : String,
) -> Bool

Returns whether a foreign symbol is exposed to this interface.

Arguments

  • name

    The name of the symbol as it appears in Catspeak.

Returns Bool

§ exposeAsset

static exposeAsset = function(
  name : String,
)

Exposes a GameMaker asset from the resource tree to this interface.

Arguments

  • name

    The name of the GM asset that you wish to expose to Catspeak.

§ exposeAssetByTag

static exposeAssetByTag = function(
  tag : Any,
)

Exposes a set of tagged GameMaker assets to this interface.

Arguments

  • tag

    The name of a tag, or array of tags, of assets to expose to Catspeak.

§ exposeConstant

static exposeConstant = function(
  name : String,
  value : Any,
)

Exposes a constant value to this interface.

📝 Note

You cannot expose GML functions using this method. Instead you should use one of exposeDynamicConstant, exposeFunction, or exposeMethod.

Arguments

  • name

    The name of the constant as it will appear in Catspeak.

  • value

    The constant value to add.

§ exposeDynamicConstant

static exposeDynamicConstant = function(
  name : String,
  func : Function,
)
🔬 This is an experimental feature. It may change at any moment.

Exposes a "dynamic constant" to this interface. The value provided for the constant should be a script or method. When the dynamic constant is evaluated at runtime, the method will be executed with zero arguments and the return value used as the value of the constant.

Arguments

  • name

    The name of the constant as it will appear in Catspeak.

  • func

    The script ID or function to add.

§ exposeFunction

static exposeFunction = function(
  name : String,
  func : Function,
)

Exposes a new unbound function to this interface. When passed a bound method (i.e. a non-global function), it will be unbound before it is added to the interface.

📝 Note

If you would prefer to keep the bound self of a method, you should use the exposeMethod method instead.

Arguments

  • name

    The name of the function as it will appear in Catspeak.

  • func

    The script ID or function to add.

§ exposeFunctionByName

static exposeFunctionByName = function(
  func : Function,
)

Behaves similarly to exposeFunction, except the name of definition is inferred. There are three ways this name will be inferred:

  • If the value is a script resource, script_get_name is used.

  • If the value is a method and a name field exists, then the value of this name field will be used as the name.

  • If the value is a method and a name field does not exist, then script_get_name will be called on the underlying bound script resource.

📝 Note

If you would prefer to keep the bound self of a method, you should use the exposeMethodByName method instead.

Arguments

  • func

    The script ID or function to add.

§ exposeFunctionByPrefix

static exposeFunctionByPrefix = function(
  namespace : String,
)

Exposes many user-defined global GML functions to this interface which share a common prefix.

Arguments

  • namespace

    The common prefix for the set of functions you want to expose to Catspeak.

§ exposeMethod

static exposeMethod = function(
  name : String,
  func : Function,
)

Exposes a new bound function to this interface.

📝 Note

If you would prefer to ignore the bound self value of the function, and treat it as a global script, you should use the exposeFunction method instead.

Arguments

  • name

    The name of the method as it will appear in Catspeak.

  • func

    The script ID or method to add.

§ exposeMethodByName

static exposeMethodByName = function(
  func : Function,
)

Behaves similarly to exposeMethod, except the name of definition is inferred. There are three ways a name will be inferred:

  • If the value is a script resource, script_get_name is used.

  • If the value is a method and a name field exists, then the value of this name field will be used as the name.

  • If the value is a method and a name field does not exist, then script_get_name will be called on the underlying bound script resource.

📝 Note

If you would prefer to ignore the bound self value of the function, and treat it as a global script, you should use the exposeFunctionByName method instead.

Arguments

  • func

    The script ID or method to add.

§ get

static get = function(
  name : String,
) -> Any

Returns the value of a foreign symbol exposed to this interface.

Arguments

  • name

    The name of the symbol as it appears in Catspeak.

Returns Any

§ isDynamicConstant

static isDynamicConstant = function(
  name : String,
) -> Bool
🔬 This is an experimental feature. It may change at any moment.

Returns whether the foreign symbol is a "dynamic constant". If the symbol hasn't been added then this function returns false.

Arguments

  • name

    The name of the symbol as it appears in Catspeak.

Returns Bool