Comments are closed

cJass on the Google Code.
Our BugTracker (recommend to post bugreports and features request there).
Beta tester notes.

all times are GMT +04:00
Latest posts

Pages: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

posted at 08/05/10 08:44
TigerCN

Some keywords are used frequenctly by us. Why do you make a highlight for them.Such as:
func new lambda class flush locals etc
Thanks for ADOLF.

posted at 08/05/10 08:36
TigerCN

I find a big bug!
When I use "enum" keyword and "flush locals" syntax at the same time, the compiler will be report error!For example:
enum (Hero) {MountainKing,ArchMage,Paldin,Blood}
void test() {
unit u = GetTriggerUnit()
int i
if (i == Paldin) {
......
}
flush locals
}
You know, when the code converts to general jass,it will become the follow:
function test takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer i
if (i == 2) then
......
endif
set trig = null//the error,where "trig" from? It hasn`t stated yet!
endfunction

posted at 29/04/10 10:05
TigerCN

1.Could you make zinc and cjass compatibleH

2.I can`t adapt to "#For(A,B)". Why don`t you use "for" loops like c program? For exampleF
void Test() {
int i;
for(i=0;i<=5;i++) {
BJDebugMsg(I2S(i));
}
}

3.Like other people say---use ":" to replace extends,like it:
interface Person {
......
}
struct Child : Person {
......
}

