Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 1,384 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 6 1 2 3 4 5 6
Re: Lite Foundation - A powerful Lite-C library [Re: WretchedSid] #368755
04/28/11 04:05
04/28/11 04:05
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
tzw Offline
Member
tzw  Offline
Member

Joined: Jan 2011
Posts: 122
GUILIN , CHINA
i think it can be emulated by using marcos.
i compile it fail in lite c. but in c99--gcc, everything is ok


Full of my eyes are class struggles.....
Re: Lite Foundation - A powerful Lite-C library [Re: tzw] #368813
04/28/11 16:28
04/28/11 16:28
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline OP
Expert
WretchedSid  Offline OP
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Mhh, no, I don't see how macros could help. I mean, if I define a macro like
Code:
#define someMacro(this, argument1, argument2)


it would still look like a function call. Or am I missing something?

About the compiling problem; Yep, I probably forgot to define the target environment as Lite-C before uploading the version, you can change this in the LFBase.h file.


Anyway, a new version is out and I would recommend the update. First of all: It fixes two bugs with the string comparison:
1) LFStringCompare() searched only the whole string -1 character
2) The functions would compare a lowercase letter greater than a uppercase letter. This means that "BBBBB" compared to "aaaaa" would be smaller, while "aaaaa" should actually smaller than "BBBBBB".

The next thing is also about string comparison: Numerical comparison. This means that "Charles 1" is smaller than "Charles 2" and greater than "Charles 0". This only works with unsigned integers but its pretty neat.

Another thing is for comparison in general: The LFComparisonResult type could not hold kLFCompareLessThan because Lite-C doesn't respect "signed char".

The really big new thing: Arrays can be sorted.
Okay, array sorting is not that fancy, everyone can write a simple bubble sort. But because bubble sort is the most slowest sorting algorithm on earth, I decided to take some time and implement a sorting algorithm that sorts the array in O(N log N) worst case and normally in O(log N).
The used algorithm is a introsearch algorithm, the function will first try to sort the array with quicksort and if it ends in a degenerate case (it checks the recursion depth), the function will switch to heapsort which is guaranteed to sort the array in O(N log N). Actually its pretty hard to end in the heapsort, in 99,9999% of all cases the quicksort algorithm will do its job.
However, as recursion is expensive, the quicksort implementation will not sort the whole array but only up to a certain threshold (which is subarrays must be larger than 10).
The rest is done via an insertion sort which is way faster for almost sorted arrays than quicksort.

I have updated the Arrays.c example to show how easy it is to sort an array with 63 strings in it (populating the array takes way more space in the demo).
As always, the old links still work. And: I would love to hear your feedback laugh


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Lite Foundation - A powerful Lite-C library [Re: WretchedSid] #368874
04/29/11 05:08
04/29/11 05:08
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
tzw Offline
Member
tzw  Offline
Member

Joined: Jan 2011
Posts: 122
GUILIN , CHINA
i find a solution. use a global ptr . use a marcro to invoke obj's method.
like this:
void * this_g= NULL;
#define tzw_invoke(obj,meth) this_g = obj; obj-> meth

and in called func,we should make sure the"this"'type is what.
place the following command in the top of function 's body;
#define set_this(tzw_type) void * this =(tzw_type *) this_g

example:
set the struct type is "chinese", it's obj is tangziwen(my name~~),one of the methods is say_hello
like this:
void say_hello(var num)
{
set_this(chinese);
......
printf("ni-hao!");
this.stuff=num;
......
}
int main(void)
{
tzw_invoke(tangziwen,say_hello)(5);
........
return 0;
}

well,the syntax is a bit ugly. but work fine.

Last edited by tzw; 04/29/11 05:16.

Full of my eyes are class struggles.....
Re: Lite Foundation - A powerful Lite-C library [Re: tzw] #368875
04/29/11 05:29
04/29/11 05:29
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
tzw Offline
Member
tzw  Offline
Member

Joined: Jan 2011
Posts: 122
GUILIN , CHINA
in fact , i make a group of codes to emulate oop (dis/constructor,interface,namespace,etc.).but i can't upload it to internet because my country 'boss --CCP forbid a lot of foreign websites,even youtube.....


