- Joined
- Nov 7, 2014
- Messages
- 571
Using the
ExecuteFunc
native one can get around vJass's privacy enforcement for calling functions/methods that do not take arguments (this is an ExecuteFunc
limitation):
JASS:
library Foo
function call_Bars_functions takes nothing returns nothing
local string PRIVACY_UNDERSCORES = SubString(SCOPE_PRIVATE, StringLength("Foo"), StringLength(SCOPE_PRIVATE))
call ExecuteFunc("Bar" + PRIVACY_UNDERSCORES + "private_function")
call ExecuteFunc("Bar_public_function")
call ExecuteFunc("global_namespace_function")
endfunction
function call_Bazs_private_methods takes nothing returns nothing
call ExecuteFunc("s__Baz_onInit")
call ExecuteFunc("s__Baz_private_method")
endfunction
function call_Quxs_private_methods takes nothing returns nothing
// because Qux is a private struct, we have to find out the number of underscores jasshelper used for privacy
// it can be either 2 or 3
local string PRIVACY_UNDERSCORES = SubString(SCOPE_PRIVATE, StringLength("Foo"), StringLength(SCOPE_PRIVATE))
call ExecuteFunc("s__Bar" + PRIVACY_UNDERSCORES + "Qux_onInit")
call ExecuteFunc("s__Bar" + PRIVACY_UNDERSCORES + "Qux_private_method")
endfunction
endlibrary
library Bar requires Foo
private function private_function takes nothing returns nothing
call BJDebugMsg("private function Bar.private_function called")
endfunction
public function public_function takes nothing returns nothing
call BJDebugMsg("public function Bar.public_function called")
endfunction
function global_namespace_function takes nothing returns nothing
call BJDebugMsg("global_namespace_function defined in Bar called")
endfunction
struct Baz extends array
private static method onInit takes nothing returns nothing
call BJDebugMsg("private static Baz.onInit called")
endmethod
private static method private_method takes nothing returns nothing
call BJDebugMsg("private static Baz.private_method called")
endmethod
endstruct
private struct Qux extends array
private static method onInit takes nothing returns nothing
call BJDebugMsg("private static Qux.onInit called")
endmethod
private static method private_method takes nothing returns nothing
call BJDebugMsg("private static Qux.private_method called")
endmethod
endstruct
endlibrary
//! inject main
call call_Bars_functions()
call call_Bazs_private_methods()
call call_Quxs_private_methods()
call BJDebugMsg(" ")
call BJDebugMsg("vJass will now call the onInit method of each struct:")
//! dovjassinit
//! endinject