4.About closure functions. When in your cjass, it named "lambda", I feel it trouble. In zinc, it`s cool.
function Test() {
TimerStart(bj_lastStartedTimer,1,true,function() {
BJDebugMsg("Ok");
});
}
What`s more, in fact, it doesn`t suppot functions with parameter.Like that:
function interface Func takes unit u returns nothing
void Test() {
Func F = void lambda(){};
F.execute(GetTriggerUnit());
}

posted at 29/04/10 09:50
TigerCN

I`m a chinese, maybe my English is pool, but I`ll still express my point of view. To tell the truth, I like vjassAzinc and cjass. However, sometimers the compiler can`t compatible with zinc and cjass. I tend to use cjass.So I`ll give some suggestions.

posted at 28/04/10 06:47
Guest

Alas, it would be nice to be able to write structs inside of structs and link up internal struct instances or delink them.
I sort of did it with this-
but as you'll see, I cheated to a degree.

posted at 25/04/10 15:50
Troll-Brain

But we should know how many lines of code we can create with #for though.

posted at 25/04/10 15:48
Troll-Brain

Yes, i said it is a silly example.
So it's because the number of code lines, hmm.
Sounds good so, i was afraid that nested nested #for was not allowed.

posted at 25/04/10 15:13
Guest

        #for A (0, 7)
        
            #for B (0, 999)
                Grp[##A*1000+##B] = CreateGroup()
                
                #for C (0, 9)
                    GroupAddUnit(Grp[##A*1000+##B],u##C)
                #endfor
        
            #endfor
            TriggerSleepAction(0.)
            
        #endfor
Oh shi~, it's over 9000 80k lines... #for B (0, 99) saved succesful.

posted at 25/04/10 14:25
Troll-Brain

I don't know if it's because nested nested #for are not allowed or something else.
But when i remove the #for C it compiles correctly, else AdiHelper just fails and cJass is not converted at all.
I got an error with "private group array Grp", since in vJass it must be inside a "global" block.
Here is the code :
library Benchmark initializer OnInit requires UnitList
    ///////////////////////////////////////////////
    // Native declarations for stopwatch natives //
    //  - Requires no modified common.j import   //
    ///////////////////////////////////////////////
    native StopWatchCreate  takes nothing returns integer
    native StopWatchMark    takes integer stopwatch returns real
    native StopWatchDestroy takes integer stopwatch returns nothing
    
    /////////////////////////
    // Benchmarking script //
    /////////////////////////
    
    // Initialisation
    
    private group array Grp
    private UnitList array Unl
    private unit U
    private integer I = 0
    
    private nothing Init() {
        // things required to be performed once before your test
        integer i = 0
        #for A (0, 9)
            unit u##A = CreateUnit(GetLocalPlayer(),'hfoo',0.,0.,0.)
        #endfor
        U = CreateUnit(GetLocalPlayer(),'hfoo',0.,0.,0.)
        
        
        #for A (0, 7)
        
            #for B (0, 999)
                Grp[##A*1000+##B] = CreateGroup()
                
                #for C (0, 9)
                    GroupAddUnit(Grp[##A*1000+##B],u##C)
                #endfor
        
            #endfor
            TriggerSleepAction(0.)
            
        #endfor
        
        #for A (0, 7)
        
            #for B (0, 999)
                Unl[##A*1000+##B] = UnitList.create()
                

                
            #endfor
            TriggerSleepAction(0.)
            
        #endfor

        BJDebugMsg("init done")
    }
Yes i know it's silly i would just use a loop and instead of this ugly TSA, split the loop with some .evaluate/execute.
It was mostly a #for test.

posted at 23/04/10 20:59
Troll-Brain

And it's supposed to null all types that extends an handle ?
Some doesn't need to be null, since they can't be created, nor destroyed, like "player", "race", "alliance type", and so one.
And even "trackable", since we can't destroy a trackable.
For my problems, i will gave you a link to download test maps, since i don't have your e-mail.

posted at 23/04/10 18:09
ADOLF

1.4.2.12

Added flush locals instruction. Why you need it? Good question.
  • you do not need to memorize the names of all variables
  • you do not need to remember the values of variables (cJass will try to analyze the code)
  • code will be readable
  • if you're after writing a function to add one more variable - you do not have to go all returns that would null it (hm...)
minus of this method is that you can get a few extra set NAME = null
OK, now examples:
bool fx () {
    unit u = GetTriggerUnit ()
    if (GetWidgetLife(u)<100.) {
        flush locals
        return false
    }

    timer t = CreateTimer ()
    // ...
    flush locals
    return false
}

// --->

function fx takes nothing returns bool
    local unit u=GetTriggerUnit()
    local timer t
    if (GetWidgetLife(u)<100.) then
        set u=null // t is null
        return false
    endif

    set t=CreateTimer()
    // ...
    set t=null
    set u=null
    return false
endfunction
nothing fx () {
    unit a = null
    unit b
    flush locals
}

// --->

function fx takes nothing returns nothing
    local unit a=null
    local unit b
    // cJass knows that both variables are empty - 
    // they do not need to set it to null
endfunction
nothing fx () {
    unit a = GetTriggerUnit()
    unit b
    if (b) {
        b = CreateUnit(...)
        a = null
    }
    flush locals
}

// --->

function fx takes nothing returns nothing
    local unit a=GetTriggerUnit()
    local unit b
    if (b) then
        set b=CreateUnit(...)
        set a=null
    endif
    set b=null
    set a=null
    // cJass not know whether that condition,
    // so erases all variables that can contain a value
endfunction

posted at 22/04/10 16:36
ADOLF

1.4.2.11

Added #for and #repeat preprocessor loops.
#repeat:
nothing fx () {
    #repeat 2
        DoNothing()
    #endrepeat
}

// --->

function fx takes nothing returns nothing
    call DoNothing()
    call DoNothing()
endfunction
#for:
#define memset (ARR_NAME, VAL) = {
    #for i (0, 8191)
        ARR_NAME[i] = VAL
    #endfor
}

#define memset (ARR_NAME, VAL, SIZE) = {
    #for i (0, SIZE)
        ARR_NAME[i] = VAL
    #endfor
}


integer arr[]

nothing fx () {
    memset(arr, 0, 127)
}

// --->

function fx takes nothing returns nothing
    set arr[0]=0
    set arr[1]=0
    set arr[2]=0
    set arr[3]=0
    set arr[4]=0
    // ...
    set arr[125]=0
    set arr[126]=0
    set arr[127]=0
endfunction
Nested #for:
#for A (0, 9)
    #for B (0, 9)
        unit ux_##A##B []
    #endfor
#endfor

// --->

globals
    unit array ux_00
    unit array ux_01
    unit array ux_02
    unit array ux_03
    unit array ux_04
    unit array ux_05
    unit array ux_06
    unit array ux_07
    unit array ux_08
    unit array ux_09
    unit array ux_10
    unit array ux_11
    unit array ux_12
    // ...
    unit array ux_96
    unit array ux_97
    unit array ux_98
    unit array ux_99
endglobals

I bring up, yet made preprocessor loops, and then'll do the rest

posted at 11/04/10 15:55
Troll-Brain

Oh well, the last post was from me

posted at 11/04/10 14:59
Guest

@Adolph :
The link i gave have optional textmacros, take a better look.
And AdicHelper converts them in that :
local optional RunAutoEvent("Resurrect")
local optional RunAutoEvent("AnimateDead")
local optional RunAutoEvent("Death")
""
You want preprocessor loop?
Specifically for?
#for (0 < NAME < 10)
// ...
#endfor
"
I want copy X times a same code, useful for benchmarks at very least.
For my define problem, what will help you to find why it doesn't work, send the map, or the war3map.j is enough ?

posted at 11/04/10 14:25
DarkDragon

looking forward to next version of cjass ;)

posted at 11/04/10 10:20
Guest

Well...
#while
#void hi() (methods)
#int
#string
#object (object editor data)
#printf (for printing lines of code)
#struct
Those would be some great things =). In essence, all cJASS features have preprocessor directives too = ).
Oh and don't forget all of this-
: instead of extends
struct is struct : []
class is struct
normal properties with getters/setters instead of crazy operators
inline keyword
change the type of this for structs using : on methods and or the struct. Structs extending other structs auto inherit the changed pointer type. For example-
inline  public string name : player {
    get {
        return GetPlayerName(this)
    }
}

or

inline struct player : player {
    public string name {
        get {
            return GetPlayerName(this)
        }
    }
}

printf(Player(0).name)
~ instead of lambda
~{} for ~void { } in anonymous functions or onInit functions
constructors and destructors that work with new and delete and also able to use thistype for the name instead of the struct/class name-
struct Hi {
public thistype(args) {
}

public ~thistype(args) {
}
}

delete new Hi()
Next and Previous properties that allow foreach to be used and allow dif types of foreach in the same scope (struct, class, or otherwise).
for
And ofc the other stuff that was already planned ; P.

posted at 10/04/10 11:06
Sebra

// this work too
#if (SomeCondition)
    if (i==0x00) then
#else
    if (myBolean) then
#endif
        // ...
    else
        // ...
    endif
#for? Yes
#for (0 < P < 10)
    TriggerRegisterPlayerEvent(t,Player(P),e)
#endfor
Adolf, I miss you :)

posted at 10/04/10 00:32
ADOLF

Nestharus, to downloading files for include from net, you could write a plugin... It should download the file to hard disk, and return an #include "filename" (or #error "cannot download file filename")
_______________________________________
There's a lot written about the features for structures, but the problem is that: now sJass not process types, so there is nothing to do cannot.
_______________________________________
About the functions that run at start - it's a good idea, and I'll try to do it.
_______________________________________
All blocks in the construction of #if must be closed. You can do so:
// this does not work
#if (SomeCondition)
    if (i==0x00) {
#else
    if (myBolean) {
#endif

// it work
#define cond = myBolean
#if (SomeCondition)
    #setdef cond = i==0x00
#endif
if (cond) {
_______________________________________
I also think adding the ternary operator, array initialization.
a=b=c=null - never)
_______________________________________
Maybe you already know it but AdicParser fail with vJass textmacro optional.
Example of code :
www.wc3c.net/showpost.php?p=1080333&postcount=1
Maybe something I did not understand, but the link in the code is no macro and he successfully saved.
Optional macros are supported.
_______________________________________
You want preprocessor loop? Specifically for?
#for (0 < NAME < 10)
    // ...
#endfor
_______________________________________

posted at 08/04/10 04:46
Guest

Built definitions don't work : |
define private <Count.Player.get> = bj_MAX_PLAYER_SLOTS
define private <Count.Team.get> = 90
    define private <D2.Player.get>(ID_1, ID_2) = ID_1*Count.Player.get+ID_2
    define private <D2.Team.get>(ID_1, ID_2) = ID_1*Count.Team.get+ID_2
define private <Alliance.ini>(TYPE, REF) = TYPE##AllianceP[REF1].last = D2.TYPE.get(Count.TYPE.get, REF)
It never will work, coz cJass first verify "D2.TYPE.get" to "D2.Team.get", and then insert the argument. Hmm...
#define private <Count.Player.get> = bj_MAX_PLAYER_SLOTS
#define private <Count.Team.get> = 90

define private <Alliance.ini>(TYPE, REF) = {
    #if (TYPE==Team)
        // ...
    #elseif (TYPE==Player)
        // ...
    #else
        #error "-_-"
    #endif
}
~ADOLF

posted at 05/04/10 21:03
Troll-Brain

Well, my big apolgizes for the last script there are many errors.
This works :
library UnitIndexer{

    module init{
    
        private nothing onInit() {
            region reg = CreateRegion();rect map = GetWorldBounds()
            RegionAddRect(reg,map);TriggerRegisterEnterRegion(CreateTrigger(),reg,Filter(function UnitIndexer.enterMap))
            RemoveRect(map);map=null
        }
    }
    
    struct UnitIndexer{
    
        private static unit U
    
        static integer getIndex(unit u){
            return GetUnitUserData(u)
        }
        
        private static boolean enterMap(){
            set U = GetFilterUnit()
            if GetUnitUserData(U) == 0 {
                SetUnitUserData(U,UnitIndexer.create())
            }
            return false
            
        }
        
        implement init
        
    }    
    
}
I'm still waiting for the define answer though.

posted at 05/04/10 14:07
Guest

Just realized that like you said there was a mistake but it still doesn't work though, i just forgote to replace AutoIndex before paste the code here :
library UnitIndexer{

    module init{
        region reg = CreateRegion();map = GetWorldBounds()
        RegionAddRect(reg,map);TriggerRegisterEnterRegion(CreateTrigger(),reg,Filter(UnitIndexer.enterMap))
        RemoveRect(map);map=null
    }
    
    struct UnitIndexer{
    
        private static unit U
    
        static integer getIndex(unit u){
            return GetUnitUserData(u)
        }
        
        private static nothing enterMap(){
            set U = GetFilterUnit()
            if GetUnitUserData(U) == 0 {
                call SetUnitUserData(U,UnitIndexer.create())
            }
            
        }
        
        implement init
        
    }    
    
}

posted at 05/04/10 13:15
Guest

The code is not finished and doesn't supposed to be public, i just rewrite an existing library AutoIndex, because i hate the new version.
Anyway there are not any syntax error, right ?

posted at 04/04/10 23:11
Artte[xgm]

omg, what are u doing?
i can't check code - where is AutoIndex struct's description?
but i think it is better just use hashtables. Obly one action, no structs, bo librarys. One trigger-one action =)

posted at 04/04/10 22:25
Troll-Brain

Oh well, sorry but your compiler seems a complete mess, each time i try to use it i got errors.
This doesn't work :

library UnitIndexer{

    module init{
        region reg = CreateRegion();map = GetWorldBounds()
        RegionAddRect(reg,map);TriggerRegisterEnterRegion(CreateTrigger(),reg,Filter(UnitIndexer.enterMap))
        RemoveRect(map);map=null
    }
    
    struct UnitIndexer{
    
        private static unit U
    
        static integer getIndex(unit u){
            return GetUnitUserData(u)
        }
        
        private static nothing enterMap(){
            set U = GetFilterUnit()
            if GetUnitUserData(U) == 0 {
                call SetUnitUserData(U,AutoIndex.create())
            }
            
        }
        
        implement init
        
    }    
    
}
And sorry if it is my fault, but i don't think so.
region reg = CreateRegion();map = GetWorldBounds()
If you want declare two region variables you may use comma. Your code looks like
  local region reg = // ...
  set map = // ...
void ini () {
    implement init
}

//---------------------
// or
//---------------------

module m {
    void init () {}
}

// ...

implement m
Or I misunderstood something?
~ADOLF

Pages: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

[back to top]