The auto-completion bug will be fixed in my next release.
About the ->.
The "." doesn't make sense for a pointer. You must first follow the pointer to the actual "instance", and then invoke the method on that. This is what the * is for. (*myClass).Print();.
a->b is just a quick way of writing (*a).b.
If you for instance made a double pointer (Class** myClass), you would need to use the *. ((**myClass).Print()), or ((*myClass)->Print())
In case you are unfamiliar with pointers, they are basically just references to another place in memory. In this other place in memory, you can create an object of your choosing. But if you want to call a method on that object, you need to specify that you want to call it on that object, and not on the pointer.
I know that I could have chosen to just use the dot, and follow pointers until I reach something which is no longer a pointer type, but I decided not to do this. Mainly because that's not the way pointers are made in languages like c++, so I think it would feel unnatural to people who are used to pointers.
Edit:
I released a small upgrade. v2.2.2
Fixed a bug that sometimes prevented autocompletion from working for pointer types.
Autocompletion now also works when indexing an array.
In the find and replace windows, only the textboxes can now have focus.
It is no longer allowed to have two methods with the same signature.
Added properties. See the documentation.
There are some other small changes as well. I just didn't write them down.
Galaxy does not support identifiers starting with _ (but yours accept it)
Your compiler messes up inlining sometimes, FixedToInt(InlinedFunction()), doesn't inline the function... however, it doesn't include the InlinedFunction() either... so the generated code references InlinedFunction(), but it doesn't exist.
Found a bug:
When I use a string which contain some Chinese characters. And a number behind a character,such as "我0",when complie and run ,there will be a error.
And there is another problem. The paeameters specification which shows when I input a function, is not long enough to show all the parameters.And can it support word warp?
The code you attached is valid, and should compile without problems. It does in the latest version v2.2.5
Added enrichments. See documentation.
Tooltips will now wrap to next line instead of going out of the screen.
Fixed some bugs.
Note that for enrichments, I only added it on the compiler side. You won't get suggestions after a dot on an integer variable even if you enriched the integer.
gives me "The left side of the . must be of type struct, class, or something which is enriched" on the line #this.pri = prix. You may also need this to figure out the error. Removing the #this like you've done in the example gives me "unable to use struct fields outside of methods".
void priorityMine (unit u) {}
#trigger priorityAddMine {
#events {}
#actions
{
int pri = priorityInd;
int pl = EventPlayer ();
int p = pl-1;
typedefWorker wo;
pFuncD test = #delegate<pFuncD>(testfunc);
for (int x=0; x<=10; x++) {
//if no worker avail is will queue the order so that
//when worker is avail it will pick up the mission
if (Worker[p][x].avail) {
wo = Worker[p][x];
wo.avail = false;
if (x==10); {
priorityQueueInsert (p, #new priorityStruct (priorityPr[p][0], test ));
}
}
}
}
That is because the #this in a constructor is a pointer to the object that was created. You need to depointer it in order to call those fields.
Use -> instead of . or use (*#this).pri
If you just use . the compiler would expect to find a matching property in an enrichment of priorityStruct*
You can't use enrichments to add new fields to a primitive. Only properties, methods and constructors. The constructors are done like for structs and classes. So a method with no return type. Only difference is that you can call it whatever you want.
When you use properties, remember that they don't give you a new place to store any data. They only give you a more convenient way of accessing data.
Instead, I would suggest you make a class or a struct that contains a boolean and a unit field.
@ANewHopeSC2: Go
The auto-completion bug will be fixed in my next release.
About the ->.
The "." doesn't make sense for a pointer. You must first follow the pointer to the actual "instance", and then invoke the method on that. This is what the * is for. (*myClass).Print();.
a->b is just a quick way of writing (*a).b.
If you for instance made a double pointer (Class
**
myClass), you would need to use the *. ((**
myClass).Print()), or ((*myClass)->Print())In case you are unfamiliar with pointers, they are basically just references to another place in memory. In this other place in memory, you can create an object of your choosing. But if you want to call a method on that object, you need to specify that you want to call it on that object, and not on the pointer.
I know that I could have chosen to just use the dot, and follow pointers until I reach something which is no longer a pointer type, but I decided not to do this. Mainly because that's not the way pointers are made in languages like c
++
, so I think it would feel unnatural to people who are used to pointers.Edit:
I released a small upgrade. v2.2.2
There are some other small changes as well. I just didn't write them down.
System.Collections.Generic.KeyNotFoundException: 给定关键字不在字典中。 在 System.Collections.Generic.Dictionary`2.get_Item(TKey key) 在 Galaxy_Editor_2.Compiler.Phases.Transformations.LivenessAnalysis.DefaultIn(Node node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Phases\Transformations\LivenessAnalysis.cs:行号 506 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.InAExpStm(AExpStm node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2062 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAExpStm(AExpStm node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2072 在 Galaxy_Editor_2.Compiler.Generated.node.AExpStm.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 4868 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAABlock(AABlock node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2051 在 Galaxy_Editor_2.Compiler.Generated.node.AABlock.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 4716 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseABlockStm(ABlockStm node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2199 在 Galaxy_Editor_2.Compiler.Generated.node.ABlockStm.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 5575 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAIfThenStm(AIfThenStm node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2095 在 Galaxy_Editor_2.Compiler.Generated.node.AIfThenStm.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 4990 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAABlock(AABlock node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2051 在 Galaxy_Editor_2.Compiler.Generated.node.AABlock.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 4716 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseABlockStm(ABlockStm node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2199 在 Galaxy_Editor_2.Compiler.Generated.node.ABlockStm.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 5575 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAIfThenStm(AIfThenStm node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2095 在 Galaxy_Editor_2.Compiler.Generated.node.AIfThenStm.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 4990 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAABlock(AABlock node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 2051 在 Galaxy_Editor_2.Compiler.Generated.node.AABlock.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 4716 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAMethodDecl(AMethodDecl node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 1463 在 Galaxy_Editor_2.Compiler.Phases.Transformations.LivenessAnalysis.CaseAMethodDecl(AMethodDecl node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Phases\Transformations\LivenessAnalysis.cs:行号 292 在 Galaxy_Editor_2.Compiler.Generated.node.AMethodDecl.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 1108 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAASourceFile(AASourceFile node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 1286 在 Galaxy_Editor_2.Compiler.Generated.node.AASourceFile.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 156 在 Galaxy_Editor_2.Compiler.Generated.analysis.DepthFirstAdapter.CaseAAProgram(AAProgram node) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\analysis.cs:行号 1325 在 Galaxy_Editor_2.Compiler.Generated.node.AAProgram.Apply(Switch sw) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Generated\prods.cs:行号 411 在 Galaxy_Editor_2.Compiler.Phases.Transformations.FinalTransformations.Apply(AAProgram ast) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Phases\Transformations\FinalTransformations.cs:行号 144 在 Galaxy_Editor_2.Compiler.Phases.Transformations.FinalTransformations.Parse(AAProgram ast, ErrorCollection errors, SharedData data, String& rootFile) 位置 C:\Users\Beier\Documents\Visual Studio 2010\Projects\Galaxy Editor 2\Galaxy Editor 2\Compiler\Phases\Transformations\FinalTransformations.cs:行号 18
This error occured at I compile. The script I complie is upload. This error happened at v2.20 and v2.22,but not happened at v2.17
I fixed it and uploaded v2.2.3.
You don't need to post the entire stack trace here. I can see it just fine in the error report you sent ;)
The editor crashes/freezes at startup, if no internet connection is present.
I get "You have unused definitions" errors again, if I use one #trigger object. Wasn't this fixed a while ago?
Found some compiler bugs:
Found a bug: When I use a string which contain some Chinese characters. And a number behind a character,such as "我0",when complie and run ,there will be a error.
And there is another problem. The paeameters specification which shows when I input a function, is not long enough to show all the parameters.And can it support word warp?
I would like to be able to aquire a pointer for an existing object. In C++ this is done by:
int x;
int* ptr = &x;
ptr will now point at x.
Your tool is great btw!
Edit: Oh, just read page 9. Nevermind.
It keeps crashing when I try to compile it...
I'm pretty sure some part of my code causes this for some reason but I have no idea what it is.
Most of it is in a class so far and it crashed when I tried to test what I currently have.
I only included the class, the rest is just the initialization trigger that creates an instance of this class.
Nevermind, I figured it out.
@Lindenk: Go
The code you attached is valid, and should compile without problems. It does in the latest version v2.2.5
Note that for enrichments, I only added it on the compiler side. You won't get suggestions after a dot on an integer variable even if you enriched the integer.
Awesome!
Are constructers possible for enrichments?
edit2:
int iy;
w = EventUnit();
i = FixedToInt(UnitGetCustomValue(w,UNIT_WALL_IND);
It says "expecting ')'"
full script is here http://paste.sc2mapster.com/co59bga8nqdh3krs/ the error is at line 77
No, constructors are not possible in enrichments (yet).
You are missing an end parenthesis for FixedToInt.
@SBeier:
oh yeah I did, thanks!
The editor is incredibly slow at startup for me lately. It freezes for like 5 to 10 seconds, every time I start it.
I added some new features and fixed some bugs. v2.3.0
This is all magic to me. You're all wizards.
struct priorityStruct {
pFuncD pFunc;
int pri;
priorityStruct (int prix, pFuncD pf) {
#this.pri = prix;
#this.pFunc = pf;
}
}
gives me "The left side of the . must be of type struct, class, or something which is enriched" on the line #this.pri = prix. You may also need this to figure out the error. Removing the #this like you've done in the example gives me "unable to use struct fields outside of methods".
void priorityMine (unit u) {}
#trigger priorityAddMine {
#events {}
#actions
{
int pri = priorityInd;
int pl = EventPlayer ();
int p = pl-1;
typedefWorker wo;
pFuncD test = #delegate<pFuncD>(testfunc);
for (int x=0; x<=10; x++) {
//if no worker avail is will queue the order so that
//when worker is avail it will pick up the mission
if (Worker[p][x].avail) {
wo = Worker[p][x];
wo.avail = false;
if (x==10); {
priorityQueueInsert (p, #new priorityStruct (priorityPr[p][0], test ));
}
}
}
}
That is because the #this in a constructor is a pointer to the object that was created. You need to depointer it in order to call those fields.
Use -> instead of . or use (*#this).pri
If you just use . the compiler would expect to find a matching property in an enrichment of priorityStruct*
alright thanks, now I'm trying to use the enrichment constructor though.
typedef unit typedefWorker;
#enrich typedefWorker {
bool avail {
#get { return #this.avail }
#set { #this.avail = #value; }
}
unit typedefWorker (int p, point P){
#this.avail=true;
return libNtve_gf_CreateUnitsAtPoint2(1, "Worker", 0, p, P);
}
}
typedefWorker[4][10] Worker;
Worker[x][y] = #new typedefWorker (x, Point(0,0));
I guess I'm not doing it correctly, however it's unclear how else to do it :S
You can't use enrichments to add new fields to a primitive. Only properties, methods and constructors. The constructors are done like for structs and classes. So a method with no return type. Only difference is that you can call it whatever you want.
When you use properties, remember that they don't give you a new place to store any data. They only give you a more convenient way of accessing data.
Instead, I would suggest you make a class or a struct that contains a boolean and a unit field.
Like this.
I sent you a crash report, I can send you the complete code if you need (dunno if that was included in the report).