Full of my eyes are class struggles.....
Re: Lite Foundation - A powerful Lite-C library [Re: tzw] #368878
04/29/11 06:56
04/29/11 06:56
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline OP
Expert
WretchedSid  Offline OP
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Ah, I see what you meant. Well, in this case, Lite Foundation offers you something like "this".
Here would be the example using LF, assuming that there is a class named foo:

Code:
void sayHello(foo *this, int num)
{
   printf("Hello world");
   this->num = num;
}

foo *bar = createFooInstance();
sayHello(bar, 10);



It works basically the same way, but without the need of a invoke function. However, LF also has a invoke function which is used in cases where polymorphism is needed (protocols), but the functions also pass the receiving object ("this") as the first parameter to functions.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Lite Foundation - A powerful Lite-C library [Re: WretchedSid] #368897
04/29/11 10:13
04/29/11 10:13
Joined: Jan 2011
Posts: 122
GUILIN , CHINA
tzw Offline
Member
tzw  Offline
Member

Joined: Jan 2011
Posts: 122
GUILIN , CHINA
yep, but make sure clients pass this argument may be very hard.and they don't like this way... BTW,nice lib.


Full of my eyes are class struggles.....
Re: Lite Foundation - A powerful Lite-C library [Re: tzw] #369772
05/06/11 22:30
05/06/11 22:30
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline OP
Expert
WretchedSid  Offline OP
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Okay, before I can issue the next update, I need to wait for JCL to implement setjmp() and longjmp() which then allow me to introduce three new classes exclusively for the GStudio version with setjmp.h support (don't worry, there will be a fallback for older versions).
Along with these three new classes, there are a few other new classes that come with the next update and that I hope you find as awesome as I do:

(Need setjmp.h)
LFException (well, exceptions... not much to say)
LFUnitTest (a class that implements one unit test)
LFUnitTestSuite (a class that collects multiple unit tests into one test suite)

(Available for every Lite-C user)
LFData (a class that can hold and alter binary data)
LFDictionary (a hash table like LFSet but which allows you to set your own keys for the values)
LFArchiver (a class that can serialize almost any other object in machine independent binary data)
LFUnarchiver (the reverse class to LFArchiver)
LFStorage (a balanced tree class which can save a large number of binary data effectively (is used as backend for the LFArchiver and LFUnarchiver class))
LFNumber (a class which can hold the primitive C types which also provides comparison and conversion etc)


The classes are so far done, although I'm not completely happy with some of the functions and the documentation for the new classes is almost non-existent. However, I guess there will be a lot of time until the update comes out which introduces the setjmp.h header so if you want to see a special class in the next update: Ask now for it! But keep in mind that Lite Foundation is meant to be a general purpose library, so specific things like an ENTITY wrapper won't make it into the library.

Last edited by JustSid; 05/06/11 22:36.

Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Lite Foundation - A powerful Lite-C library [Re: WretchedSid] #370331
05/12/11 14:26
05/12/11 14:26
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline OP
Expert
WretchedSid  Offline OP
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Looks like my webhoster has some fuckup so my website is down for a few days. While its down, you can download the latest version here:
http://cl.ly/6ghG

There is one little change; The array demo closed itself in the actual release which wasn't intended, the array demo now shows the sorted array in the engines window.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: Lite Foundation - A powerful Lite-C library [Re: WretchedSid] #370689
05/15/11 00:31
05/15/11 00:31
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline
Serious User
Rackscha  Offline
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Quote:
foo *bar = createFooInstance();
sayHello(bar, 10);


Thats how my simple GUI system works^^(other naming convention, but the same way).

for example if i have a struct called TFrame (the T is from Type used in Delphi....)

'Methods' of it are called like
TFrame_Free
TFrame_Create
TFrame_Paint

etc
(First parameter is always the instance)


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: Lite Foundation - A powerful Lite-C library [Re: Rackscha] #370759
05/15/11 14:25
05/15/11 14:25
Joined: Apr 2007
Posts: 3,751
Canada
WretchedSid Offline OP
Expert
WretchedSid  Offline OP
Expert

Joined: Apr 2007
Posts: 3,751
Canada
Yes, thats the common way for C functions that do something more object oriented. Gamestudio has the very same convention.

Underscore or camel case is just a matter of what one likes more, I for one prefer camel case but everyone should use whatever they like more.
Its the same with syntax styles, some people like K&R more, I like the Allman style more and some people even prefer the GNU style. As long as the code is consistent, there is nothing wrong with the styles.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Page 3 of 6 1 2 3 4 5 6

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