2 registered members (AndrewAMD, SBGuy),
987
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Genesis "Precompiler" (prototype)
[Re: Superku]
#392911
01/29/12 16:14
01/29/12 16:14
|
Joined: Jul 2001
Posts: 6,904
HeelX
Senior Expert
|
Senior Expert
Joined: Jul 2001
Posts: 6,904
|
Rakscha, with all due respect for your hard work, would you mind to answer the following, serious, question: in what circumstance do you need your precompiler? Isn't it just a tool that transform sort of C++ code into Lite-C and compiles it? Would'nt it make more sense to take the SDK and "just" develop with it in... "native"... C++?
There are two reasons I could imagine, why someone would have a real benefit over directly working with the C++ SDK: level_load (for mapping the action name to a function pointer) and wait(1). Ah, and float <-> var transparency.
So, big question here: how is wait(1) supported and how does it integrate, in, say, methods?
Is it possible to work with the STD? How about template programming? Do you plan to take a VS project and transform it?
Last edited by HeelX; 01/29/12 16:15.
|
|
|
Re: Genesis "Precompiler" (prototype)
[Re: HeelX]
#392916
01/29/12 16:51
01/29/12 16:51
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
@Superku: thanks @HeeIX: Yep, the C++ LIKE code(like, because not everything is implemented/supported atm) is transformed to LiteC-Code. Every method is just a normal function internally. Ofcourse, you'll face problems when using wait inside a method, and the object is freed during waiting. I might add restrictions for that.(or a corresponding compiler warning) I have several reasons to do this: 1) Its quite an interesting experience 2) Most beginners will start with LiteC. Pushing them directly to C++ might be a problem. They have to struggle with the SDK , setting up an advanced Development environment(for a total beginner it might be a problem). So this precompiler is some kind of experience bridge between LiteC and C++. Those who already worked with Gamestudio+C++ might not need this, but new ones. 3) So far(as far as i know), using engine functions inside C++ requires _var() where ever a var parameter is required. Unnecessary overhead for writing(i.e. requires wrapping before using) 4) The liteC compiler sometimes throws uninformative messages(or even wrong ones). By parsing everything thats outside a function, i want to catch as much as possible. For example a missing ';' after a struct definition wont lead to an error inside a following function anymore. But a proper "missing ';'" error 5) Programming in LiteC while using advanced IDEs. Sometimes using a complete C++ environment might be an overkill for some projects(or the programmer/beginner). Using my precompiler you can write your code in CodeBlocks for example and compile directly. (i plan on adding more parameter compatibility for my precompiler, so it runs better with input from a make command). 6) Its possible to directly include LiteC projects in Projects from my Precompiler. Just include the .c/.h files and you can use the functions written there. (.c/.h units are not parsed, just added). So, if a user made a usefull LiteC contribution, its most likely, you can use it in my Precompiler. About STD: its likely that it doesnt work. Currently my precompiler doesnt include everything. I havent tested it yet, but iam sure there is a lot that might cause conflicts(we have only singleinheritance. Multiinheritance is NOT possible for me,as it is in C++). Template programming is a nice and interesting feature. I wish to implement it, but its way to early atm. I have to make sure that those things i implemented, work. Otherwhise i'll blow up the code. And no, iam not planning on transforming a VS project. This requires a complete implementation of C++, which is either not possible for me or too time consuming. Greetings Rackscha
Last edited by Rackscha; 01/29/12 17:06.
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Genesis "Precompiler" (prototype)
[Re: Rackscha]
#393021
01/30/12 16:37
01/30/12 16:37
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
During the last few seconds, i implemented implicit "this". Which means that its not necessary to use "this" inside a method for accessing a member of the "this" instance. However. If you dont use "this", the precompiler first searches the current method for a declared var of this name, if its not found, it searches the class of this method for a member with this name. As you cann see, if you have a class with a member called "FCount" and a method with a lokal var called "FCount", the compiler will priorize the lokal var and NOT use the member of the Class. example input: (CList has a var of type int called FCount)
void CList::Remove(int AIndex)
{
int i;
if(clamp(AIndex, 0, FCount-1) == AIndex)
{
for (i = AIndex; i < FCount-2; i++)
{
(FItems)[i] = (FItems)[i+1];
}
FItems = sys_realloc(FItems, sizeof(int), FCount, FCount-1);
FCount -= 1;
}
}
example output:
void GenesisCListRemove(CList* this, int AIndex)
{
int i;
if(clamp(AIndex, 0, this.FCount-1) == AIndex)
{
for (i = AIndex; i < this.FCount-2; i++)
{
(this.FItems)[i] = (this.FItems)[i+1];
}
this.FItems = sys_realloc(this.FItems, sizeof(int), this.FCount, this.FCount-1);
this.FCount -= 1;
}
}
but this behaves differently: input:
void CList::Remove(int AIndex)
{
int i;
int FCount;
if(clamp(AIndex, 0, FCount-1) == AIndex)
{
for (i = AIndex; i < FCount-2; i++)
{
(FItems)[i] = (FItems)[i+1];
}
FItems = sys_realloc(FItems, sizeof(int), FCount, FCount-1);
FCount -= 1;
}
}
output:
void GenesisCListRemove(CList* this, int AIndex)
{
int i;
int FCount;
if(clamp(AIndex, 0, FCount-1) == AIndex)
{
for (i = AIndex; i < FCount-2; i++)
{
(this.FItems)[i] = (this.FItems)[i+1];
}
this.FItems = sys_realloc(this.FItems, sizeof(int), FCount, FCount-1);
FCount -= 1;
}
}
As you can see from this example, the lokal var has a higher priority/visibility. Greetings Rackscha
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Genesis "Precompiler" (prototype)
[Re: Rackscha]
#393265
02/01/12 19:29
02/01/12 19:29
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
Ladies and gentlemen: I proudly present: for each(<varpointer> in <List>) I know, using for each in the following example is useless, but i is required to draw everything properly, and its a testrun anyway(so i is NOT requird for a normal for each loop, just in this dump testcase :P) input:
i = 0;
for each(LMessage in LList)
{
draw_text(LMessage, 10, 10*i, vector(100, 100, 100));
draw_text("huhu", 200, 10*i, vector(100, 100, 100));
i++;
}
output:
i = 0;
LList.FEInit(LList); while(LList.FEHasMoreElements(LList) > 0)
{ LMessage = LList.FENextElement(LList);
draw_text(LMessage, 10, 10*i, vector(100, 100, 100));
draw_text("huhu", 200, 10*i, vector(100, 100, 100));
i++;
}
Okay, how does it work? There is a new Class called CForEachObject. This class implements 3 methods. FEInit(); FEHasMoreElements(); FENextElement(); If you want your object to work with the for each loop, you have to derive it from CForEachObject and implement those 3 methods. Here is an example implementation from my CList:
void* CList::FENextElement()
{
FFECount ++;
return((FItems)[FFECount-1]);
}
int CList::FEHasMoreElements()
{
return(FFECount < FCount);
}
void CList::FEInit()
{
FFECount = 0;
}
As you can see, my CList has a private var called FFECount. This var is used to count up. In FEInit i initialize it to 0. In HasMoreElements, i check if the FFECount is BELOW my FCount(which is the number of items in my list). And incrementing FFECount in NextElement to go on with the next one later. If you use the same list in a nested for each (for what reason). It wont break the mechanic but keep in mind that only the inner loop runs properly and the outer one quit directly after the first run. PS: oh and it seems that deriving classes from each others went a bit buggy in 0.4. i fixed it. Greetings Rackscha
Last edited by Rackscha; 02/01/12 19:31.
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Genesis "Precompiler" (prototype)
[Re: Rackscha]
#393412
02/03/12 00:19
02/03/12 00:19
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
Expert
|
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Hot stuff so far! Well done . I might just give this a shot. For me C++ is a little bit overhead for an average 3dgs game. This looks cool. How about an eclipse solution though instead of codeblocks? :>
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
Re: Genesis "Precompiler" (prototype)
[Re: Joozey]
#393419
02/03/12 08:50
02/03/12 08:50
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
For using it in Eclipse, you have to install a make-tool(as included in GCC for example).
When i fix the issues with reading the commandparemeters correctly, you should be able(gramatic fail here?) to use it in eclipse and other IDEs supporting make-tools. CodeBlocks is just easier for now, because it startsup the Compiler and linker directly.
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Genesis "Precompiler" (prototype)
[Re: Joozey]
#393464
02/03/12 18:50
02/03/12 18:50
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
the only thing i need so far, is an interface to run my compiler(i.e. using a make-tool and a makefile in eclipse).
The rest should work for most points. Or have you found any groundbreaking stuff/problem that confuses eclipses codeview?
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
Re: Genesis "Precompiler" (prototype)
[Re: Rackscha]
#393509
02/04/12 13:03
02/04/12 13:03
|
Joined: Dec 2008
Posts: 1,218 Germany
Rackscha
OP
Serious User
|
OP
Serious User
Joined: Dec 2008
Posts: 1,218
Germany
|
Just released v0.5. Changes (as always) are included in the changelog in my mainpost.
Greetings Rackscha
MY Website with news of my projects: (for example my current Muliplayer Bomberman, GenesisPrecompiler for LiteC and TileMaster, an easy to use Tile editor) Sparetime-Development
|
|
|
|