Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Nymphodora, Quad), 894 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Genesis PreCompiler #372131
05/28/11 21:26
05/28/11 21:26
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Good evening everybody.

First: What is Genesis?
Genesis is a Precompiler which can Precompute C++ like Classes and convert them to LiteC

What is the Goal?
The goal is to extend LiteC with Class-Features(Inheritance, virtual methods). While Genesis converts the c++ classes to LiteC code, it starts the LiteC compiler afterwards to do the final step. Output is captured.

What is working:
  • write Classes C++ like
  • Can include Fieldvars
  • Can include Methods
  • you can derove one class from another
  • methods are correctly overwritten
  • you can define a method as virtual, and it will work like it does in real C++
  • define your own constructors/destructors with extended parameters(constructor ONLY)
  • a final constructor is automatically created. Use _ClassName(my parameters) to create your instance
  • use Super(this) to call the parent version of an overriden method
  • 'this' paremeter is always defined inside a method. Currently you call methods like MYObject.Foo(MyObject).
    An autofill will be added
    later for simple notation.
  • all Class objects can be casted in usual LiteC way.
  • Property ClassName and ParentClassName is set automatically. They are part of the CBaseClass(DO NOT MODIFY)
  • Objects are removed with "delete(MyObject);"
  • use include statements. Including another .cxx file auotriggers compiling for this file(as LiteC does). Other
    filetypes(.c, .h are
    added to includes but not precomputed)
  • write normal functions (functions which are not part of a class).

as of version 0.4:
  • You can define Global vars
  • You can define global function dummies
  • You can define structs (its yet not possible to define values at the end)
  • You can define (lazy) enums. You cant set custom values. Each value in an enum is unique
  • New warnings for possible wrong/missing return statements
  • You dont have to add the instancepointer to the method call manually anymore. Its automatic^^
  • super() is obsoleted. You can finally use ParentClass:ParentMethod() to call methods from a parentclass
  • Showing alternative matchind identifier(not yet used everywhere)
  • Showing LiteC Errors correctly in log

as of version 0.5:
  • Bugfix: stringcontent is ignored now when parsing methodcontent.
  • Its now possible to use single and/or multiline comments.
  • You can now use private/protected/public to define the accessspecifiers as you do in C++
  • Implicit "this". Inside a method, you no longer need to write "this" before accessing a member of this instance.
  • for each(<LokalVar> in <List>). to get your class work with the for each loop, just derive it from CForEachObject and implement the 3 methods defined there
  • new/delete can be used as in C++ now(only for classes and no arrays atm). You dont have to write "_ClassName" to construct an object. Just write "new ClassName". And "delete" can be used without brackets now.
  • Required Compilerfiles(CBaseObject, CForEachObject) are automatically copied to your project folder. You dont have to put them in your folder manually anymore


Currently, GPC is available in 2 versions:
GPC: the Precompiler with GUI. Just open your mainfile(.cxx) and let it run.
GPCC: The commandline Precompiler. You can use it with CodeBlocks for example(where GCC is normally required). After successfully precompiling, it starts the LiteC
compiler on your system. Doubleklick GPCC.exe for more info(or ask here if required^^). GPCC captures the LiteC error to and marks
the faulty line for you(well, CodeBlocks does with the info provided by GPCC).

GPCC should work with IDEs where GCC is working too.


PS: Just in case, Put BaseClass.cxx into your projectfolder. It might not be copied and cause LiteC error(missing file). I'll fis this in a futire version.

Download(On my Blog)

If you find any Bugs, please tell me.

EDIT: Small tutorial on how to use it with CodeBlocks
Tutorial

Greetings
Rackscha

Last edited by Rackscha; 02/04/12 13:02.

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] #372137
05/29/11 02:35
05/29/11 02:35
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
tzw Offline
Member
tzw  Offline
Member

Joined: Jan 2011
Posts: 122
GUILIN , CHINA
good!!!!!!!!!!!!!!!!!!!!!!!!!!


Full of my eyes are class struggles.....
Re: Genesis "Precompiler" (prototype) [Re: tzw] #372145
05/29/11 08:04
05/29/11 08:04
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
I almost forgot to add Virtual Methods to the things i want to support^^"
*Added*


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] #375599
06/26/11 18:48
06/26/11 18:48
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
If someone wondered what happened the past weeks:

With the current uploaded version i went the lazy way for catching (syntax) errors. The nex day i noticed that a complete rewrite of the core is nescecary.
I had not much time, and the time i had was used for relaxing. Today i started to rewrite the core. Took me some hours to rewrite just the part for parsing the Class construct(there is now a shitload of positions where it can throw syntax errors).

This code is a bit ugly now, but doesnt allow syntax erros enymore(hopefully). Need to clean up the code and add the rest for parsing methods.

After this i'll reupload the new rewritten programm, no new features just a rewritten core.


Greets
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] #390885
01/05/12 16:49
01/05/12 16:49
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
During the last days, i had some time to rewrite the core and extend the functionality:

-Its now possible to use include statements.
-You can derive one class from another. Include the .class file
from parent class and derive from the class as you do in c++.
EXCEPT for multiple inheritance in a single class. You can only
derive from one class at a time.
-if you do not derive your class from another, its derived
from CBaseClass automatically(the required file has to be in
the compilerfolder OR the folder of your files)

Example source:
BaseClass.class
Code:
class CBaseClass {
  STRING* ClassName;
  STRING* ClassParentName;
};



TestClass.class
Code:
class CTestClass {
  int R, O, P;
  STRING* Stuff;
  STRING* GetMessage();
};


STRING* CTestClass::GetMessage()
{
  return("Hallo");
}



Rectangle.class
Code:
#include<TestClass.class>;
class CRectangle: public CTestClass {
    int x, y;
    CBaseClass* TestPtr;
  public:
    void set_values (int,int);
    int area ();
  };

