ExecuteFunc'ing static methods

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Hm... Maybe I've asked this one before but anyway:

How to use the ExecuteFunc native which takes a string, i.e function/static method's name to "execute" a static method?

JASS:
struct STRUCT

    static method FUNCY takes nothing returns nothing
        call BJDebugMsg("If instead of ")
        call BJDebugMsg("ExecuteFunc, .evaluate()")
        call BJDebugMsg("or .execute()")
        call BJDebugMsg("are used then")
        call BJDebugMsg("this will be copied in")
        call BJDebugMsg("another function")
        call BJDebugMsg("the problem is that")
        call BJDebugMsg("the static method is quite long")
        call BJDebugMsg("I can't believe I actually wrote that =)")        
    endmethod

    static method onInit takes nothing returns nothing
        //call FUNCY.evaluate()
        //call FUNCY.execute()
        call ExecuteFunc(????)
        call ExecuteFunc("s__STRUCT_FUNCY") // works but ... it's "way too hacky"
        call ExecuteFunc("s__LIBRARY___STRUCT_FUNCY") // even worse if the struct is private
    endmethod

endstruct
 

Bribe

vJass errors are legion
Reaction score
67
.name generates the same prototype functions that .execute does. Either don't use structs with ExecuteFunc, or use .execute.

Cohadar may update JassHelper to not compile the prototype functions for things like this, but until then, I recommend if you have a situation that requires ".name", to use .execute or TriggerExecute instead.
 

luorax

Invasion in Duskwood
Reaction score
67
.name generates the same prototype functions that .execute does. Either don't use structs with ExecuteFunc, or use .execute.

lol? Didn't know 'bout that. Doesn't make too much sense, but hell, nothing does that has anything to do with JH.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
This is peculiar. And well in that case [ljass] call ExecuteFunc("s__<struct_name>_<static_method_name>")[/ljass] and [ljass] call ExecuteFunc("s__<library>___<struct_name>_<static_method_name>")[/ljass] suddenly seam "reasonable".
 

Bribe

vJass errors are legion
Reaction score
67
Keep in mind, private members are either two or three underscores, because JassHelper randomizes it.

But yeah, I usually avoid ExecuteFunc'ing static methods and when I need to ExecuteFunc a "private" function I just make the function prefixed with something, like Private_LibraryName_FunctionName or something. I avoid the string "SCOPE_PRIVATE" because when you use concatenation and then "shorten names" on Vexorian's optimizer, you get a fail.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top