Wc3C.net

Wc3C.net (http://www.wc3c.net/forums.php)
-   Warcraft Editing Tools (http://www.wc3c.net/forumdisplay.php?f=13)
-   -   JassHelper 0.A.2.B - A vJass and Zinc 2 Jass compiler (http://www.wc3c.net/showthread.php?t=88142)

Jazradel 03-05-2008 05:17 AM

I would like a keyword that allows me to implement a library in mine, so I have access to its private functions and public functions without needing a prefix.

Something like:
Quote:

library CoreSystem
private function f //...
endlibrary

library CoreExtension implements CoreSystem
//...
call f
//...
endfunction
endlibrary
It would just allow me neaten up/modularize several things.

Also on top of my wish list for initializers for scopes so they're not tied to trigger names anymore. public function InitTrig... is very lame.

I'd also like For(i to n) and For(unit in group) syntax.

Also on my wish list is function syntax more like java/c++, local declaration freedom, optional endline and merge line syntax, no need for set/call and the ability to go u.GetX() instead of GetUnitX(). But the chance of you implementing most of those is about zero.

DiscipleOfLife 03-05-2008 12:00 PM

I found a bug in 0.9.9.7 (havent tried with 0.9.9.8).
I have an empty map with nothing in it except for this:
Collapse JASS:
struct a
    // doesnt matter what is here
endstruct

struct b extends a
    // doesnt matter what is here either
endstruct

I get an "undeclared variable f__arg_this" error in function sc__a_destroy, and infact there is no f__arg_this variable in the globals block:
Collapse JASS:
globals
    // Generated
    trigger                 gg_trg_Buggy               = null


//JASSHelper struct globals:
constant integer si__a=1
integer si__a_F=0
integer si__a_I=0
integer array si__a_V
constant integer si__b=2
integer array si__a_type
trigger array st__a_onDestroy

endglobals

//Generated allocator of a
function s__a__allocate takes nothing returns integer
 local integer this=si__a_F
    if (this!=0) then
        set si__a_F=si__a_V[this]
    else
        set si__a_I=si__a_I+1
        set this=si__a_I
    endif
    if (this>8190) then
        return 0
    endif

    set si__a_V[this]=-1
 return this
endfunction

//Generated destructor of a
function sc__a_destroy takes integer this returns nothing
    if this==null then
        return
    elseif (si__a_V[this]!=-1) then
        return
    endif
    set f__arg_this=this
    call TriggerEvaluate(st__a_onDestroy[si__a_type[this]])
    set si__a_V[this]=si__a_F
    set si__a_F=this
endfunction

//Generated allocator of b
function s__b__allocate takes nothing returns integer
 local integer this=s__a__allocate()
 local integer kthis
    if(this==0) then
        return 0
    endif
    set si__a_type[this]=2
    set kthis=this

 return this
endfunction


//===========================================================================
// 
// Just another Warcraft III map
//...
The problem goes away if struct b is commented out or if there is a third struct in the map which has an onDestroy method, or if struct a has an onDestroy method.


I also have a suggestion: ability to declare globals like this anywhere: global integer example = 2. When I say anywhere I mean in functions also. Maybe they could also have private and public keywords - as in relation to the functions they are in.

I have a more useful suggestion too: ability to initialize boolexprs in global blocks like this:
Collapse JASS:
globals
    boolexpr myExpr = initializeboolexpr(function SomeFunctionAnywhereInTheMapScript)
endglobals
What it would do is just call Filter(function ...) in some initialization trigger and ofc before that move the desired function above that Filter() call.

Vexorian 03-05-2008 01:38 PM

Quote:

so I have access to its private functions and public functions without needing a prefix.

That's hard right now, perhaps with the next compilrer, if it happens though I would not allow private usage.

Quote:

I'd also like For(i to n) and For(unit in group) syntax.
definitely not For, but for, and I will not ever implement for(unit in group) since it would be like promoting the usage of unit groups.


Quote:

Also on top of my wish list for initializers for scopes so they're not tied to trigger names anymore. public function InitTrig... is very lame.

Use a library. Next version I am going to add requires * or something like that to libraries.

Vexorian 03-05-2008 01:41 PM

Quote:

Also on my wish list is function syntax more like java/c++, local declaration freedom, optional endline and merge line syntax, no need for set/call and the ability to go u.GetX() instead of GetUnitX(). But the chance of you implementing most of those is about zero.
Declaration freedom is uninmplementable in Jass. optional endline maybe, I would like to once implement wrapper stuff to handles, and it would be u.x instead of u.GetX.

Quote:

I also have a suggestion: ability to declare globals like this anywhere:
I like scopes as a solution for this.

Jazradel 03-06-2008 05:29 AM

I was just capitalizing for to make it stand out. Fair enough about the for(unit in group) thing.

Quote:

Next version I am going to add requires * or something like that to libraries.
I don't get this.

Using a library is a pain because of all the other libraries I'm using. It means each needs a giant list of requirements. Unless I have a special library whose only purpose is to require other stuff ... which I might actually do. It's still lame.

How is declaration freedom unimplementable? Just place it at the top of the trigger, and change the declaration to a set. Maybe you misunderstood what I meant, I just want my triggers to be slightly neater.

Like the sound of the u.x stuff, much better than u.GetX

Vexorian 03-07-2008 12:00 AM

Quote:

Using a library is a pain because of all the other libraries I'm using
That's what requires * would do.


Quote:

How is declaration freedom unimplementable? Just place it at the top of the trigger, and change the declaration to a set.
That would be totally pointless and not declaration freedom.

Jazradel 03-07-2008 06:22 AM

So requires * would make it require all other libraries (be placed at the bottom in other words)?

local declaration maybe mostly pointless, but it would neaten up my code and make my life a tiny bit easier..

With the u.x stuff, will it be u.x() or u.x? It might not be clear to people they are actually calling a function without the ().

Strilanc 03-07-2008 02:47 PM

A quick request: one-line if statements. I'm tired of needing 3 lines for simple checks.

Collapse JASS:
if conditions then action
translates to
Collapse JASS:
if conditions then
   action
endif

Vexorian 03-07-2008 03:37 PM

Quote:

With the u.x stuff, will it be u.x() or u.x? It might not be clear to people they are actually calling a function without the ().

set u.x = 2.3
becomes call SetUnitX(u,2.3)
call BJDebugMsg(R2S(u.x))
becomes call BJDebugMsg(R2S(GetUnitX(u) ))

cohadar 03-08-2008 01:06 AM

How about a copy constructor?

Jazradel 03-08-2008 07:59 AM

IMO it should be u.x() to differentiate between methods/data.

Vexorian 03-08-2008 11:03 AM

unit's x is data.

I don't really have time to make the wrapper library myself, I will just leave the ability to make that stuff, let someone else decide that stuff.

DiscipleOfLife 03-11-2008 03:25 PM

Suggestion: function interface_once
This would naturally have the same effect for function interfaces as library_once has for libraries.

EDIT: ...as long as all function interface_onces with the same name are identical. In other words:
Collapse JASS:
function interface_once actionfunc takes nothing returns nothing
//...
function interface_once actionfunc takes nothing returns nothing // Works
but on the other hand:
Collapse JASS:
function interface_once actionfunc takes nothing returns nothing
//...
function interface_once actionfunc takes unit u returns nothing // Makes the compiler sad :(

SoulReaping 03-11-2008 06:43 PM

Suggestion:
Adding if statement to textmacro.
Example:
Collapse JASS:
library SomeLibrary
//! textmacro ATextMacro takes ARG1, ARG2
//! if not ARG1 == "hello" then
function $ARG1$ takes $ARG2$ a returns nothing
//....
endfunction
//! else
function KKK takes $ARG2$ $ARG1$ returns nothing
//...
endfunction
//! endif
//! endtextmacro

//! runtextmacro ATextMacro("hello", "integer")
//! runtextmacro ATextMacro("tralala", "boolean")

I'm sure it will be useful if implemented for some systems I know.

Strilanc 03-12-2008 05:36 PM

A small bug with how destroy is handled:

Destroy is always, always placed above the onDestroy method, meaning the 'TriggerEvaluate' calling convention is used when onDestroy is called. Not a huge problem, but it does slow down destroy calls a lot.

onDestroy is almost never called by other struct code, so placing it above destroy makes more sense.


All times are GMT. The time now is 06:57 AM.

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services