How are function interfaces compiled?

Bribe

vJass errors are legion
Reaction score
67
If I have this:

JASS:
function interface myfunc takes nothing returns nothing


And this:

JASS:
globals
    myfunc array Funcs
endglobals


Does Funcs convert to a trigger array? How does it work internally?

Ideally, I want to check to see if an array slot has been assigned or not. Would I use:

JASS:
boolean b = Funcs[this] != null
//or...
boolean b = Funcs[this] != 0

?

Huge reputation for help, as I am unable to compile wc3 since I moved.
 

Bribe

vJass errors are legion
Reaction score
67
Integer? I guess it is paralleled by an invisible trigger array, then?

I have to rep some more people, first. You are too helpful, my good man.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
How are [INSERT ANYTHING HERE] compiled?

There are a ton of methods of finding that out. My personal favorite:

1-Download Jass Shop Pro.
2-Write the code you want to see compiled in a map. Compile it.
3-Open Jass Shop Pro.
4-Open your map in Jass Shop Pro to see the war3map.j file.
5-Win.
 

Ashlebede

New Member
Reaction score
43
JASS:
scope foobar initializer init
        function interface FUNCTION_INTERFACE takes unit u, trigger t returns integer
        
    private function foo takes unit u, trigger t returns integer
        return GetHandleId(u)
    endfunction
    
    private function bar takes unit u, trigger t returns integer
        return GetHandleId(t)
    endfunction

    private function init takes nothing returns nothing
        local FUNCTION_INTERFACE foo_interface = foo
        local FUNCTION_INTERFACE bar_interface = bar
    endfunction
endscope


Will become

JASS:
globals
//JASSHelper struct globals:
trigger array st___prototype3
integer f__result_integer
unit f__arg_unit1
trigger f__arg_trigger1

endglobals

function sc___prototype3_execute takes integer i,unit a1,trigger a2 returns nothing
    set f__arg_unit1=a1
    set f__arg_trigger1=a2

    call TriggerExecute(st___prototype3<i>)
endfunction
function sc___prototype3_evaluate takes integer i,unit a1,trigger a2 returns integer
    set f__arg_unit1=a1
    set f__arg_trigger1=a2

    call TriggerEvaluate(st___prototype3<i>)
 return f__result_integer
endfunction

// scope foobar begins
//processed:         function interface FUNCTION_INTERFACE takes unit u, trigger t returns integer
        
    function foobar___foo takes unit u,trigger t returns integer
        return GetHandleId(u)
    endfunction
    
    function foobar___bar takes unit u,trigger t returns integer
        return GetHandleId(t)
    endfunction

    function foobar___init takes nothing returns nothing
        local integer foo_interface= (1)
        local integer bar_interface= (2)
    endfunction
// scope foobar ends

//Struct method generated initializers/callers:
function sa___prototype3_foobar___foo takes nothing returns boolean
    set f__result_integer=foobar___foo(f__arg_unit1,f__arg_trigger1)
    return true
endfunction
function sa___prototype3_foobar___bar takes nothing returns boolean
    set f__result_integer=foobar___bar(f__arg_unit1,f__arg_trigger1)
    return true
endfunction

function jasshelper__initstructs22017840 takes nothing returns nothing
    set st___prototype3[1]=CreateTrigger()
    call TriggerAddAction(st___prototype3[1],function sa___prototype3_foobar___foo)
    call TriggerAddCondition(st___prototype3[1],Condition(function sa___prototype3_foobar___foo))
    set st___prototype3[2]=CreateTrigger()
    call TriggerAddAction(st___prototype3[2],function sa___prototype3_foobar___bar)
    call TriggerAddCondition(st___prototype3[2],Condition(function sa___prototype3_foobar___bar))


endfunction</i></i>


As you can see, this uses [ljass]TriggerExecute()[/ljass] & [ljass]TriggerEvaluate()[/ljass], so I'd say this ain't the best option, for performance. You might as well use [ljass]ExecuteFunc()[/ljass] and globals to pass values, since that is what is done here, and should be somewhat-faster.
 
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