AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   SourceModGen - Data modeling tool (https://forums.alliedmods.net/showthread.php?t=217892)

API 06-09-2013 02:49

SourceModGen - Data modeling tool
 
Hey guys,

For the past day or so I have been working on the first version of what I like to call SourceModGen

Link: http://smgen.pointlimit.com
Github (source code): https://github.com/AnthonyIacono/SourceModGen

What is it?
SourceModGen is a data visualization tool that will generate redundant code based on structure descriptions. It supports many different types and in the future (once I get some sleep) I will make it generate database CRUD methods as well (Create, Read, Update, Delete)

UPDATE v1.1: SourceModGen now generates KV read / write functions.
UPDATE v1.2: SourceModGen now generates constants (with a configurable prefix) instead of hard-coding block size, field KV keys, and field max lengths.

In short, SourceModGen generates functions that allow you as an SM developer to worry less about the structure and storage of your data and worry more about getting things done.

I haven't had a chance to test it thoroughly, but reading over the generated code looks promising.

030Maric 06-09-2013 03:35

Re: SourceModGen - Data modeling tool
 
WOW

Thanks a lot...

API 06-09-2013 11:21

SourceModGen - Data modeling tool
 
:) I can't wait to add some more stuff to this and release a data modeling video tutorial.

API 06-09-2013 22:26

Re: SourceModGen - Data modeling tool
 
Okay just updated it to generate read / write functions for KeyValues. I've also changed the default variable prefix and function parameter prefix. I'll be doing a video tutorial next on how you can use SMGen to speed up development cycles.

friagram 06-10-2013 22:10

Re: SourceModGen - Data modeling tool
 
Wtb malloc calloc

realloc*

API 06-10-2013 22:34

Re: SourceModGen - Data modeling tool
 
Code:

CloseHandle()

API 06-10-2013 22:37

Re: SourceModGen - Data modeling tool
 
Unless I'm misunderstanding your not-sentence.

friagram 06-11-2013 08:34

Re: SourceModGen - Data modeling tool
 
No, i am just pointing out how odd and inefficient dynamic array models are in pawn.
But sure, you don't need these type functions, esp realloc, you can just allocate a new array of the new size, copy the contents, and close the old handle, and return the new handle. You need more functions to do it.

Also, there is no tag type associated to the array, i think, so you can't initialize it on creation. This is a bit annoying.

Presumably array creation will succeed? There is no way of knowing i think, because it doesn't return something like null ptr on failure.

API 06-11-2013 10:20

Re: SourceModGen - Data modeling tool
 
SMGen creates a copy function.

Example:
Code:

stock Handle:War3_CopyWar3Race(Handle:p_War3Race) {
    new Handle:s_War3Race = CreateArray(8);

    PushArrayCell(s_War3Race, GetArrayCell(p_War3Race, 0));
    decl String:s_ShortNameOutput[32];
    GetArrayString(p_War3Race, 1, s_ShortNameOutput, 32);
    PushArrayString(s_War3Race, s_ShortNameOutput);
    decl any:s_DescriptionOutput[5];
    GetArrayArray(p_War3Race, 2, s_DescriptionOutput, 5);
    PushArrayArray(s_War3Race, s_DescriptionOutput, 5);

    return s_War3Race;
}


Powerlord 06-11-2013 16:49

Re: SourceModGen - Data modeling tool
 
Quote:

Originally Posted by friagram (Post 1968669)
No, i am just pointing out how odd and inefficient dynamic array models are in pawn.
But sure, you don't need these type functions, esp realloc, you can just allocate a new array of the new size, copy the contents, and close the old handle, and return the new handle. You need more functions to do it.

I'm lost as to what you mean here. adt_arrays automatically resize based on how many elements they have so you should never have to copy data between adt_arrays... and since normal Pawn arrays don't use handles, I have to assume you're talking about adt_arrays.

Quote:

Originally Posted by friagram (Post 1968669)
Also, there is no tag type associated to the array, i think, so you can't initialize it on creation. This is a bit annoying.

Yes, but sadly it's more or less a limitation of Pawn. Remember, everything is a 32-bit int to Pawn, even floating point numbers. Strings are just sets of 4 chars stuffed into 32-bit ints.

Quote:

Originally Posted by friagram (Post 1968669)
Presumably array creation will succeed? There is no way of knowing i think, because it doesn't return something like null ptr on failure.

It returns INVALID_HANDLE on failure.


All times are GMT -4. The time now is 08:53.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.