This site has been archived and made available for preservation purposes. No edits can be made.

MakePublic

(Difference between revisions)
Return to current revision
  1.  
    Makes a function public. A public function can be called from other scripts.
    [h="2"] Declaration [/h]
    [highlight=cpp]
  2. -
    VAULTSCRIPT vaultmp::Void (*MakePublic)(vaultmp::Function, vaultmp::String, vaultmp::String);
  3. +
    VAULTSCRIPT VAULTSPACE Void (*VAULTAPI(MakePublic))(VAULTSPACE RawFunction(), VAULTSPACE cRawString, VAULTSPACE cRawString) _CPP(noexcept);
    [/highlight]
    [highlight=c]
  4.  
    native MakePublic(const func{}, const name{}, const def{});
    [/highlight]
    [h="2"] Parameters [/h]
  5. -
    [b][wiki="Function"]vaultmp::Function[/wiki][/b] (C++ only) - the function
    [b]func[/b] (PAWN only) - the name of the function
    [b]name[/b] - the public name of the function (must be unique)
    [b]def[/b] - the parameter list of the function. This is a string containing a sequence of:
  6. +
    [b][wiki="Function"]Function[/wiki][/b] - the function
    [b][wiki]cRawString[/wiki][/b] - the public name of the function (must be unique)
    [b][wiki]cRawString[/wiki][/b] - the parameter list of the function. This is a string containing a sequence of:
  7.  
    [list][*]i - Integer (4 byte)
    [*]l - Long integer (8 byte)
    [*]f - Floating-point (8 byte)
    [*]p - Pointer (4 byte)
    [*]s - String (const char*)
    [/LIST]
    [h="2"] Return value [/h]
    None.
    [h="2"] Usage example (C++) [/h]
    [highlight=cpp]
  8. -
    vaultmp::Result VAULTSCRIPT MyPublic(unsigned int a, unsigned int b, const char* c)
  9. +
    Result VAULTSCRIPT MyPublic(unsigned int a, unsigned int b, const char* c)
  10.  
    {
    // Public function
  11. -
    return (a + b);
  12. +
    return static_cast<Result>(a + b);
  13.  
    }
  14. -
    vaultmp::Void VAULTSCRIPT exec()
  15. +
    Void VAULTSCRIPT exec() noexcept
  16.  
    {
  17. -
    MakePublic(reinterpret_cast<Function>(&MyPublic), "MagicFunction", "iis");
  18. +
    // C++ template version (type-safe, deduces type string)
    MakePublic(MyPublic, "MagicFunction");
  19.  
    }
    [/highlight]
    [h="2"] Usage example (PAWN) [/h]
    [highlight=c]
    forward MyPublic(a, b, const c{});
    public MyPublic(a, b, const c{})
    {
    // Public function
    return (a + b);
    }
    main()
    {
    MakePublic("MyPublic", "MagicFunction", "iis");
    }
    [/highlight]
    [h="2"] Related pages [/h]
    [list][*][wiki]CallPublic[/wiki]
    [/LIST]
    [category]VaultMP interface[/category]
    [category]Scripting functions[/category]
    [category]Misc functions[/category]