| 04-16-2007, 12:58 AM | #1 |
I've been reading the JASSHelper tutorial so I can do my spells using this system. But I'm intrigued about what is behind the structs. I mean, as far as I know, the structs are converted internally into normal jass code, so... how is it managed?? how the code is converted in order to understand the structs?? does it use game cache internally?? if we have a struct like this: JASS:
struct point
real x=0.0
real y=0.0
method move takes real tx, real ty returns nothing
set this.x=tx
set this.y=ty
endmethod
endstructHow would it look internally in the map?? |
| 04-16-2007, 01:13 AM | #2 |
It looks like this: JASS://JASSHelper struct globals: integer si__point_I=0 integer si__point_N=0 integer array si__point_V boolean array si__point_active real array s__point_x real array s__point_y endglobals //Generated allocator of point function s__point__allocate takes nothing returns integer local integer this if (si__point_N==0) then set si__point_I=si__point_I+1 set this=si__point_I if (this>8190) then return 0 endif else set this=si__point_V[si__point_N] set si__point_N=si__point_N-1 endif set s__point_x[this]=0.0 set s__point_y[this]=0.0 set si__point_active[this]=true return this endfunction //Generated destructor of point function s__point_destroy takes integer this returns nothing if this==null then return elseif not(si__point_active[this]) then return endif set si__point_N=si__point_N+1 set si__point_V[si__point_N]=this set si__point_active[this]=false endfunction function s__point_move takes integer this,real tx,real ty returns nothing set s__point_x[this]=tx set s__point_y[this]=ty endfunction If you want to see what the code looks like after JassHelper compiles it, extract the war3map.j file from the map and look it over. Or you can do what I do and create a trigger with an incorrect name so that when it compiles it gives an error and I can browse through the code in the little error window. |
| 04-16-2007, 01:28 AM | #3 |
I see... for every component in the struct it is generated an array to store that data. Thanks for your help wantok :) |
| 04-16-2007, 12:10 PM | #4 |
well but if wrote (it was the past year) what i am using a lot of custom arrays + vars = it was a bad kind of coding... =) but now... suckers ! |
| 04-16-2007, 12:44 PM | #5 |
If you leave a syntax error in your main maps script section, when the box pops up, the code you see is the code after the parser has converted it, so you could take a look and see whats what xD. |
| 04-16-2007, 01:10 PM | #6 | ||
Quote:
Quote:
I was checking the code again and now I understand why it's not offered the possibility to manage arrays inside the structs. It's quite complicated to do it. |
| 04-16-2007, 01:27 PM | #7 | |||
Quote:
Quote:
Nobody does. Quote:
What are you talking about? |
| 04-16-2007, 01:58 PM | #8 |
I had this idea: JASS:struct Matrix integer i=0 integer j=0 real array m // And the methods goes here... endstruct I developed a structure like this for a project at the university in VB to make matrix calculations. I was thinking in developing a matrix library to manage splines. And I wanted to know if it was possible and, if so, if it was efficient enough. |
| 04-16-2007, 02:26 PM | #9 | ||
Quote:
Quote:
btw... it could be the next extension for vJass (dynamic arrays inside of structures !) this would be cool (ofc if performance is not needed...) i already know some ways to do this... |
| 04-16-2007, 02:32 PM | #10 |
I just use linked lists as arrays inside structs... but its slow. |
| 04-16-2007, 02:40 PM | #11 | |
huh? JASS:
struct Matrix
integer i=0
integer j=0
real array m [5]
// And the methods goes here...
endstructQuote:
|
| 04-16-2007, 03:07 PM | #12 | ||
Quote:
Quote:
|
| 04-16-2007, 03:17 PM | #13 |
hmm structs is nothing different from the old object orientated array method. Only different is that it makes the code looks cleaner, and u can therefore put more into it without worry it will be messy and looks ugly. |
| 04-16-2007, 04:07 PM | #14 |
There is a huge difference between prefix and suffix notation. like (+ 1 (* 4 3)) vs. 1+4*3 |
