HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

TypeConverter

06-10-2009, 03:01 AM#1
ToukoAozaki
With return-bug cast deprecated, and blizzard not supporting explicit cast, widget event responses became difficult to use. This library is designed to deal with such problem by using hashtable as a converter medium.

This script requires 1.23b or later.

Expand JASS:
06-10-2009, 03:07 AM#2
Rising_Dusk
You know, I'm pretty sure this exact typecasting is the whole thing Blizzard is trying to remove with this patch.
06-10-2009, 03:19 AM#3
ToukoAozaki
Quote:
Originally Posted by Rising_Dusk
You know, I'm pretty sure this exact typecasting is the whole thing Blizzard is trying to remove with this patch.

This is not an unsafe typecast. unit, item and destructable are child type of widgets. Almost every language that support upcast also support downcast, and every language should. However, Jass2 never had capability to downcast while upcast has been possible.

Also note that there is a Blizzard safety layer on the hashtable. This library is not bypassing it; that behavior is by design. Blizzard uses internal type metadata, not the type when the handle is stored. If the widget is not an item then WidgetToItem will return null.
06-10-2009, 05:02 AM#4
Rising_Dusk
I see. Anyways, I don't like your function names; might I suggest W2I, W2U, and W2D?
06-10-2009, 05:05 AM#5
Vexorian
I like these function names, W2U, W2D and W2I sound like return bug exploiters.
06-10-2009, 05:06 PM#6
Troll-Brain
Wait, this one-line-return is considered as a return bug ?

Collapse common.j:
constant native GetTriggerWidget takes nothing returns widget

Collapse blizzard.j:
function GetDyingDestructable takes nothing returns destructable
    return GetTriggerWidget()
endfunction

I can't download the beta patch so i can't take a look in the new blizzard.j

If not, then this script is useless.
06-10-2009, 05:24 PM#7
ToukoAozaki
Quote:
Originally Posted by Troll-Brain
Wait, this one-line-return is considered as a return bug ?

Collapse common.j:
constant native GetTriggerWidget takes nothing returns widget

Collapse blizzard.j:
function GetDyingDestructable takes nothing returns destructable
    return GetTriggerWidget()
endfunction

I can't download the beta patch so i can't take a look in the new blizzard.j

If not, then this script is useless.

Collapse JASS:
function GetDyingDestructable takes nothing returns destructable
    return GetTriggerDestructable()
endfunction

This is their new implementation. Seems that they have added GetTriggerDestructable native.

However I am not sure whether this native returns properly for every widget events.
Practically conversion for destructable wouldn't be needed. However, I see no reason that they shouldn't exist as a set. What if one decides to use widget arrays or pass parameter as a widget...
06-10-2009, 10:50 PM#8
Vexorian
Approved BTW.
06-11-2009, 03:02 AM#9
Rising_Dusk
Quote:
Originally Posted by Vexorian
I like these function names, W2U, W2D and W2I sound like return bug exploiters.
I disagree, but okay.