Gamestudio Links
Zorro Links
Newest Posts
New Zorro version 1.83
by jcl
Today at 16:24
Unfreed in -diag
by 3run
Today at 10:30
About STRING* and char
by 20BN
Today at 09:40
I need help
by evangelos
Today at 02:37
Draw stuff from other thread
by Superku
Yesterday at 22:00
Optimize Stop with multi Asset strategy
by Dalla
Yesterday at 21:48
cloth ?
by 3run
Yesterday at 20:48
AUM Magazine
Latest Screens
Evonet Beta v1.0 : Online Project Development Template
Lake scene
Forgotten Tales - Demo version
RPG PARTY
Who's Online
17 registered (FirasTaji, AndrewAMD, Cerve, 3run, easyX, alibaba, jenGs, 4 invisible), 483 Guests and 3 Spiders online.
Key: Admin, Global Mod, Mod
Newest Members
FirasTaji, zentrader, Fenry, DJ_Algo, tang
18005 Registered Users
Page 1 of 3 1 2 3 >
Topic Options
Rate This Topic
#372131 - 05/28/11 23:26 Genesis PreCompiler
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: 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


Edited by Rackscha (02/04/12 14: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


Top
#372137 - 05/29/11 04:35 Re: Genesis "Precompiler" (prototype) [Re: Rackscha]
tzw Offline
Member

Registered: 01/16/11
Posts: 122
Loc: GUILIN , CHINA
good!!!!!!!!!!!!!!!!!!!!!!!!!!
_________________________
Full of my eyes are class struggles.....

Top
#372145 - 05/29/11 10:04 Re: Genesis "Precompiler" (prototype) [Re: tzw]
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: 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


Top
#375599 - 06/26/11 20:48 Re: Genesis "Precompiler" (prototype) [Re: Rackscha]
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: 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


Top
#390885 - 01/05/12 17:49 Re: Genesis "Precompiler" (prototype) [Re: Rackscha]
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: 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


Top
#390966 - 01/06/12 16:00 Re: Genesis "Precompiler" (prototype) [Re: Rackscha]
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: 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


Top
#391482 - 01/13/12 01:34 Re: Genesis "Precompiler" (prototype) [Re: Rackscha]
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: 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


Top
#391866 - 01/16/12 18:12 Re: Genesis "Precompiler" (prototype) [Re: Rackscha]
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: 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


Edited by Rackscha (01/16/12 18: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


Top
#391909 - 01/16/12 23:03 Re: Genesis "Precompiler" (prototype) [Re: Rackscha]
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: Germany
Testing something new:


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

Greets
Rackscha



Edited by Rackscha (01/16/12 23: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


Top
#391973 - 01/17/12 21:10 Re: Genesis "Precompiler" (prototype) [Re: Rackscha]
Rackscha Offline
Serious User

Registered: 12/30/08
Posts: 1218
Loc: 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


Edited by Rackscha (01/17/12 21: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


Top
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