void CRectangle::set_values (int a, int b) {
  This.x = a;
  This.y = b;
}

int CRectangle::area()
{
	return(This.x*This.y);
}



Output:

BaseClass.c
Code:
#ifndef GenesisBaseClass_class
#define GenesisBaseClass_class
typedef struct CBaseClass{
STRING* ClassName;
STRING* ClassParentName;
}CBaseClass;



void GenesisCBaseClassBindMethods(void* ClassPointer)
{
CBaseClass* This = ClassPointer;
}


CBaseClass* CBaseClassCreate()
{
CBaseClass* LObject;
LObject = sys_malloc(sizeof(CBaseClass));
GenesisCBaseClassBindMethods(LObject);
return(LObject);
}


void CBaseClassFree(void* ClassPointer)
{
CBaseClass* This = ClassPointer;
sys_free(This);
}

#endif



TestClass.c
Code:
#ifndef GenesisTestClass_class
#define GenesisTestClass_class
#include<BaseClass.c>;
//is derived from: CBaseClass
typedef struct CTestClass{
STRING* ClassName;
STRING* ClassParentName;
int R;
int O;
int P;
STRING* Stuff;
STRING* GetMessage(CTestClass);
}CTestClass;



STRING* GenesisCTestClassGetMessage(void* ClassPointer)
{
CTestClass* This = ClassPointer;

  return("Hallo");
}


void GenesisCTestClassBindMethods(void* ClassPointer)
{
CTestClass* This = ClassPointer;
GenesisCBaseClassBindMethods(This);
This.GetMessage = GenesisCTestClassGetMessage;
}


CTestClass* CTestClassCreate()
{
CTestClass* LObject;
LObject = sys_malloc(sizeof(CTestClass));
GenesisCTestClassBindMethods(LObject);
return(LObject);
}


void CTestClassFree(void* ClassPointer)
{
CTestClass* This = ClassPointer;
sys_free(This);
}

#endif



Rectangle.c
Code:
#ifndef GenesisRectangle_class
#define GenesisRectangle_class
#include<BaseClass.c>;
#include<TestClass.c>;
//is derived from: CTestClass
typedef struct CRectangle{
STRING* ClassName;
STRING* ClassParentName;
int R;
int O;
int P;
STRING* Stuff;
STRING* GetMessage(CRectangle);
int x;
int y;
CBaseClass* TestPtr;
void set_values(CRectangle, int, int);
int area(CRectangle);
}CRectangle;



void GenesisCRectangleset_values(void* ClassPointer, int a, int b)
{
CRectangle* This = ClassPointer;

  This.x = a;
  This.y = b;
}


int GenesisCRectanglearea(void* ClassPointer)
{
CRectangle* This = ClassPointer;

	return(This.x*This.y);
}


void GenesisCRectangleBindMethods(void* ClassPointer)
{
CRectangle* This = ClassPointer;
GenesisCTestClassBindMethods(This);
This.set_values = GenesisCRectangleset_values;
This.area = GenesisCRectanglearea;
}


CRectangle* CRectangleCreate()
{
CRectangle* LObject;
LObject = sys_malloc(sizeof(CRectangle));
GenesisCRectangleBindMethods(LObject);
return(LObject);
}


void CRectangleFree(void* ClassPointer)
{
CRectangle* This = ClassPointer;
sys_free(This);
}

#endif




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] #390966
01/06/12 15:00
01/06/12 15:00
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Year^^,
'new' and virtual is working now.

A derived class can now implement a method with the same name as its parentclass.
Its handled like 'new' in c++.

for example if CTestClass implements Foo, and CRectangle is derived from CTestclass, CRectangle can now implement Foo aswell.

if you do:
Code:
CRectangle* LRect;
  ...
  LRect.Foo(LRect);



This will call the method foo of CRectangle

and you can do this:
Code:
CRectangle* LRect;
  CTestClass* LTest;
  ...
  LTest = LRect;
  LRect.Foo(LRect);
  LTest.Foo(LTest);



for LTest, the Foo method of CTestClass is called.

BUT(for the same example as above):
If CTestClass declares Foo as virtual, in both cases Foo of CRectangle is called.

Another nice feature is "super".
If your class reimplements a parentsclass method, you can do this:

Code:
void CRectangle::Foo()
{
  super(This);//will call Foo of CTestClass
  //and go on with my stuff
}



Next step: implementing custom constructors.

Greets
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] #391482
01/13/12 00:34
01/13/12 00:34
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Updated mainpost with up2date download link. Includes features noted above.

Play around with it, and tell me wink


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] #391866
01/16/12 17:12
01/16/12 17:12
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
New version available: v0.3. Adding new features like own constructors/destructors and many more.

You can use it now in Codeblocks.

See Mainpost for features and Notes.

EDIT: added tutorial to mainpost.

Greets
Rackscha

Last edited by Rackscha; 01/16/12 17:45.

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] #391909
01/16/12 22:03
01/16/12 22:03
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Testing something new:


Yep Sid, the compiler screenshot you posted some time ago inspired me grin

Greets
Rackscha


Last edited by Rackscha; 01/16/12 22:04.

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] #391973
01/17/12 20:10
01/17/12 20:10
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline OP
Serious User
Rackscha  Offline OP
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Today, i fixed several problems with the errorout of the LiteC compiler.
Merging of ackerr.txt and acklog.txt + picking the error messages works.

I can fix false line numbers from the LiteC compiler too.
In this picture, the LiteC compiler would output the Linenumber of the bracket below 'lol'. Now its fixed.


Greets
Rackscha

Last edited by Rackscha; 01/17/12 20:11.

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

Page 1 of 3 1 2 3

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1