Initial commit

This commit is contained in:
2025-11-17 10:28:09 +01:00
parent 7bff81691f
commit 6ee36e26be
391 changed files with 110253 additions and 0 deletions

View File

@@ -0,0 +1,713 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <application.h>
char * someArray[10] = {"a", "b", "c"};
void startOpenGL( ) {
opengl * instance = opengl_newPointer();
opengl_initialize( instance );
}
int main( ) {
startOpenGL();
}

View File

@@ -0,0 +1,69 @@
#ifndef _application
#define _application
// Macros
#define LINUX
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/sysinfo.h>
#include <pthread.h>
#include <time.h>
#include "opengl.h"
#include "street.h"
#include "console.h"
#include "toolset.h"
#include "extends.h"
#include "int.h"
#include "char.h"
#include "sqlite.h"
#include "fileSystem.h"
#include "array.h"
#include "triangle.h"
#include "vector3.h"
#include "vector2.h"
#include "text.h"
#include <user.h>
int main( );
void startOpenGL( );
char * someArray[10] ;
#endif

202
application/target/array.c Normal file
View File

@@ -0,0 +1,202 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <array.h>
int array_length( array * this ) {
return this->total;
}
void * array_get( array * this, int index ) {
if ( index >= 0 && index < this->total ){
return this->items[index];
}
return NULL;
}
void array_set( array * this, int index, void * item ) {
if ( index >= 0 && index < this->total ){
this->items[ index ] = item;
}
}
void array_resize( array * this, int capacity ) {
void * * items = realloc( this->items, sizeof( void * ) * capacity );
this->items = items;
this->capacity = capacity;
}
void array_add( array * this, void * item ) {
if ( this->capacity == this->total ){
array_resize( this, this->capacity * 2 );
}
this->items[ this->total++ ] = item;
}
char * array_join( array * this, char * separator ) {
int count = array_length( this );
text * result = text_newPointer( "" );
for (int i = 0; i < count; ++i)
{
char * currentPart = this->items[ i ];
if( i > 0 ) {
text_append( result, separator );
}
text_append( result, currentPart );
}
return result->value;
}
void array_delete( array * this, int index ) {
if ( index < 0 || index >= this->total ){
return;
}
this->items[index] = NULL;
for ( int i = index; i < this->total - 1; i++ ) {
this->items[i] = this->items[i + 1];
this->items[i + 1] = NULL;
}
this->total--;
if ( this->total > 0 && this->total == this->capacity / 4 ){
array_resize( this, this->capacity / 2 );
}
}
int array_array_push( array * this, void * item ) {
array_add( this, item );
return this->total;
}
void array_unshift( array * this, void * item ) {
int length = this->total;
this->total++;
if ( this->capacity == this->total ){
array_resize( this, this->capacity * 2 );
}
for ( int i = length - 1; i >= 0; --i ) {
this->items[ i + 1 ] = this->items[ i ];
}
this->items[ 0 ] = item;
}
void * array_pop( array * this ) {
int length = this->total;
int lastIndex = length - 1;
void * lastItem = array_get( this, lastIndex );
array_delete( this, lastIndex );
return lastItem;
}
array array_new() {
array instance;
instance.__classIndex = 5;
instance.capacity = 10;
instance.total = 0;
instance.items = malloc( 10000000 );
return instance;
}
array * array_newPointer() {
struct array * pointer = malloc( sizeof ( struct array ) );
pointer->__classIndex = 5;
pointer->capacity = 10;
pointer->total = 0;
pointer->items = malloc( 10000000 );
return pointer;
}

View File

@@ -0,0 +1,61 @@
#ifndef _array
#define _array
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <text.h>
#include <char.h>
#include <stdlib.h>
typedef struct array{
unsigned short __classIndex;
int capacity;
int total;
void * * items;
} array;
int array_length( array * this );
void * array_get( array * this, int index );
void array_set( array * this, int index, void * item );
void array_resize( array * this, int capacity );
void array_add( array * this, void * item );
char * array_join( array * this, char * separator );
void array_delete( array * this, int index );
int array_array_push( array * this, void * item );
void array_unshift( array * this, void * item );
void * array_pop( array * this );
array array_new( );
array * array_newPointer( );
#endif

156
application/target/char.c Normal file
View File

@@ -0,0 +1,156 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <char.h>
int char_operator_compare( char * this, char * b ) {
return char_compare( this, b );
}
void char_operator_add( char * this, char * b ) {
strcat( this, b );
}
char * char_operator_plus( char * this, char * b ) {
return char_concatenate( this, b );
}
int char_compare( char * this, char * b ) {
return strcmp( this, b ) == 0;
}
char * char_concatenate( char * this, char * b ) {
int lengthA = strlen( this );
int lengthB = strlen( b );
char * pointer = this;
char * copy = ( char * ) malloc( ( lengthA + lengthB + 1 ) * sizeof( char ) );
int idx = 0;
while ( * pointer != '\0' ){
copy[idx++] = *pointer++;
}
pointer = &b[0];
while ( * pointer != '\0' ){
copy[idx++] = *pointer++;
}
copy[ idx++ ] = '\0';
return &copy[0];
}
char * char_clone( char * this ) {
char * newCopy = malloc( sizeof( char ) * strlen( this ) );
strcpy( newCopy, this );
return newCopy;
}
char * char_copy( char * this ) {
char * newCopy = malloc( sizeof( char ) * strlen( this ) );
strcpy( newCopy, this );
return newCopy;
}
struct array * char_split( char * this, char * needle ) {
char * haystack = char_clone( this );
struct array * keys = array_newPointer();
int count = 0;
char * tmp = haystack;
char * token = strtok( haystack, needle );
int i = 0;
while ( token ) {
array_add( keys, token );
token = (char *) strtok( NULL, needle );
}
return keys;
}
char * char_removeWhitespaceLeft( char * this ) {
char * s = this;
while(isspace(*s)) s++;
return s;
}
char * char_removeWhitespaceRight( char * this ) {
char * s = this;
char* back = s + strlen(s);
while( isspace( *--back ) );
*( back + 1 ) = '\0';
return s;
}
char * char_removeWhitespace( char * this ) {
return char_removeWhitespaceRight(char_removeWhitespaceLeft( this ) );
}

54
application/target/char.h Normal file
View File

@@ -0,0 +1,54 @@
#ifndef _char
#define _char
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <string.h>
#include <ctype.h>
#include <dirent.h>
#include <array.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
int char_operator_compare( char * this, char * b );
void char_operator_add( char * this, char * b );
char * char_operator_plus( char * this, char * b );
int char_compare( char * this, char * b );
char * char_concatenate( char * this, char * b );
char * char_clone( char * this );
char * char_copy( char * this );
struct array * char_split( char * this, char * needle );
char * char_removeWhitespaceLeft( char * this );
char * char_removeWhitespaceRight( char * this );
char * char_removeWhitespace( char * this );
#endif

View File

@@ -0,0 +1,480 @@
#include <classConfiguration.h>
char * __ClassNames[TOTAL_CLASS_COUNT] = { "opengl", "unsignedIntegerArray", "vector2", "vector3", "text", "array", "char", "floatArray", "shader", "uniform", "attribute", "fileSystem", "consoleManager", "http", "headerManager", "header", "request", "mimeTypes", "mesh", "address", "toolset", "b", "a", "inherit", "classA", "classB", "int", "sqlite", "triangle", "user" };
int __ClassPropertyCount[TOTAL_CLASS_COUNT] = { 13, 3, 2, 3, 4, 3, 0, 3, 2, 3, 3, 0, 0, 9, 1, 2, 9, 2, 9, 2, 0, 1, 2, 3, 1, 1, 0, 4, 3, 5 };
char * __ClassPropertyNames[TOTAL_CLASS_COUNT][30] = {
{ "mainDisplay" , "mainWindow" , "MainScreen" , "RootWindow" , "lastTime" , "deltaTime" , "startTime" , "frameCount" , "vertexbuffer" , "indexBuffer" , "currentShader" , "quads" , "image[HEIGHT][WIDTH]" },
{ "capacity" , "total" , "items" },
{ "x" , "y" },
{ "x" , "y" , "z" },
{ "value" , "usevalue" , "length" , "capacity" },
{ "capacity" , "total" , "items" },
{ },
{ "capacity" , "total" , "items" },
{ "uniforms" , "attributes" },
{ "name[64]" , "location" , "type" },
{ "name[64]" , "location" , "type" },
{ },
{ },
{ "socket" , "hostAddress" , "hostAddresslength" , "filesystem" , "mimetypes" , "headers" , "useSSL" , "sslContext" , "requestCallback" },
{ "headers" },
{ "name" , "value" },
{ "connection" , "address" , "port" , "url" , "method" , "version" , "mimeType" , "extension" , "headers" },
{ "extensions" , "mimeTypes" },
{ "indices" , "textureCoordinates" , "vertexCoordinates" , "normalCoordinates" , "indexBuffer" , "vertexbuffer" , "textureCoordinateBuffer" , "meshIndexBuffer" , "uvBuffer" },
{ "street" , "number" },
{ },
{ "propertyFromB" },
{ "propertyFromA" , "propertyFromB" },
{ "propertyFromC" , "propertyFromA" , "propertyFromB" },
{ "propertyFromC" },
{ "propertyFromC" },
{ },
{ "db" , "res" , "value" , "selectedModel" },
{ "a" , "b" , "c" },
{ "username" , "id" , "userlevel" , "hash" , "addresses" }
};
int __ClassPropertyOffsets[TOTAL_CLASS_COUNT][30] = {
{ offsetof( opengl, mainDisplay ) , offsetof( opengl, mainWindow ) , offsetof( opengl, MainScreen ) , offsetof( opengl, RootWindow ) , offsetof( opengl, lastTime ) , offsetof( opengl, deltaTime ) , offsetof( opengl, startTime ) , offsetof( opengl, frameCount ) , offsetof( opengl, vertexbuffer ) , offsetof( opengl, indexBuffer ) , offsetof( opengl, currentShader ) , offsetof( opengl, quads ) , offsetof( opengl, image[HEIGHT][WIDTH] ) },
{ offsetof( unsignedIntegerArray, capacity ) , offsetof( unsignedIntegerArray, total ) , offsetof( unsignedIntegerArray, items ) },
{ offsetof( vector2, x ) , offsetof( vector2, y ) },
{ offsetof( vector3, x ) , offsetof( vector3, y ) , offsetof( vector3, z ) },
{ offsetof( text, value ) , offsetof( text, usevalue ) , offsetof( text, length ) , offsetof( text, capacity ) },
{ offsetof( array, capacity ) , offsetof( array, total ) , offsetof( array, items ) },
{ },
{ offsetof( floatArray, capacity ) , offsetof( floatArray, total ) , offsetof( floatArray, items ) },
{ offsetof( shader, uniforms ) , offsetof( shader, attributes ) },
{ offsetof( uniform, name[64] ) , offsetof( uniform, location ) , offsetof( uniform, type ) },
{ offsetof( attribute, name[64] ) , offsetof( attribute, location ) , offsetof( attribute, type ) },
{ },
{ },
{ offsetof( http, socket ) , offsetof( http, hostAddress ) , offsetof( http, hostAddresslength ) , offsetof( http, filesystem ) , offsetof( http, mimetypes ) , offsetof( http, headers ) , offsetof( http, useSSL ) , offsetof( http, sslContext ) },
{ offsetof( headerManager, headers ) },
{ offsetof( header, name ) , offsetof( header, value ) },
{ offsetof( request, connection ) , offsetof( request, address ) , offsetof( request, port ) , offsetof( request, url ) , offsetof( request, method ) , offsetof( request, version ) , offsetof( request, mimeType ) , offsetof( request, extension ) , offsetof( request, headers ) },
{ offsetof( mimeTypes, extensions ) , offsetof( mimeTypes, mimeTypes ) },
{ offsetof( mesh, indices ) , offsetof( mesh, textureCoordinates ) , offsetof( mesh, vertexCoordinates ) , offsetof( mesh, normalCoordinates ) , offsetof( mesh, indexBuffer ) , offsetof( mesh, vertexbuffer ) , offsetof( mesh, textureCoordinateBuffer ) , offsetof( mesh, meshIndexBuffer ) , offsetof( mesh, uvBuffer ) },
{ offsetof( address, street ) , offsetof( address, number ) },
{ },
{ offsetof( b, propertyFromB ) },
{ offsetof( a, propertyFromA ) , offsetof( a, propertyFromB ) },
{ offsetof( inherit, propertyFromC ) , offsetof( inherit, propertyFromA ) , offsetof( inherit, propertyFromB ) },
{ offsetof( classA, propertyFromC ) },
{ offsetof( classB, propertyFromC ) },
{ },
{ offsetof( sqlite, db ) , offsetof( sqlite, res ) , offsetof( sqlite, value ) , offsetof( sqlite, selectedModel ) },
{ offsetof( triangle, a ) , offsetof( triangle, b ) , offsetof( triangle, c ) },
{ offsetof( user, username ) , offsetof( user, id ) , offsetof( user, userlevel ) , offsetof( user, hash ) , offsetof( user, addresses ) }
};
int __ClassPropertyDatatypeIndices[TOTAL_CLASS_COUNT][30] = {
{1 , 1 , -5 , 1 , -5 , 1 , 1 , -5 , 1 , 1 , 8 , 18 , -2 },
{-5 , -5 , -5 },
{1 , 1 },
{1 , 1 , 1 },
{-3 , -5 , -5 , -5 },
{-5 , -5 , 1 },
{ },
{-5 , -5 , 1 },
{5 , 5 },
{-2 , 1 , 1 },
{1 , 1 , 1 },
{ },
{ },
{-5 , 1 , -5 , 11 , 17 , 14 , -5 , 1 , 1 },
{5 },
{-3 , -3 },
{-3 , -3 , -5 , -3 , -3 , -3 , -3 , -3 , 14 },
{5 , 5 },
{1 , 7 , 7 , 7 , 1 , 1 , 1 , 1 , 1 },
{-3 , -5 },
{ },
{-5 },
{-5 , -5 },
{-5 , -5 , -5 },
{-5 },
{-5 },
{ },
{1 , 1 , -3 , -3 },
{2 , 2 , 2 },
{-3 , -5 , -5 , -3 , 5 }
};
void getArrayByClassIndex( int size, void * * voidArray, int * structByteSize, int classIndex ) {
switch( classIndex ) {
case 0:
voidArray = ( void ** ) ( struct opengl * ) malloc( sizeof( struct opengl ) * size );
*structByteSize = sizeof( struct opengl );
break;
case 1:
voidArray = ( void ** ) ( struct unsignedIntegerArray * ) malloc( sizeof( struct unsignedIntegerArray ) * size );
*structByteSize = sizeof( struct unsignedIntegerArray );
break;
case 2:
voidArray = ( void ** ) ( struct vector2 * ) malloc( sizeof( struct vector2 ) * size );
*structByteSize = sizeof( struct vector2 );
break;
case 3:
voidArray = ( void ** ) ( struct vector3 * ) malloc( sizeof( struct vector3 ) * size );
*structByteSize = sizeof( struct vector3 );
break;
case 4:
voidArray = ( void ** ) ( struct text * ) malloc( sizeof( struct text ) * size );
*structByteSize = sizeof( struct text );
break;
case 5:
voidArray = ( void ** ) ( struct array * ) malloc( sizeof( struct array ) * size );
*structByteSize = sizeof( struct array );
break;
case 7:
voidArray = ( void ** ) ( struct floatArray * ) malloc( sizeof( struct floatArray ) * size );
*structByteSize = sizeof( struct floatArray );
break;
case 8:
voidArray = ( void ** ) ( struct shader * ) malloc( sizeof( struct shader ) * size );
*structByteSize = sizeof( struct shader );
break;
case 9:
voidArray = ( void ** ) ( struct uniform * ) malloc( sizeof( struct uniform ) * size );
*structByteSize = sizeof( struct uniform );
break;
case 10:
voidArray = ( void ** ) ( struct attribute * ) malloc( sizeof( struct attribute ) * size );
*structByteSize = sizeof( struct attribute );
break;
case 11:
voidArray = ( void ** ) ( struct fileSystem * ) malloc( sizeof( struct fileSystem ) * size );
*structByteSize = sizeof( struct fileSystem );
break;
case 12:
voidArray = ( void ** ) ( struct consoleManager * ) malloc( sizeof( struct consoleManager ) * size );
*structByteSize = sizeof( struct consoleManager );
break;
case 13:
voidArray = ( void ** ) ( struct http * ) malloc( sizeof( struct http ) * size );
*structByteSize = sizeof( struct http );
break;
case 14:
voidArray = ( void ** ) ( struct headerManager * ) malloc( sizeof( struct headerManager ) * size );
*structByteSize = sizeof( struct headerManager );
break;
case 15:
voidArray = ( void ** ) ( struct header * ) malloc( sizeof( struct header ) * size );
*structByteSize = sizeof( struct header );
break;
case 16:
voidArray = ( void ** ) ( struct request * ) malloc( sizeof( struct request ) * size );
*structByteSize = sizeof( struct request );
break;
case 17:
voidArray = ( void ** ) ( struct mimeTypes * ) malloc( sizeof( struct mimeTypes ) * size );
*structByteSize = sizeof( struct mimeTypes );
break;
case 18:
voidArray = ( void ** ) ( struct mesh * ) malloc( sizeof( struct mesh ) * size );
*structByteSize = sizeof( struct mesh );
break;
case 19:
voidArray = ( void ** ) ( struct address * ) malloc( sizeof( struct address ) * size );
*structByteSize = sizeof( struct address );
break;
case 20:
voidArray = ( void ** ) ( struct toolset * ) malloc( sizeof( struct toolset ) * size );
*structByteSize = sizeof( struct toolset );
break;
case 21:
voidArray = ( void ** ) ( struct b * ) malloc( sizeof( struct b ) * size );
*structByteSize = sizeof( struct b );
break;
case 22:
voidArray = ( void ** ) ( struct a * ) malloc( sizeof( struct a ) * size );
*structByteSize = sizeof( struct a );
break;
case 23:
voidArray = ( void ** ) ( struct inherit * ) malloc( sizeof( struct inherit ) * size );
*structByteSize = sizeof( struct inherit );
break;
case 24:
voidArray = ( void ** ) ( struct classA * ) malloc( sizeof( struct classA ) * size );
*structByteSize = sizeof( struct classA );
break;
case 25:
voidArray = ( void ** ) ( struct classB * ) malloc( sizeof( struct classB ) * size );
*structByteSize = sizeof( struct classB );
break;
case 27:
voidArray = ( void ** ) ( struct sqlite * ) malloc( sizeof( struct sqlite ) * size );
*structByteSize = sizeof( struct sqlite );
break;
case 28:
voidArray = ( void ** ) ( struct triangle * ) malloc( sizeof( struct triangle ) * size );
*structByteSize = sizeof( struct triangle );
break;
case 29:
voidArray = ( void ** ) ( struct user * ) malloc( sizeof( struct user ) * size );
*structByteSize = sizeof( struct user );
break;
}
}
// #include "sqlite.h"
int getPropertyIndexOfClassIndex( int propertyCount, char ** propertyNames ) {
int propertyIdOfIndex = -1;
for ( int i = 0; i < propertyCount; ++i )
{
char * propertyName = propertyNames[i];
//printf("propertyName: %s\n", propertyName);
if( strcmp( propertyName, "id" ) == 0 ) {
propertyIdOfIndex = i;
break;
}
}
return propertyIdOfIndex;
}
/*
void getArrayByClassIndex( int items, void * * voidArray, int * structByteSize, int classIndex ) {
struct user * array;
switch( classIndex ) {
case 8:
array = ( struct user * ) malloc( sizeof( struct user ) * 1000 );
voidArray = ( void ** ) array;
*structByteSize = sizeof( struct user );
break;
default:
array = ( struct user * ) malloc( sizeof( struct user ) * 1000 );
voidArray = ( void ** ) array;
*structByteSize = sizeof( struct user );
}
}*/
char * getClassName( int classIndex ) {
return __ClassNames[ classIndex ];
}
int getClassIndexByClassName( char * className ) {
for (int i = 0; i < TOTAL_CLASS_COUNT; ++i)
{
char * currentClassName = __ClassNames[ i ];
if( strcmp( className, currentClassName ) == 0 ) {
//printf("find classname: %s\n", className);
return i;
}
}
return -1;
}
int getPropertyCountByClassIndex( int classIndex ) {
return __ClassPropertyCount[ classIndex ];
}
char * * getPropertiesByClassIndex( int classIndex ) {
return __ClassPropertyNames[ classIndex ];
}
int * getPropertyOffsetsByClassIndex( int classIndex ) {
return __ClassPropertyOffsets[ classIndex ];
}
int getPropertyOffsetByPropertyIndex( int * propertyOffsets, int propertyIndex ) {
return propertyOffsets[ propertyIndex ];
}
int * getPropertyDatatypeIndexesByClassIndex( int classIndex ) {
return __ClassPropertyDatatypeIndices[ classIndex ];
}
int getPropertyDatatypeIndex( int * propertyDatatypeIndices, int propertyIndex ) {
return propertyDatatypeIndices[ propertyIndex ];
}
int getPropertyIndexByPropertyName( int classID, char * propertyName ) {
int propertyCount = getPropertyCountByClassIndex( classID );
char * * propertyNames = getPropertiesByClassIndex( classID );
for (int i = 0; i < propertyCount; ++i)
{
char * propertyNameCompare = propertyNames[i];
if( strcmp( propertyName, propertyNameCompare ) == 0 ) {
return i;
}
}
return -1;
}

View File

@@ -0,0 +1,86 @@
#ifndef __classConfiguration
#define __classConfiguration
#include <stddef.h>
#include <opengl.h>
#include <unsignedIntegerArray.h>
#include <vector2.h>
#include <vector3.h>
#include <text.h>
#include <array.h>
#include <char.h>
#include <floatArray.h>
#include <shader.h>
#include <fileSystem.h>
#include <console.h>
#include <http.h>
#include <headers.h>
#include <header.h>
#include <request.h>
#include <mimeTypes.h>
#include <mesh.h>
#include <street.h>
#include <toolset.h>
#include <extends.h>
#include <int.h>
#include <sqlite.h>
#include <triangle.h>
#include <user.h>
#define TOTAL_CLASS_COUNT 30
extern char * __ClassNames[TOTAL_CLASS_COUNT];
extern int __ClassPropertyCount[TOTAL_CLASS_COUNT];
extern char * __ClassPropertyNames[TOTAL_CLASS_COUNT][30];
extern int __ClassPropertyOffsets[TOTAL_CLASS_COUNT][30];
extern int __ClassPropertyOffsets[TOTAL_CLASS_COUNT][30];
#include <string.h>
int getPropertyIndexOfClassIndex( int propertyCount, char ** propertyNames );
void getArrayByClassIndex( int size, void * * voidArray, int * structByteSize, int classIndex );
int getClassIndexByClassName( char * className );
char * getClassName( int classIndex );
int getPropertyCountByClassIndex( int classIndex );
char * * getPropertiesByClassIndex( int classIndex );
int * getPropertyOffsetsByClassIndex( int classIndex );
int getPropertyOffsetByPropertyIndex( int * propertyOffsets, int propertyIndex );
int getPropertyIndexByPropertyName( int classID, char * propertyName );
int * getPropertyDatatypeIndexesByClassIndex( int classIndex );
int getPropertyDatatypeIndex( int * propertyDatatypeIndices, int propertyIndex );
#endif

View File

@@ -0,0 +1,273 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <console.h>
struct consoleManager * console;
char * consoleManager_whiteSpace( consoleManager * this, int whiteSpaceCount ) {
char * output = malloc( whiteSpaceCount + 1 );
for (int i = 0; i < whiteSpaceCount; ++i)
{
strcat( output, " " );
}
output[whiteSpaceCount] = 0;
return output;
}
void consoleManager_logObject( consoleManager * this, void * voidPointer, int classIndex, int level ) {
char * whiteSpace = consoleManager_whiteSpace( this, level );
level++;
char * className = getClassName( classIndex );
printf( "\n\n" );
printf( whiteSpace );
printf(" %s : {\n", className );
char * * propertyNames = getPropertiesByClassIndex( classIndex );
int propertyCount = getPropertyCountByClassIndex( classIndex );
int * propertyOffsets = getPropertyOffsetsByClassIndex( classIndex );
int * datatypeIndices = getPropertyDatatypeIndexesByClassIndex( classIndex );
char * pointer = voidPointer;
for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex)
{
char * propertyName = propertyNames[propertyIndex];
printf( whiteSpace );
printf(" %-20s : ", propertyName);
int propertyDatatypeIndex = getPropertyDatatypeIndex( datatypeIndices, propertyIndex );
int propertyOffset = getPropertyOffsetByPropertyIndex( propertyOffsets, propertyIndex );
if( propertyDatatypeIndex == -5 ) {
int value = *( int * )(pointer + propertyOffset);
printf( whiteSpace );
printf("%-20i ", value );
} else if( propertyDatatypeIndex == -3 ) {
uintptr_t * value = ( uintptr_t * ) ( pointer + propertyOffset );
printf( whiteSpace );
printf( "%-20s", ( char * ) * value );
} else if( propertyDatatypeIndex > 0 ) {
char * memberClassName = getClassName( propertyDatatypeIndex );
if( strcmp( memberClassName, "array" ) == 0 ) {
struct array * memberArray = *(struct array ** )(pointer + propertyOffset) ;
if( memberArray == NULL ) {
printf(" this has to be fixed, array is not created.\n");
continue;
}
int numberRows = array_length( memberArray );
int * arrayPointer = ( int * ) memberArray->items;
for (int k = 0; k < numberRows; ++k)
{
void * pointer = array_get( memberArray, k );
short * row = (short*)(pointer);
consoleManager_logObject( this, pointer, (int) *row, level );
}
}
}
printf("\n");
}
printf( whiteSpace );
printf( " }\n" );
}
void consoleManager_log( consoleManager * this, int count, int datatypes[], ... ) {
int level = 0;
va_list args;
va_start( args, count );
for (int i = 0; i < count; ++i)
{
int datatype = datatypes[i];
if( datatype == -2 ) {
char * message = va_arg( args, char * );
printf("%s", message);
}
if( datatype == -1 ) {
int message = va_arg( args, int );
printf("%i", message);
}
if( datatype > 0 ) {
void * voidPointer = va_arg( args, void * );
consoleManager_logObject( this, voidPointer, datatype, level++ );
}
printf(" ");
}
printf("\n");
va_end( args);
}
void consoleManager_error( consoleManager * this, char * message ) {
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_DIM_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_RESET "\x1b[0m"
#define ANSI_COLOR_BRIGHT_YELLOW "\x1b[93m"
printf( ANSI_COLOR_RED );
printf( "\n\n Error: " );
printf( "%s\n\n", message );
printf( ANSI_COLOR_RESET );
exit( 0 );
}
void consoleManager_createHorisontalLine( consoleManager * this ) {
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
for (int i = 0; i < w.ws_col; ++i)
{
printf("-");
};
printf("\n");
}
consoleManager consoleManager_new() {
consoleManager instance;
instance.__classIndex = 12;
return instance;
}
consoleManager * consoleManager_newPointer() {
struct consoleManager * pointer = malloc( sizeof ( struct consoleManager ) );
pointer->__classIndex = 12;
return pointer;
}

View File

@@ -0,0 +1,60 @@
#ifndef _console
#define _console
// Macros
# define isCompatible(x, type) _Generic(x, type: true, default: false)
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdbool.h>
#include <classConfiguration.h>
typedef struct consoleManager{
unsigned short __classIndex;
} consoleManager;
char * consoleManager_whiteSpace( consoleManager * this, int whiteSpaceCount );
void consoleManager_logObject( consoleManager * this, void * voidPointer, int classIndex, int level );
void consoleManager_log( consoleManager * this, int count, int datatypes[], ... );
void consoleManager_error( consoleManager * this, char * message );
void consoleManager_createHorisontalLine( consoleManager * this );
extern struct consoleManager * console;
consoleManager consoleManager_new( );
consoleManager * consoleManager_newPointer( );
#endif

View File

@@ -0,0 +1,7 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <define.h>

View File

@@ -0,0 +1,20 @@
#ifndef _define
#define _define
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#endif

View File

@@ -0,0 +1,222 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <extends.h>
void classB_methodFromC( struct inherit * this ) {
printf("Please print much much..");
}
void inherit_methodFromC( struct inherit * this ) {
printf("Don't print soo much...");
}
void classA_methodFromC( struct inherit * this ) {
printf("Don't print soo much...");
}void inherit_methodFromA( struct inherit * this ) {
printf("this is a method from a\n\n");
printf("from a: a : %i\n", this->propertyFromA);
printf("from a: b : %i\n", this->propertyFromB);
printf("from a: c : %i\n", this->propertyFromC);
}
void inherit_methodFromB( struct inherit * this ) {
printf("this is a method from b\n\n");
printf("from b: a : %i\n", this->propertyFromA);
printf("from b: b : %i\n", this->propertyFromB);
printf("from b: c : %i\n", this->propertyFromC);
}
void a_methodFromA( struct inherit * this ) {
printf("this is a method from a\n\n");
printf("from a: a : %i\n", this->propertyFromA);
printf("from a: b : %i\n", this->propertyFromB);
printf("from a: c : %i\n", this->propertyFromC);
}
void a_methodFromB( struct inherit * this ) {
printf("this is a method from b\n\n");
printf("from b: a : %i\n", this->propertyFromA);
printf("from b: b : %i\n", this->propertyFromB);
printf("from b: c : %i\n", this->propertyFromC);
}void b_methodFromB( struct inherit * this ) {
printf("this is a method from b\n\n");
printf("from b: a : %i\n", this->propertyFromA);
printf("from b: b : %i\n", this->propertyFromB);
printf("from b: c : %i\n", this->propertyFromC);
}
b b_new() {
b instance;
instance.__classIndex = 21;
instance.propertyFromB = 1234;
return instance;
}
b * b_newPointer() {
struct b * pointer = malloc( sizeof ( struct b ) );
pointer->__classIndex = 21;
pointer->propertyFromB = 1234;
return pointer;
}
a a_new() {
a instance;
instance.__classIndex = 22;
instance.propertyFromA = 10;
instance.propertyFromB = 1234;
return instance;
}
a * a_newPointer() {
struct a * pointer = malloc( sizeof ( struct a ) );
pointer->__classIndex = 22;
pointer->propertyFromA = 10;
pointer->propertyFromB = 1234;
return pointer;
}
inherit inherit_new() {
inherit instance;
instance.__classIndex = 23;
instance.propertyFromC = 100;
instance.propertyFromA = 10;
instance.propertyFromB = 1234;
return instance;
}
inherit * inherit_newPointer() {
struct inherit * pointer = malloc( sizeof ( struct inherit ) );
pointer->__classIndex = 23;
pointer->propertyFromC = 100;
pointer->propertyFromA = 10;
pointer->propertyFromB = 1234;
return pointer;
}
classA classA_new() {
classA instance;
instance.__classIndex = 24;
instance.propertyFromC = 100;
return instance;
}
classA * classA_newPointer() {
struct classA * pointer = malloc( sizeof ( struct classA ) );
pointer->__classIndex = 24;
pointer->propertyFromC = 100;
return pointer;
}
classB classB_new() {
classB instance;
instance.__classIndex = 25;
instance.propertyFromC = 111;
return instance;
}
classB * classB_newPointer() {
struct classB * pointer = malloc( sizeof ( struct classB ) );
pointer->__classIndex = 25;
pointer->propertyFromC = 111;
return pointer;
}

View File

@@ -0,0 +1,107 @@
#ifndef _extends
#define _extends
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <stdio.h>
typedef struct b{
unsigned short __classIndex;
int propertyFromB;
} b;
void b_methodFromB( struct inherit * this );
typedef struct a{
unsigned short __classIndex;
int propertyFromA;
int propertyFromB;
} a;
void a_methodFromA( struct inherit * this );
void a_methodFromB( struct inherit * this );
typedef struct inherit{
unsigned short __classIndex;
int propertyFromC;
int propertyFromA;
int propertyFromB;
} inherit;
void inherit_methodFromC( struct inherit * this );
void inherit_methodFromA( struct inherit * this );
void inherit_methodFromB( struct inherit * this );
typedef struct classA{
unsigned short __classIndex;
int propertyFromC;
} classA;
void classA_methodFromC( struct inherit * this );
typedef struct classB{
unsigned short __classIndex;
int propertyFromC;
} classB;
void classB_methodFromC( struct inherit * this );
b b_new( );
b * b_newPointer( );
a a_new( );
a * a_newPointer( );
inherit inherit_new( );
inherit * inherit_newPointer( );
classA classA_new( );
classA * classA_newPointer( );
classB classB_new( );
classB * classB_newPointer( );
#endif

View File

@@ -0,0 +1,263 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <fileSystem.h>
struct fileSystem * filesystem;
void fileSystem_writeFile( fileSystem * this, char * filepath, char * data ) {
FILE *fp = fopen( filepath, "wb" );
if (fp != NULL)
{
fputs( data, fp );
fclose( fp );
}
}
struct array * fileSystem_readDir( fileSystem * this, char * filePath ) {
DIR * dir;
struct dirent * entry;
struct array * files = array_newPointer();
if ( ( dir = opendir( filePath ) ) == NULL ){
perror("opendir() error");
} else {
while( ( entry = readdir( dir ) ) != NULL ) {
char * filename = (char *)entry->d_name;
if ( strcmp( filename, ".." ) != 0 && strcmp( filename, "." ) != 0 ) {
array_add( files, filename );
}
}
}
return files;
}
struct text * fileSystem_readFile( fileSystem * this, char * name, char * mode ) {
char * readMode;
if( char_operator_compare( mode , "utf8") ) {
readMode = "r";
} else {
readMode = "rb";
}
FILE * file = fopen( name, readMode );
if ( file == NULL ) {
fprintf( stderr, "Error: Can't open file '%s'.", name );
exit( EXIT_FAILURE );
}
fseek( file, 0, SEEK_END );
long length = ftell( file );
fseek( file, 0, SEEK_SET );
char * buffer = malloc( sizeof( char ) * ( length + 1 ) );
fread( buffer, sizeof( char ), length, file );
fclose( file );
if( char_operator_compare( mode , "utf8") ) {
buffer[ length ] = 0;
}
text * output = text_newPointer( "" );
output->length = 0;
text_appendBinary( output, buffer, length );
return output;
}
char * fileSystem_readBinaryFile( fileSystem * this, char * name, char * mode, int * size ) {
char * readMode;
if( char_operator_compare( mode , "utf8") ) {
readMode = "r";
} else {
readMode = "rb";
printf("readmode = rb binary\n\n");
}
FILE * file = fopen( name, readMode );
if ( file == NULL ) {
fprintf( stderr, "Error: Can't open file '%s'.", name );
exit( EXIT_FAILURE );
}
fseek( file, 0, SEEK_END );
long length = ftell( file );
printf("buffer length is '%i' \n\n", length);
fseek( file, 0, SEEK_SET );
char * buffer = malloc( sizeof( char ) * ( length + 1 ) );
buffer[ length ] = '\0';
fread( buffer, sizeof( char ), length, file );
fclose( file );
*size = length;
printf("strlen: %i \n\n", length);
return buffer;
}
int fileSystem_ensureDirectory( fileSystem * this, char * path ) {
char * pathCopy = char_copy( path );
struct array * parts = char_split( pathCopy, "/" );
int count = array_length( parts );
for ( int i = 1; i < count; ++i )
{
struct array * tempParts = char_split( pathCopy, "/" );
for ( int j = 0; j < count-i-1; ++j )
{
array_pop( tempParts );
}
char * tempPath = array_join( tempParts, "/" );
if( fileSystem_exists( this, tempPath ) ) {
} else {
fileSystem_makeDirectory( this, tempPath );
}
}
return 1;
}
int fileSystem_makeDirectory( fileSystem * this, char * path ) {
if ( fileSystem_exists( this, path ) == NULL ) {
mkdir( path, 0700 );
}
return 1;
}
int fileSystem_exists( fileSystem * this, char * path ) {
if ( access( path, F_OK ) == 0 ) {
return 1;
} else {
return 0;
}
}
fileSystem fileSystem_new() {
fileSystem instance;
instance.__classIndex = 11;
return instance;
}
fileSystem * fileSystem_newPointer() {
struct fileSystem * pointer = malloc( sizeof ( struct fileSystem ) );
pointer->__classIndex = 11;
return pointer;
}

View File

@@ -0,0 +1,67 @@
#ifndef _fileSystem
#define _fileSystem
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include <char.h>
#include <console.h>
#include <array.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <http.h>
typedef struct fileSystem{
unsigned short __classIndex;
} fileSystem;
void fileSystem_writeFile( fileSystem * this, char * filepath, char * data );
struct array * fileSystem_readDir( fileSystem * this, char * filePath );
struct text * fileSystem_readFile( fileSystem * this, char * name, char * mode );
char * fileSystem_readBinaryFile( fileSystem * this, char * name, char * mode, int * size );
int fileSystem_ensureDirectory( fileSystem * this, char * path );
int fileSystem_makeDirectory( fileSystem * this, char * path );
int fileSystem_exists( fileSystem * this, char * path );
extern struct fileSystem * filesystem;
fileSystem fileSystem_new( );
fileSystem * fileSystem_newPointer( );
#endif

View File

@@ -0,0 +1,197 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <floatArray.h>
int floatArray_length( floatArray * this ) {
return this->total;
}
float floatArray_get( floatArray * this, int index ) {
if ( index >= 0 && index < this->total ){
return this->items[index];
}
return NULL;
}
void floatArray_set( floatArray * this, int index, float item ) {
if ( index >= 0 && index < this->total ){
this->items[ index ] = item;
}
}
void floatArray_resize( floatArray * this, int capacity ) {
float * items = realloc( this->items, sizeof( float ) * capacity );
this->items = items;
this->capacity = capacity;
}
void floatArray_addVector2( floatArray * this, struct vector2 * item ) {
floatArray_add( this, item->x );
floatArray_add( this, item->y );
}
void floatArray_addVector3( floatArray * this, struct vector3 * item ) {
floatArray_add( this, item->x );
floatArray_add( this, item->y );
floatArray_add( this, item->z );
}
void floatArray_add( floatArray * this, float item ) {
if ( this->capacity == this->total ){
floatArray_resize( this, this->capacity * 2 );
}
this->items[ this->total++ ] = item;
}
void floatArray_delete( floatArray * this, int index ) {
if ( index < 0 || index >= this->total ){
return;
}
this->items[index] = NULL;
for ( int i = index; i < this->total - 1; i++ ) {
this->items[i] = this->items[i + 1];
this->items[i + 1] = NULL;
}
this->total--;
if ( this->total > 0 && this->total == this->capacity / 4 ){
floatArray_resize( this, this->capacity / 2 );
}
}
int floatArray_array_push( floatArray * this, float item ) {
floatArray_add( this, item );
return this->total;
}
void floatArray_unshift( floatArray * this, float item ) {
int length = this->total;
this->total++;
if ( this->capacity == this->total ){
floatArray_resize( this, this->capacity * 2 );
}
for ( int i = length - 1; i >= 0; --i ) {
this->items[ i + 1 ] = this->items[ i ];
}
this->items[ 0 ] = item;
}
float floatArray_pop( floatArray * this ) {
int length = this->total;
int lastIndex = length - 1;
float lastItem = floatArray_get( this, lastIndex );
floatArray_delete( this, lastIndex );
return lastItem;
}
floatArray floatArray_new() {
floatArray instance;
instance.__classIndex = 7;
instance.capacity = 10;
instance.total = 0;
instance.items = malloc( 10000000 );
return instance;
}
floatArray * floatArray_newPointer() {
struct floatArray * pointer = malloc( sizeof ( struct floatArray ) );
pointer->__classIndex = 7;
pointer->capacity = 10;
pointer->total = 0;
pointer->items = malloc( 10000000 );
return pointer;
}

View File

@@ -0,0 +1,67 @@
#ifndef _floatArray
#define _floatArray
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <vector2.h>
#include <vector3.h>
#include <text.h>
#include <char.h>
#include <stdlib.h>
typedef struct floatArray{
unsigned short __classIndex;
int capacity;
int total;
float * items;
} floatArray;
int floatArray_length( floatArray * this );
float floatArray_get( floatArray * this, int index );
void floatArray_set( floatArray * this, int index, float item );
void floatArray_resize( floatArray * this, int capacity );
void floatArray_addVector2( floatArray * this, struct vector2 * item );
void floatArray_addVector3( floatArray * this, struct vector3 * item );
void floatArray_add( floatArray * this, float item );
void floatArray_delete( floatArray * this, int index );
int floatArray_array_push( floatArray * this, float item );
void floatArray_unshift( floatArray * this, float item );
float floatArray_pop( floatArray * this );
floatArray floatArray_new( );
floatArray * floatArray_newPointer( );
#endif

View File

@@ -0,0 +1,27 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <header.h>
header header_new() {
header instance;
instance.__classIndex = 15;
return instance;
}
header * header_newPointer() {
struct header * pointer = malloc( sizeof ( struct header ) );
pointer->__classIndex = 15;
return pointer;
}

View File

@@ -0,0 +1,33 @@
#ifndef _header
#define _header
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
typedef struct header{
unsigned short __classIndex;
char * name;
char * value;
} header;
header header_new( );
header * header_newPointer( );
#endif

View File

@@ -0,0 +1,190 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <headers.h>
void headerManager_parse( headerManager * this, char * headerContent ) {
array * headerRows = char_split( headerContent, "\n");
int headerCount = array_length( headerRows );
for (int i = 1; i < headerCount; ++i)
{
char * headerRow = array_get( headerRows, i );
array * headerRowParts = char_split( headerRow, ":");
int headerRowPartsCount = array_length( headerRowParts );
if( headerRowPartsCount == 2 ) {
char * headerName = array_get( headerRowParts, 0 );
char * headerValue = array_get( headerRowParts, 1 );
headerManager_add( this, headerName, char_removeWhitespace( headerValue ) );
}
}
printf("\n\n");
}
void headerManager_display( headerManager * this ) {
struct array * headerRows = this->headers;
int headerCount = array_length( headerRows );
for (int i = 0; i < headerCount; ++i)
{
struct header * headerInstance = array_get( headerRows, i );
printf("%-20s %-30s \n", headerInstance->name, headerInstance->value);
}
}
void headerManager_add( headerManager * this, char * name, char * value ) {
header * headerInstance = header_newPointer();
headerInstance->name = name;
headerInstance->value = value;
array_add( this->headers, headerInstance );
}
void headerManager_set( headerManager * this, char * name, char * value ) {
struct header * headerInstance = headerManager_get( this, name );
if( headerInstance == NULL ) {
headerManager_add( this, name, value );
} else {
int headerIndex = headerManager_getHeaderIndex( this, name );
array * headers = this->headers;
header * headerInstance = array_get( headers, headerIndex );
headerInstance->value = value;
}
}
int headerManager_getHeaderIndex( headerManager * this, char * name ) {
array * headers = this->headers;
int count = array_length( headers );
for (int i = 0; i < count; ++i)
{
header * headerInstance = array_get( headers, i );
if( char_operator_compare( headerInstance->name , name) ) {
return i;
}
}
return -1;
}
char * headerManager_getValue( headerManager * this, char * name ) {
array * headers = this->headers;
int count = array_length( headers );
for (int i = 0; i < count; ++i)
{
header * headerInstance = array_get( headers, i );
if( char_operator_compare( headerInstance->name , name) ) {
return headerInstance->value;
}
}
return NULL;
}
header * headerManager_get( headerManager * this, char * name ) {
array * headers = this->headers;
int count = array_length( headers );
for (int i = 0; i < count; ++i)
{
header * headerInstance = array_get( headers, i );
if( char_operator_compare( headerInstance->name , name) ) {
return headerInstance;
}
}
return NULL;
}
headerManager headerManager_new() {
headerManager instance;
instance.__classIndex = 14;
instance.headers = array_newPointer();
return instance;
}
headerManager * headerManager_newPointer() {
struct headerManager * pointer = malloc( sizeof ( struct headerManager ) );
pointer->__classIndex = 14;
pointer->headers = array_newPointer();
return pointer;
}

View File

@@ -0,0 +1,49 @@
#ifndef _headers
#define _headers
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include "header.h"
#include "array.h"
typedef struct headerManager{
unsigned short __classIndex;
struct array * headers;
} headerManager;
void headerManager_parse( headerManager * this, char * headerContent );
void headerManager_display( headerManager * this );
void headerManager_add( headerManager * this, char * name, char * value );
void headerManager_set( headerManager * this, char * name, char * value );
int headerManager_getHeaderIndex( headerManager * this, char * name );
char * headerManager_getValue( headerManager * this, char * name );
header * headerManager_get( headerManager * this, char * name );
headerManager headerManager_new( );
headerManager * headerManager_newPointer( );
#endif

547
application/target/http.c Normal file
View File

@@ -0,0 +1,547 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <http.h>
void http_createServer( http * this, void ( * requestCallback )( request * req, text * response ) ) {
this->requestCallback = requestCallback;
if( this->useSSL == 1 ) {
http_initializeOpenSSL( this );
}
printf("after initializeOpenSSL\n\n");
}
void http_initializeOpenSSL( http * this ) {
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
SSLeay_add_ssl_algorithms();
return;
}
int http_listen( http * this, int port ) {
this->socket = socket( AF_INET, SOCK_STREAM, 0 );
int iSetOption = 1;
setsockopt( this->socket, SOL_SOCKET, SO_REUSEADDR, ( char * ) & iSetOption, sizeof( iSetOption ) );
if ( this->socket == -1 ) {
perror("webserver (socket)");
exit( 0 );
} else {
printf("socket created successfully\n");
}
this->hostAddress->sin_family = AF_INET;
this->hostAddress->sin_port = htons( port );
this->hostAddress->sin_addr.s_addr = htonl( INADDR_ANY );
if ( bind( this->socket, ( struct sockaddr * ) this->hostAddress, this->hostAddresslength ) != 0 ) {
perror("webserver (bind)");
exit( 0 );
} else {
printf("socket successfully bound to address\n");
}
if ( listen( this->socket, SOMAXCONN ) != 0 ) {
perror("webserver (listen)");
exit( 0 );
} else {
printf("server listening for connections\n");
}
for (;;) {
http_acceptConnection( this );
}
printf("exit");
return 0;
}
char * http_getExtension( http * this, char * path ) {
array * parts = char_split( path, ".");
int count = array_length( parts );
return array_get( parts, count - 1 );
}
void http_logRequest( http * this, request * requestInstance ) {
printf("server address: [%s:%u]\n", requestInstance->address, requestInstance->port );
printf("mimeType: %-30s \n", requestInstance->mimeType);
printf("header: %-30s \n", requestInstance->extension );
printf("method: %-30s \n", requestInstance->method );
printf("version: %-30s \n\n", requestInstance->version );
}
void http_acceptConnection( http * this ) {
fileSystem * filesystem = this->filesystem;
mimeTypes * mimetypes = this->mimetypes;
text * response = text_newPointer("");
char buffer[ 4096 ];
struct sockaddr_in client_addr;
int client_addrlen = sizeof(client_addr);
int socketConnection = accept( this->socket,
(struct sockaddr *)this->hostAddress,
( socklen_t * ) & this->hostAddresslength );
SSL * ssl = NULL;
if( this->useSSL == 1 ) {
const SSL_METHOD * method = SSLv23_server_method();
this->sslContext = SSL_CTX_new( method );
if ( this->sslContext == NULL ) {
printf("Error loading SSL_CTX_NEW '%s'\n\n", stderr);
}
SSL_CTX_set_options( this->sslContext, SSL_OP_SINGLE_DH_USE );
int use_cert = SSL_CTX_use_certificate_file( this->sslContext, "/etc/letsencrypt/live/unifyjs.org/fullchain.pem" , SSL_FILETYPE_PEM );
int use_prv = SSL_CTX_use_PrivateKey_file( this->sslContext, "/etc/letsencrypt/live/unifyjs.org/privkey.pem", SSL_FILETYPE_PEM );
if( use_cert != 1 ) {
printf( "error: SSL_CTX_use_certificate_file\n\n" );
}
if( use_prv != 1 ) {
printf( "error: SSL_CTX_use_PrivateKey_file\n\n" );
}
if ( !SSL_CTX_check_private_key(this->sslContext) ) {
printf("Private key does not match the certificate public key\n");
}
ssl = SSL_new( this->sslContext );
SSL_set_fd( ssl, socketConnection );
int ssl_err = SSL_accept( ssl );
if( ssl_err == 0 ){
printf("SSL_accept returned zero\n");
}
int n;
if( ssl_err < 0 ) {
int err;
if( ( err = SSL_get_error(ssl,n ) ) == SSL_ERROR_WANT_READ) {
printf("SSL_accept wants more data\n");
return ;
}
exit(7);
}
} else {
printf("connection accepted\n\n");
int sockn = getsockname( socketConnection,
( struct sockaddr * ) &client_addr,
( socklen_t * ) &client_addrlen);
if ( sockn == -1 ) {
perror("webserver (getsockname)");
}
}
int valread;
if( this->useSSL == 1 ) {
valread = SSL_read( ssl, buffer, 4096 - 1 );
} else {
printf("read without ssl\n\n");
int valread = read( socketConnection, buffer, 4096 -1 );
if ( valread == -1 ) {
perror("webserver (read)");
}
}
if ( valread == -1 ) {
perror("webserver (read)");
}
request * requestInstance = request_newPointer();
sscanf( buffer, "%s %s %s", requestInstance->method, requestInstance->url, requestInstance->version );
requestInstance->address = inet_ntoa( client_addr.sin_addr );
requestInstance->port = ntohs( client_addr.sin_port );
requestInstance->extension = http_getExtension( this, requestInstance->url );
requestInstance->mimeType = mimeTypes_getByExtension( mimetypes, requestInstance->extension );
this->requestCallback( requestInstance, response );
int writeResponse;
if( this->useSSL == 1 ) {
writeResponse = SSL_write( ssl, response->value, response->length );
} else {
int writeResponse = write( socketConnection, response->value, response->length );
printf("close connection");
if ( writeResponse == -1 ) {
perror("webserver (write)");
return;
}
}
if ( writeResponse == -1 ) {
perror("webserver (write)");
return;
} else {
}
close( socketConnection );
}
void http_dump_buffer( http * this, void *buffer, int buffer_size ) {
int i;
for(i = 0;i < buffer_size;++i){
printf( "%c", ( (char *) buffer )[i]);
}
}
void abort( ) {
}
http http_new() {
http instance;
instance.__classIndex = 13;
instance.hostAddress = malloc( sizeof( struct sockaddr_in ) );
instance.hostAddresslength = sizeof( struct sockaddr_in );
instance.filesystem = fileSystem_newPointer();
instance.mimetypes = mimeTypes_newPointer();
instance.headers = headerManager_newPointer();
instance.useSSL = 1;
return instance;
}
http * http_newPointer() {
struct http * pointer = malloc( sizeof ( struct http ) );
pointer->__classIndex = 13;
pointer->hostAddress = malloc( sizeof( struct sockaddr_in ) );
pointer->hostAddresslength = sizeof( struct sockaddr_in );
pointer->filesystem = fileSystem_newPointer();
pointer->mimetypes = mimeTypes_newPointer();
pointer->headers = headerManager_newPointer();
pointer->useSSL = 1;
return pointer;
}

91
application/target/http.h Normal file
View File

@@ -0,0 +1,91 @@
#ifndef _http
#define _http
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <sys/resource.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <headers.h>
#include <request.h>
#include <unistd.h>
#include <sys/socket.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <arpa/inet.h>
#include "./mimeTypes.h"
#include "./text.h"
#include "./fileSystem.h"
typedef struct http{
unsigned short __classIndex;
int socket;
struct sockaddr_in * hostAddress;
int hostAddresslength;
struct fileSystem * filesystem;
struct mimeTypes * mimetypes;
struct headerManager * headers;
int useSSL;
SSL_CTX * sslContext;
void ( * requestCallback )( struct request * requestInstance, struct text * response );
} http;
void http_createServer( http * this, void ( * requestCallback )( request * req, text * response ) );
void http_initializeOpenSSL( http * this );
int http_listen( http * this, int port );
char * http_getExtension( http * this, char * path );
void http_logRequest( http * this, request * requestInstance );
void http_acceptConnection( http * this );
void http_dump_buffer( http * this, void *buffer, int buffer_size );
void abort( );
http http_new( );
http * http_newPointer( );
#endif

21
application/target/int.c Normal file
View File

@@ -0,0 +1,21 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <int.h>
char * int_toText( int * this ) {
char * textNumber = malloc( sizeof( char ) * 20 );
sprintf( textNumber, "%d", this );
return textNumber;
}
int int_negative( int * this ) {
return 12;
}

24
application/target/int.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef _int
#define _int
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <stdio.h>
char * int_toText( int * this );
int int_negative( int * this );
#endif

365
application/target/mesh.c Normal file
View File

@@ -0,0 +1,365 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <mesh.h>
void mesh_createBuffers( mesh * this ) {
struct unsignedIntegerArray * indices = unsignedIntegerArray_newPointer();
struct floatArray * textureCoordinates = floatArray_newPointer();
struct floatArray * vertexCoordinates = floatArray_newPointer();
struct floatArray * normalCoordinates = floatArray_newPointer();
struct unsignedIntegerArray * meshIndices = unsignedIntegerArray_newPointer();
int subdivisionsDepth = 1;
int subdivisionsWidth = 1;
float width = 2;
float depth = 2;
int meshCount = 100 * 50;
int meshStartIndex = 0;
for (int meshIndex = 0; meshIndex < meshCount; ++meshIndex)
{
meshStartIndex = unsignedIntegerArray_length( meshIndices );
int numVertsAcross = subdivisionsWidth + 1;
for ( int z = 0; z < subdivisionsDepth; z++ ) {
for ( int x = 0; x < subdivisionsWidth; x++ ) {
unsignedIntegerArray_add( indices, ( z + 0 ) * numVertsAcross + x + meshStartIndex );
unsignedIntegerArray_add( indices, ( z + 1 ) * numVertsAcross + x + meshStartIndex );
unsignedIntegerArray_add( indices, ( z + 0 ) * numVertsAcross + x + 1 + meshStartIndex );
unsignedIntegerArray_add( indices, ( z + 1 ) * numVertsAcross + x + meshStartIndex );
unsignedIntegerArray_add( indices, ( z + 1 ) * numVertsAcross + x + 1 + meshStartIndex );
unsignedIntegerArray_add( indices, ( z + 0 ) * numVertsAcross + x + 1 + meshStartIndex );
}
}
for ( int z = 0; z <= subdivisionsDepth; z++ ) {
for ( int x = 0; x <= subdivisionsWidth; x++ ) {
float u = ( float ) x;
float v = ( float ) z;
floatArray_add( textureCoordinates, u );
floatArray_add( textureCoordinates, ( 1 - v ) );
floatArray_add( vertexCoordinates, width * u - width * 0.5 );
floatArray_add( vertexCoordinates, depth * v - depth * 0.5 );
floatArray_add( vertexCoordinates, 0 );
floatArray_add( normalCoordinates, 0 );
floatArray_add( normalCoordinates, 0 );
floatArray_add( normalCoordinates, 1 );
unsignedIntegerArray_add( meshIndices, meshIndex );
}
}
}
int vertexBufferSize = floatArray_length( vertexCoordinates ) * sizeof( float );
glGenBuffers( 1, &this->vertexbuffer );
glBindBuffer( GL_ARRAY_BUFFER, this->vertexbuffer );
glBufferData( GL_ARRAY_BUFFER, vertexBufferSize, vertexCoordinates->items, GL_STATIC_DRAW );
int meshIndexBufferSize = unsignedIntegerArray_length( meshIndices ) * sizeof( unsigned int );
glGenBuffers( 1, &this->meshIndexBuffer );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, this->meshIndexBuffer );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, meshIndexBufferSize, meshIndices->items, GL_STATIC_DRAW );
int textureCoordinateSize = floatArray_length( textureCoordinates ) * sizeof( float );
glGenBuffers( 1, &this->textureCoordinateBuffer );
glBindBuffer( GL_ARRAY_BUFFER, this->textureCoordinateBuffer );
glBufferData( GL_ARRAY_BUFFER, textureCoordinateSize, textureCoordinates->items, GL_STATIC_DRAW );
int indexBufferSize = unsignedIntegerArray_length( indices ) * sizeof( unsigned int );
glGenBuffers( 1, &this->indexBuffer );
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, this->indexBuffer );
glBufferData( GL_ELEMENT_ARRAY_BUFFER, indexBufferSize, indices->items, GL_STATIC_DRAW );
GLint compareSize = 0;
glGetBufferParameteriv( GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SIZE, &compareSize );
if( indexBufferSize != compareSize )
{
glDeleteBuffers(1, &this->indexBuffer);
printf("ERROR: size error");
return;
}
this->indices = indices;
this->textureCoordinates = textureCoordinates;
this->vertexCoordinates = vertexCoordinates;
this->normalCoordinates = normalCoordinates;
}
void mesh_createOrderedTriangleStripQuad( mesh * this ) {
}
void mesh_createBuffer( mesh * this, GLuint * buffer, int bufferSize, float * bufferData ) {
glGenBuffers( 1, buffer );
glBindBuffer( GL_ARRAY_BUFFER, this->vertexbuffer );
glBufferData( GL_ARRAY_BUFFER, bufferSize, bufferData, GL_STATIC_DRAW );
}
mesh mesh_new() {
mesh instance;
instance.__classIndex = 18;
return instance;
}
mesh * mesh_newPointer() {
struct mesh * pointer = malloc( sizeof ( struct mesh ) );
pointer->__classIndex = 18;
return pointer;
}

66
application/target/mesh.h Normal file
View File

@@ -0,0 +1,66 @@
#ifndef _mesh
#define _mesh
// Macros
#define GL_GLEXT_PROTOTYPES
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include "unsignedIntegerArray.h"
#include "floatArray.h"
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glext.h>
typedef struct mesh{
unsigned short __classIndex;
struct unsignedIntegerArray * indices;
struct floatArray * textureCoordinates;
struct floatArray * vertexCoordinates;
struct floatArray * normalCoordinates;
GLuint indexBuffer;
GLuint vertexbuffer;
GLuint textureCoordinateBuffer;
GLuint meshIndexBuffer;
GLuint uvBuffer;
} mesh;
void mesh_createBuffers( mesh * this );
void mesh_createOrderedTriangleStripQuad( mesh * this );
void mesh_createBuffer( mesh * this, GLuint * buffer, int bufferSize, float * bufferData );
mesh mesh_new( );
mesh * mesh_newPointer( );
#endif

View File

@@ -0,0 +1,97 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <mimeTypes.h>
void mimeTypes_constructor( mimeTypes * this ) {
mimeTypes_add( this, "html", "text/html");
mimeTypes_add( this, "css", "text/css");
mimeTypes_add( this, "ttf", "application/x-font-ttf");
mimeTypes_add( this, "png", "image/png");
mimeTypes_add( this, "svg", "image/svg+xml");
}
void mimeTypes_add( mimeTypes * this, char * extension, char * mimeType ) {
struct array * extensions = this->extensions;
array_add( extensions, extension );
struct array * mimeTypes = this->mimeTypes;
array_add( mimeTypes, mimeType );
}
char * mimeTypes_getByExtension( mimeTypes * this, char * extension ) {
struct array * extensions = this->extensions;
struct array * mimeTypes = this->mimeTypes;
int count = array_length( extensions );
for (int i = 0; i < count; ++i)
{
char * currentExtension = array_get( extensions, i );
if( char_operator_compare( currentExtension , extension) ) {
char * mimeType = array_get( mimeTypes, i );
return mimeType;
}
}
return "no-mimetype";
}
mimeTypes mimeTypes_new() {
mimeTypes instance;
instance.__classIndex = 17;
instance.extensions = array_newPointer();
instance.mimeTypes = array_newPointer();
mimeTypes_constructor( &instance);
return instance;
}
mimeTypes * mimeTypes_newPointer() {
struct mimeTypes * pointer = malloc( sizeof ( struct mimeTypes ) );
pointer->__classIndex = 17;
pointer->extensions = array_newPointer();
pointer->mimeTypes = array_newPointer();
mimeTypes_constructor( pointer );
return pointer;
}

View File

@@ -0,0 +1,41 @@
#ifndef _mimeTypes
#define _mimeTypes
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include "array.h"
typedef struct mimeTypes{
unsigned short __classIndex;
array * extensions;
array * mimeTypes;
} mimeTypes;
void mimeTypes_constructor( mimeTypes * this );
void mimeTypes_add( mimeTypes * this, char * extension, char * mimeType );
char * mimeTypes_getByExtension( mimeTypes * this, char * extension );
mimeTypes mimeTypes_new( );
mimeTypes * mimeTypes_newPointer( );
#endif

697
application/target/opengl.c Normal file
View File

@@ -0,0 +1,697 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <opengl.h>
static int DoubleBufferAttributes[] = {
GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 12,
GLX_DOUBLEBUFFER,
None,
};
void opengl_initialize( opengl * this ) {
opengl_setupWindow( this );
opengl_showVersion( this );
opengl_createShaders( this );
opengl_createQuad( this );
opengl_setupTime( this );
opengl_setupRenderLoop( this );
}
void opengl_showVersion( opengl * this ) {
printf("opengl version : %s\n\n", glGetString(GL_VERSION) );
}
void opengl_setupTime( opengl * this ) {
clock_gettime( CLOCK_REALTIME, &this->startTime );
}
void opengl_setupWindow( opengl * this ) {
this->mainDisplay = XOpenDisplay( 0 );
this->MainScreen = XDefaultScreen( this->mainDisplay );
this->RootWindow = XDefaultRootWindow( this->mainDisplay );
int empty;
int ResultStatus = glXQueryExtension( this->mainDisplay, &empty, &empty );
XVisualInfo* VisualInfo = glXChooseVisual( this->mainDisplay, this->MainScreen, DoubleBufferAttributes );
GLXContext ShareList = None;
int IsDirectRendering = True;
GLXContext OpenGLContext = glXCreateContext( this->mainDisplay, VisualInfo, ShareList, IsDirectRendering );
int WindowX = 0;
int WindowY = 0;
int WindowWidth = 800;
int WindowHeight = 600;
int BorderWidth = 0;
int WindowClass = InputOutput;
int WindowDepth = VisualInfo->depth;
Visual* WindowVisual = VisualInfo->visual;
int AttributeValueMask = CWBackPixel | CWEventMask | CWColormap;
XSetWindowAttributes WindowAttributes = {};
WindowAttributes.colormap = XCreateColormap( this->mainDisplay, this->RootWindow, VisualInfo->visual, AllocNone);
WindowAttributes.background_pixel = 0xffafe9af;
WindowAttributes.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask | PointerMotionMask;
this->mainWindow = XCreateWindow( this->mainDisplay, this->RootWindow,
WindowX, WindowY, WindowWidth, WindowHeight,
BorderWidth, WindowDepth, WindowClass, WindowVisual,
AttributeValueMask, &WindowAttributes);
XStoreName( this->mainDisplay, this->mainWindow, "Opengl: Fixed function pipeline" );
glXMakeCurrent( this->mainDisplay, this->mainWindow, OpenGLContext );
XMapWindow( this->mainDisplay, this->mainWindow );
Atom WM_DELETE_WINDOW = XInternAtom( this->mainDisplay, "WM_DELETE_WINDOW", False );
if( !XSetWMProtocols( this->mainDisplay, this->mainWindow, &WM_DELETE_WINDOW, 1) ) {
printf( "Couldn't register WM_DELETE_WINDOW\n" );
}
}
void opengl_setupRenderLoop( opengl * this ) {
int IsProgramRunning = 1;
while( IsProgramRunning ) {
while( XPending( this->mainDisplay ) ) {
XEvent GeneralEvent = {};
XNextEvent( this->mainDisplay, &GeneralEvent );
switch( GeneralEvent.type ) {
case ClientMessage:
{
IsProgramRunning = 0;
} break;
}
}
{
opengl_render( this );
}
}
}
void opengl_createShaders( opengl * this ) {
shader * currentShader = shader_newPointer();
shader_createFromFile( currentShader, "assets/shaders/color.vertex", "assets/shaders/color.fragment" );
vector3 * diffuseColor = vector3_newPointer( 0.0, 1.0, 0.0 );
shader_setUniform( currentShader, "diffuse", diffuseColor );
vector2 * position = vector2_newPointer( 1.0, 0.0 );
shader_setUniform( currentShader, "position", position );
this->currentShader = currentShader;
}
void opengl_createQuad( opengl * this ) {
this->quads = mesh_newPointer();
mesh_createBuffers( this->quads );
}
double opengl_clockToMilliseconds( opengl * this, clock_t ticks ) {
return ( ticks / ( double ) CLOCKS_PER_SEC );
}
void opengl_render( opengl * this ) {
Window qRoot;
Window qChild;
unsigned int qMask;
int childX;
int childY;
int mouseX;
int mouseY;
int child;
int windowX = 0;
int windowY = 0;
int windowWidth = 0;
int windowHeight = 0;
XWindowAttributes window;
if( XGetWindowAttributes( this->mainDisplay, this->mainWindow, &window ) ) {
}
if( XQueryPointer( this->mainDisplay, this->RootWindow, &qRoot, &qChild, &mouseX, &mouseY, &childX, &childY, &qMask ) )
{
mouseX -= window.x;
mouseY -= window.y;
for(int i = 0; i < sizeof(int) * 8; i++)
{
int mask = 1 << sizeof(int) * 8 - i - 1;
if(mask & qMask)
{
}
else
{
}
}
if( qMask == Button1MotionMask ) {
printf("LeftMouse\n");
}
if( qMask == Button2MotionMask ) {
printf("Button2MotionMask\n");
}
if( qMask == Button3MotionMask ) {
printf("RightMouse\n");
}
if( qMask == Button4MotionMask ) {
printf("Button2MotionMask\n");
}
if( qMask == Button5MotionMask ) {
printf("Button2MotionMask\n");
}
if( qMask == ShiftMask ) {
printf("Pressed shift\n");
}
if( qMask == ControlMask ) {
printf("Pressed control\n");
}
if( qMask == EnterWindowMask ) {
}
XEvent event;
int keyboardEventCount = XPending( this->mainDisplay );
while( XPending( this->mainDisplay ) ) {
XNextEvent( this->mainDisplay, &event );
switch ( event.type ) {
case KeyPress:
printf("key has been pressed. %i\n\n", event.xkey.keycode);
break;
case KeyRelease:
printf("key has been released. %i\n\n", event.xkey.keycode);
break;
case Expose:
break;
default:
}
}
}
opengl_clearColor( this, 0.0, 1.0, 0.6, 1.0 );
opengl_clear( this, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
float number = (float)(this->frameCount & 1000) / 1000;
shader * currentShader = this->currentShader;
vector2 * windowSize = vector2_newPointer( window.width, window.height );
vector2 * mouse = vector2_newPointer( mouseX, mouseY );
shader_setUniform( currentShader, "window", windowSize );
shader_setUniform( currentShader, "mouse", mouse );
int itemSize;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnableVertexAttribArray( 0 );
glEnableVertexAttribArray( 1 );
glEnableVertexAttribArray( 3 );
itemSize = 3;
glBindBuffer( GL_ARRAY_BUFFER, this->quads->vertexbuffer );
glVertexAttribPointer( 0, itemSize, GL_FLOAT, GL_FALSE, 0, ( void * ) 0 );
itemSize = 2;
glBindBuffer( GL_ARRAY_BUFFER, this->quads->textureCoordinateBuffer );
glVertexAttribPointer( 1, itemSize, GL_FLOAT, GL_FALSE, 0, ( void * ) 0 );
itemSize = 1;
glBindBuffer( GL_ARRAY_BUFFER, this->quads->meshIndexBuffer );
glVertexAttribPointer( 2, itemSize, GL_FLOAT, GL_FALSE, 0, ( void * ) 0 );
int numItems = 10000;
glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, this->quads->indexBuffer );
glDrawElements( GL_TRIANGLES, numItems, GL_UNSIGNED_INT, ( void * ) 0 );
glDisableVertexAttribArray( 0 );
glDisableVertexAttribArray( 1 );
opengl_end( this );
opengl_flush( this );
}
void opengl_displayFPS( opengl * this ) {
struct timespec now;
clock_gettime( CLOCK_REALTIME, &now );
this->frameCount++;
int elapsedTime = now.tv_sec - this->startTime.tv_sec;
if( elapsedTime != this->lastTime ) {
printf("%i fps.\n\n", this->frameCount );
this->lastTime = elapsedTime;
this->frameCount = 0;
}
}
void opengl_vertex2f( opengl * this, float x, float y ) {
glVertex2f( x, y );
}
void opengl_color3f( opengl * this, float r, float g, float b ) {
glColor3f( r, g, b );
}
void opengl_clear( opengl * this, GLbitfield mask ) {
glClear( mask );
}
void opengl_clearColor( opengl * this, float r, float g, float b, float a ) {
glClearColor( r, g, b, a );
}
void opengl_begin( opengl * this, GLenum mode ) {
glBegin( mode );
}
void opengl_end( opengl * this ) {
glEnd();
}
void opengl_flush( opengl * this ) {
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA;
PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress( (const GLubyte*)"glXSwapIntervalEXT");
if (glXSwapIntervalEXT != NULL) {
glXSwapIntervalEXT(this->mainDisplay, this->mainWindow, 0);
} else {
glXSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress( (const GLubyte*)"glXSwapIntervalMESA");
if ( glXSwapIntervalMESA != NULL ) {
glXSwapIntervalMESA(0);
} else {
glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddress( (const GLubyte*)"glXSwapIntervalSGI");
if ( glXSwapIntervalSGI != NULL ) {
glXSwapIntervalSGI(0);
}
}
}
glXSwapBuffers( this->mainDisplay, this->mainWindow );
}
opengl opengl_new() {
opengl instance;
instance.__classIndex = 0;
instance.lastTime = clock();
instance.deltaTime = 0;
instance.frameCount = 0;
return instance;
}
opengl * opengl_newPointer() {
struct opengl * pointer = malloc( sizeof ( struct opengl ) );
pointer->__classIndex = 0;
pointer->lastTime = clock();
pointer->deltaTime = 0;
pointer->frameCount = 0;
return pointer;
}

124
application/target/opengl.h Normal file
View File

@@ -0,0 +1,124 @@
#ifndef _opengl
#define _opengl
// Macros
#define HEIGHT 480
#define WIDTH 640
#define GL_GLEXT_PROTOTYPES
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <time.h>
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <stdlib.h>
#include <stdio.h>
#include "unsignedIntegerArray.h"
#include "floatArray.h"
#include "shader.h"
#include "mesh.h"
typedef struct opengl{
unsigned short __classIndex;
Display * mainDisplay;
Window mainWindow;
int MainScreen;
Window RootWindow;
int lastTime;
clock_t deltaTime;
struct timespec startTime;
int frameCount;
GLuint vertexbuffer;
GLuint indexBuffer;
struct shader * currentShader;
struct mesh * quads;
unsigned char image[HEIGHT][WIDTH];
} opengl;
void opengl_initialize( opengl * this );
void opengl_showVersion( opengl * this );
void opengl_setupTime( opengl * this );
void opengl_setupWindow( opengl * this );
void opengl_setupRenderLoop( opengl * this );
void opengl_createShaders( opengl * this );
void opengl_createQuad( opengl * this );
double opengl_clockToMilliseconds( opengl * this, clock_t ticks );
void opengl_render( opengl * this );
void opengl_displayFPS( opengl * this );
void opengl_vertex2f( opengl * this, float x, float y );
void opengl_color3f( opengl * this, float r, float g, float b );
void opengl_clear( opengl * this, GLbitfield mask );
void opengl_clearColor( opengl * this, float r, float g, float b, float a );
void opengl_begin( opengl * this, GLenum mode );
void opengl_end( opengl * this );
void opengl_flush( opengl * this );
static int DoubleBufferAttributes[] ;
opengl opengl_new( );
opengl * opengl_newPointer( );
#endif

View File

@@ -0,0 +1,116 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <request.h>
void request_constructor( request * this ) {
}
void request_free( request * this ) {
free( this );
}
request request_new() {
request instance;
instance.__classIndex = 16;
instance.connection = malloc( BUFFER_SIZE );
instance.address = malloc( BUFFER_SIZE );
instance.url = malloc( BUFFER_SIZE );
instance.method = malloc( BUFFER_SIZE );
instance.version = malloc( BUFFER_SIZE );
instance.mimeType = malloc( BUFFER_SIZE );
instance.extension = malloc( BUFFER_SIZE );
instance.headers = headerManager_newPointer();
request_constructor( &instance);
return instance;
}
request * request_newPointer() {
struct request * pointer = malloc( sizeof ( struct request ) );
pointer->__classIndex = 16;
pointer->connection = malloc( BUFFER_SIZE );
pointer->address = malloc( BUFFER_SIZE );
pointer->url = malloc( BUFFER_SIZE );
pointer->method = malloc( BUFFER_SIZE );
pointer->version = malloc( BUFFER_SIZE );
pointer->mimeType = malloc( BUFFER_SIZE );
pointer->extension = malloc( BUFFER_SIZE );
pointer->headers = headerManager_newPointer();
request_constructor( pointer );
return pointer;
}

View File

@@ -0,0 +1,58 @@
#ifndef _request
#define _request
// Macros
#define BUFFER_SIZE 1024
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include "headers.h"
#include "stdlib.h"
typedef struct request{
unsigned short __classIndex;
char * connection;
char * address;
int port;
char * url;
char * method;
char * version;
char * mimeType;
char * extension;
struct headerManager * headers;
} request;
void request_constructor( request * this );
void request_free( request * this );
request request_new( );
request * request_newPointer( );
#endif

344
application/target/shader.c Normal file
View File

@@ -0,0 +1,344 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <shader.h>
void shader_checkShaderForErrors( shader * this, GLuint shader ) {
GLint isCompiled = 0;
glGetShaderiv( shader, GL_COMPILE_STATUS, &isCompiled );
if(isCompiled == GL_FALSE)
{
GLint maxLength = 0;
glGetShaderiv( shader, GL_INFO_LOG_LENGTH, &maxLength );
GLchar errorMessage[ maxLength ];
glGetShaderInfoLog( shader, maxLength, &maxLength, errorMessage );
printf("Error: %s\n\n", errorMessage);
glDeleteShader( shader );
return;
}
}
void shader_createFromFile( shader * this, char * vertexShaderPath, char * fragmentShaderPath ) {
text * vertexShaderSource = fileSystem_readFile( filesystem, vertexShaderPath, "utf8" );
text * fragmentShaderSource = fileSystem_readFile( filesystem, fragmentShaderPath, "utf8" );
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource( vertexShader, 1, &vertexShaderSource->value, NULL );
glCompileShader( vertexShader );
shader_checkShaderForErrors( this, vertexShader );
GLuint fragmentShader = glCreateShader( GL_FRAGMENT_SHADER );
glShaderSource( fragmentShader, 1, &fragmentShaderSource->value, NULL );
glCompileShader( fragmentShader );
shader_checkShaderForErrors( this, fragmentShader );
GLint program = glCreateProgram();
glAttachShader( program, fragmentShader );
glAttachShader( program, vertexShader );
glLinkProgram( program );
glUseProgram( program );
int attributeCount = 0;
GLsizei bufSize = 64;
GLsizei length;
GLint size;
GLenum type;
glGetProgramiv( program, GL_ACTIVE_ATTRIBUTES, &attributeCount );
printf("Active Attributes: %d\n", attributeCount );
for (int i = 0; i < attributeCount; i++)
{
GLenum type;
attribute attributeInstance = attribute_new();
glGetActiveAttrib( program, ( GLuint ) i, bufSize, &length, &size, &type, attributeInstance.name);
printf("Attribute #%d Type: %u Name: %s\n", i, type, attributeInstance.name);
GLint attributeLocation = glGetAttribLocation( program, attributeInstance.name );
glEnableVertexAttribArray( attributeLocation );
attributeInstance.location = attributeLocation;
attributeInstance.type = type;
array_add( this->attributes, &attributeInstance );
}
printf("attributes count: %i\n", array_length( this->attributes ));
int uniformCount = 0;
glGetProgramiv( program, GL_ACTIVE_UNIFORMS, &uniformCount );
printf( "Active Uniforms: %d\n", uniformCount );
for (int i = 0; i < uniformCount; i++)
{
uniform * uniformInstance = uniform_newPointer();
GLenum type;
GLchar name[bufSize];
glGetActiveUniform( program, ( GLuint ) i, bufSize, &length, &size, &type, uniformInstance->name );
printf( "Uniform #%d Type: %u Name: %s\n", i, type, uniformInstance->name );
GLint uniformLocation = glGetUniformLocation( program, uniformInstance->name );
uniformInstance->location = uniformLocation;
uniformInstance->type = type;
array_add( this->uniforms, uniformInstance );
}
printf("uniforms count: %i\n", array_length( this->uniforms ));
}
struct attribute * shader_getAttributeByName( shader * this, char * attributeName ) {
int attributeCount = array_length( this->attributes );
for ( int i = 0; i < attributeCount; ++i )
{
uniform * currentAttribute = array_get( this->attributes, i );
char * currentAttributeName = ( char * ) currentAttribute->name;
if( char_operator_compare( currentAttributeName , attributeName) ) {
return currentAttribute;
}
}
}
void shader_setUniform( shader * this, char * name, void * value ) {
int uniformCount = array_length( this->uniforms );
for (int i = 0; i < uniformCount; ++i)
{
uniform * currentUniform = array_get( this->uniforms, i );
char * uniformName = (char *)currentUniform->name;
if( char_operator_compare( uniformName , name) ) {
switch( currentUniform->type ) {
case GL_FLOAT_VEC2:
vector2 * vector2Value = ( vector2 * ) value;
glUniform2f( currentUniform->location, vector2Value->x, vector2Value->y );
break;
case GL_FLOAT_VEC3:
vector3 * vector3Value = ( vector3 * ) value;
glUniform3f( currentUniform->location, vector3Value->x, vector3Value->y, vector3Value->z );
break;
}
}
}
}
shader shader_new() {
shader instance;
instance.__classIndex = 8;
instance.uniforms = array_newPointer();
instance.attributes = array_newPointer();
return instance;
}
shader * shader_newPointer() {
struct shader * pointer = malloc( sizeof ( struct shader ) );
pointer->__classIndex = 8;
pointer->uniforms = array_newPointer();
pointer->attributes = array_newPointer();
return pointer;
}
uniform uniform_new() {
uniform instance;
instance.__classIndex = 9;
return instance;
}
uniform * uniform_newPointer() {
struct uniform * pointer = malloc( sizeof ( struct uniform ) );
pointer->__classIndex = 9;
return pointer;
}
attribute attribute_new() {
attribute instance;
instance.__classIndex = 10;
return instance;
}
attribute * attribute_newPointer() {
struct attribute * pointer = malloc( sizeof ( struct attribute ) );
pointer->__classIndex = 10;
return pointer;
}

View File

@@ -0,0 +1,92 @@
#ifndef _shader
#define _shader
// Macros
#define GL_GLEXT_PROTOTYPES
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include "char.h"
#include "array.h"
#include "fileSystem.h"
#include <stdio.h>
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glext.h>
typedef struct shader{
unsigned short __classIndex;
array * uniforms;
array * attributes;
} shader;
void shader_checkShaderForErrors( shader * this, GLuint shader );
void shader_createFromFile( shader * this, char * vertexShaderPath, char * fragmentShaderPath );
struct attribute * shader_getAttributeByName( shader * this, char * attributeName );
void shader_setUniform( shader * this, char * name, void * value );
typedef struct uniform{
unsigned short __classIndex;
char name[64];
GLint location;
GLenum type;
} uniform;
typedef struct attribute{
unsigned short __classIndex;
GLchar name[64];
GLint location;
GLenum type;
} attribute;
shader shader_new( );
shader * shader_newPointer( );
uniform uniform_new( );
uniform * uniform_newPointer( );
attribute attribute_new( );
attribute * attribute_newPointer( );
#endif

840
application/target/sqlite.c Normal file
View File

@@ -0,0 +1,840 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <sqlite.h>
void sqlite_constructor( sqlite * this, char * filePath ) {
this->value = "good";
sqlite_connect( this, filePath );
}
void sqlite_connect( sqlite * this, char * filePath ) {
printf("\n\ntrying to connect.. %s\n\n", filePath);
int rc = sqlite3_open( filePath, & this->db );
if ( rc != SQLITE_OK ) {
printf( "Cannot open database: %s\n", sqlite3_errmsg( this->db ) );
sqlite3_close( this->db );
consoleManager_error( console, ( char * ) sqlite3_errmsg( this->db ) );
return;
}
rc = sqlite3_prepare_v2( this->db, "SELECT SQLITE_VERSION()", -1, & this->res, 0 );
if (rc != SQLITE_OK) {
consoleManager_error( console, ( char * ) sqlite3_errmsg( this->db ) );
sqlite3_close( this->db );
return;
}
rc = sqlite3_step(this->res);
}
void sqlite_free( sqlite * this ) {
sqlite3_finalize( this->res );
sqlite3_close( this->db );
}
void sqlite_selectModel( sqlite * this, char * className ) {
this->selectedModel = className;
}
void sqlite_createTable( sqlite * this ) {
char * errorMessage = 0;
char *sql = "DROP TABLE IF EXISTS user;"
"CREATE TABLE user( id INT, username TEXT, userlevel INT, hash TEXT );";
int rc = sqlite3_exec(this->db, sql, 0, 0, &errorMessage);
if ( rc != SQLITE_OK ) {
printf( "SQL error: %s\n", errorMessage );
sqlite3_free( errorMessage );
sqlite3_close(this->db);
}
}
void sqlite_addRows( sqlite * this, array * insertArray ) {
array * copy = insertArray;
int classIndex = getClassIndexByClassName( this->selectedModel );
text * query = text_newPointer( "" );
text_append( query, "INSERT INTO " );
text_append( query, this->selectedModel );
sqlite3_stmt * result;
char * * propertyNames = getPropertiesByClassIndex( classIndex );
int propertyCount = getPropertyCountByClassIndex( classIndex );
int * propertyOffsets = getPropertyOffsetsByClassIndex( classIndex );
int * datatypeIndices = getPropertyDatatypeIndexesByClassIndex( classIndex );
text_append( query, " ( " );
for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex)
{
char * propertyName = propertyNames[propertyIndex];
int datatype = datatypeIndices[ propertyIndex ];
if( datatype > 0 ) {
continue;
}
if( propertyIndex > 0 ) {
text_append( query, ", " );
}
text_append( query, propertyName );
}
text_append( query, " ) " );
text_append( query, " VALUES ( " );
for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex)
{
int datatype = datatypeIndices[ propertyIndex ];
if( datatype > 0 ) {
continue;
}
if( propertyIndex > 0 ) {
text_append( query, ", " );
}
text_append( query, "?" );
}
text_append( query, " ) " );
sqlite3_prepare_v2( this->db, query->value, -1, &result, 0 );
sqlite3_exec(this->db, this->selectedModel, NULL, NULL, 0);
sqlite3_exec(this->db, "PRAGMA synchronous = OFF", NULL, NULL, 0);
sqlite3_exec(this->db, "PRAGMA journal_mode = MEMORY", NULL, NULL, 0);
int insertItemCount = copy->total;
char * voidArray = ( char * ) copy->items;
for (int i = 0; i < insertItemCount; ++i)
{
char * pointer = array_get( copy, i );
sqlite_updateRow( this, result, propertyCount, propertyNames, propertyOffsets, datatypeIndices, pointer );
sqlite3_step( result );
sqlite3_reset( result );
}
sqlite3_finalize( result );
}
void sqlite_updateRow( sqlite * this, sqlite3_stmt * result, int propertyCount, char * * propertyNames, int * propertyOffsets, int * datatypeIndices, char * pointer ) {
for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex)
{
char * propertyName = propertyNames[propertyIndex];
int propertyOffset = propertyOffsets[propertyIndex];
int propertyDatatypeIndex = getPropertyDatatypeIndex( datatypeIndices, propertyIndex );
if( propertyDatatypeIndex == -5 ) {
int value = *( int * )(pointer + propertyOffset);
sqlite3_bind_int( result, propertyIndex + 1, value );
} else if( propertyDatatypeIndex == -3 ) {
uintptr_t * value = ( uintptr_t * ) ( pointer + propertyOffset );
sqlite3_bind_text( result, propertyIndex + 1, (char *) *value, -1, SQLITE_TRANSIENT );
}
}
}
void sqlite_update( sqlite * this, void * row ) {
int classIndex = getClassIndexByClassName( this->selectedModel );
char ** propertyNames = getPropertiesByClassIndex( classIndex );
int propertyCount = getPropertyCountByClassIndex( classIndex );
int * propertyOffsets = getPropertyOffsetsByClassIndex( classIndex );
int * datatypeIndices = getPropertyDatatypeIndexesByClassIndex( classIndex );
int propertyIdOfIndex = -1;
for ( int i = 0; i < propertyCount; ++i )
{
char * propertyName = propertyNames[i];
if( strcmp( propertyName, "id" ) == 0 ) {
propertyIdOfIndex = i;
break;
}
}
if( propertyIdOfIndex == -1 ) {
printf("Class '%s' does not have an id field. ");
}
int idOffset = propertyOffsets[ propertyIdOfIndex ];
char * pointer = row;
int id = *( pointer + idOffset );
text * query = text_newPointer( "" );
text_append( query, "UPDATE " );
text_append( query, this->selectedModel );
text_append( query, " SET " );
int activePropertyCount = 0;
for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex)
{
char * propertyName = propertyNames[propertyIndex];
int datatypeIndex = datatypeIndices[propertyIndex];
if( datatypeIndex > 0 ) {
continue;
}
activePropertyCount++;
if( propertyIndex > 0 ) {
text_append( query, ", " );
}
text_append( query, propertyName );
text_append( query, " = ? " );
}
text_append( query, " where id = ? " );
sqlite3_stmt * result;
sqlite3_prepare_v2( this->db, query->value, -1, &result, 0 );
sqlite_updateRow( this, result, propertyCount, propertyNames, propertyOffsets, datatypeIndices, pointer );
sqlite3_bind_int( result, activePropertyCount + 1, id );
sqlite3_step( result );
sqlite3_finalize( result );
}
void sqlite_addRow( sqlite * this, void * row ) {
int classIndex = getClassIndexByClassName( this->selectedModel );
text * query = text_newPointer( "" );
text_append( query, "INSERT INTO " );
text_append( query, this->selectedModel );
sqlite3_stmt * result;
char * * propertyNames = getPropertiesByClassIndex( classIndex );
int propertyCount = getPropertyCountByClassIndex( classIndex );
int * propertyOffsets = getPropertyOffsetsByClassIndex( classIndex );
int * datatypeIndices = getPropertyDatatypeIndexesByClassIndex( classIndex );
char * pointer = row;
text_append( query, " ( " );
for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex)
{
char * propertyName = propertyNames[ propertyIndex ];
int datatype = datatypeIndices[ propertyIndex ];
if( datatype > 0 ) {
continue;
}
if( propertyIndex > 0 ) {
text_append( query, ", " );
}
text_append( query, propertyName );
}
text_append( query, " ) " );
text_append( query, " VALUES ( " );
for (int propertyIndex = 0; propertyIndex < propertyCount; ++propertyIndex)
{
int datatype = datatypeIndices[ propertyIndex ];
if( datatype > 0 ) {
continue;
}
if( propertyIndex > 0 ) {
text_append( query, ", " );
}
text_append( query, "?" );
}
text_append( query, " ) " );
sqlite3_prepare_v2( this->db, query->value, -1, &result, 0 );
sqlite_updateRow( this, result, propertyCount, propertyNames, propertyOffsets, datatypeIndices, pointer );
sqlite3_step( result );
sqlite3_finalize( result );
}
struct array * sqlite_fetchRows( sqlite * this, char * sql ) {
sqlite3_stmt * result;
int rc = sqlite3_prepare_v2( this->db, sql, -1, &result, 0 );
if ( rc != SQLITE_OK ) {
printf("Failed to execute statement: %s\n", sqlite3_errmsg( this->db ) );
}
int rowIndex = 0;
int classIndex = getClassIndexByClassName( this->selectedModel );
int propertyIndex = getPropertyIndexByPropertyName( classIndex, "username" );
int propertyCount = getPropertyCountByClassIndex( classIndex );
char ** propertyNames = getPropertiesByClassIndex( classIndex );
int * propertyOffsets = getPropertyOffsetsByClassIndex( classIndex );
int * datatypeIndices = getPropertyDatatypeIndexesByClassIndex( classIndex );
char * shortPointer = malloc( sizeof( char * ) * 100000 );
void * * voidArray = malloc( sizeof( void * ) * 100000 );
int structByteSize;
getArrayByClassIndex( 1000, voidArray, &structByteSize, classIndex );
shortPointer = ( char * ) shortPointer;
while ( sqlite3_step( result ) != SQLITE_DONE ) {
int pointerIndex = ( rowIndex * ( structByteSize ) );
char * pointer = shortPointer + pointerIndex;
int columnCount = sqlite3_data_count( result );
for (int i = 0; i < columnCount; ++i)
{
const char * columnName = sqlite3_column_name( result, i );
const int propertyIndex = getPropertyIndexByPropertyName( classIndex, (char *)columnName );
int propertyDatatypeIndex = getPropertyDatatypeIndex( datatypeIndices, propertyIndex );
int propertyOffset = getPropertyOffsetByPropertyIndex( propertyOffsets, propertyIndex );
if( propertyDatatypeIndex == -5 ) {
const int columnValue = sqlite3_column_int( result, i );
*( int * )( pointer + propertyOffset ) = columnValue;
} else if( propertyDatatypeIndex == -3 ) {
const char * columnValue = sqlite3_column_text( result, i );
char * columnValueCopy = malloc( strlen( columnValue ) );
strncpy( columnValueCopy, columnValue, strlen( columnValue ) );
memcpy( pointer + propertyOffset, &columnValueCopy, 8 );
}
}
voidArray[rowIndex] = pointer;
rowIndex++;
}
struct array * rows = array_newPointer();
rows->items = voidArray;
rows->total = rowIndex;
return rows;
}
sqlite sqlite_new(char * filePath) {
sqlite instance;
instance.__classIndex = 27;
sqlite_constructor( &instance, filePath);
return instance;
}
sqlite * sqlite_newPointer(char * filePath) {
struct sqlite * pointer = malloc( sizeof ( struct sqlite ) );
pointer->__classIndex = 27;
sqlite_constructor( pointer , filePath);
return pointer;
}

View File

@@ -0,0 +1,73 @@
#ifndef _sqlite
#define _sqlite
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include "console.h"
#include <text.h>
#include <array.h>
#include <string.h>
#include <stdio.h>
#include <sqlite3.h>
#include <stdlib.h>
#include <classConfiguration.h>
typedef struct sqlite{
unsigned short __classIndex;
sqlite3 * db;
sqlite3_stmt * res;
char * value;
char * selectedModel;
} sqlite;
void sqlite_constructor( sqlite * this, char * filePath );
void sqlite_connect( sqlite * this, char * filePath );
void sqlite_free( sqlite * this );
void sqlite_selectModel( sqlite * this, char * className );
void sqlite_createTable( sqlite * this );
void sqlite_addRows( sqlite * this, array * insertArray );
void sqlite_updateRow( sqlite * this, sqlite3_stmt * result, int propertyCount, char * * propertyNames, int * propertyOffsets, int * datatypeIndices, char * pointer );
void sqlite_update( sqlite * this, void * row );
void sqlite_addRow( sqlite * this, void * row );
struct array * sqlite_fetchRows( sqlite * this, char * sql );
sqlite sqlite_new( char * filePath );
sqlite * sqlite_newPointer( char * filePath );
#endif

View File

@@ -0,0 +1,34 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <street.h>
void address_someMethod( address * this ) {
}
address address_new() {
address instance;
instance.__classIndex = 19;
return instance;
}
address * address_newPointer() {
struct address * pointer = malloc( sizeof ( struct address ) );
pointer->__classIndex = 19;
return pointer;
}

View File

@@ -0,0 +1,35 @@
#ifndef _street
#define _street
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
typedef struct address{
unsigned short __classIndex;
char * street;
int number;
} address;
void address_someMethod( address * this );
address address_new( );
address * address_newPointer( );
#endif

209
application/target/text.c Normal file
View File

@@ -0,0 +1,209 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <text.h>
int text_operator_compare( text * this, text * b ) {
if( strcmp( this->value, b->value ) == 0 ) {
return 1;
} else {
return 0;
}
}
text * text_operator_add( text * this, char * b ) {
text_append( this, b );
return this;
}
void text_constructor( text * this, char * value ) {
this->length = strlen( value );
if( this->length > this->capacity ) {
this->capacity = this->length * 2;
}
this->value = malloc( sizeof( char ) * this->capacity );
strcpy( this->value, value );
}
char text_get( text * this, int index ) {
return this->value[ index ];
}
void text_resize( text * this, int size ) {
this->value = realloc( this->value, size );
this->capacity = size;
}
text * text_append( text * this, char * value ) {
int originalLength = this->length;
int newValueLength = strlen( value );
this->length += newValueLength;
if( this->length > this->capacity ) {
text_resize( this, this->length * 2 );
}
memcpy( this->value + originalLength, value, newValueLength + 1 );
return this;
}
text * text_appendBinary( text * this, char * value, int size ) {
int originalLength = this->length;
int newValueLength = size;
this->length += newValueLength;
if( this->length > this->capacity ) {
text_resize( this, this->length * 2 );
}
memcpy( this->value + originalLength, value, newValueLength + 1 );
return this;
}
text * text_appendObject( text * this, text * object ) {
int originalLength = this->length;
int newValueLength = object->length;
this->length += newValueLength;
if( this->length > this->capacity ) {
text_resize( this, this->length * 2 );
}
memcpy(this->value + originalLength, object->value, newValueLength + 1);
return this;
}
text * text_concatenate( text * this, char * value ) {
text * copy = text_newPointer( this->value );
strcat( copy->value, value );
return copy;
}
char * text_toNative( text * this ) {
return this->value;
}
char * text_whiteSpace( text * this, int whiteSpaceCount ) {
char * output = malloc( 400 );
for (int i = 0; i < whiteSpaceCount; ++i)
{
strcat( output, " " );
}
return output;
}
void text_free( text * this ) {
free( this->value );
free( this );
}
text text_new(char * value) {
text instance;
instance.__classIndex = 4;
instance.usevalue = -1;
instance.capacity = 500;
text_constructor( &instance, value);
return instance;
}
text * text_newPointer(char * value) {
struct text * pointer = malloc( sizeof ( struct text ) );
pointer->__classIndex = 4;
pointer->usevalue = -1;
pointer->capacity = 500;
text_constructor( pointer , value);
return pointer;
}

71
application/target/text.h Normal file
View File

@@ -0,0 +1,71 @@
#ifndef _text
#define _text
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <dirent.h>
#include <array.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct text{
unsigned short __classIndex;
char * value;
int usevalue;
int length;
int capacity;
} text;
int text_operator_compare( text * this, text * b );
text * text_operator_add( text * this, char * b );
void text_constructor( text * this, char * value );
char text_get( text * this, int index );
void text_resize( text * this, int size );
text * text_append( text * this, char * value );
text * text_appendBinary( text * this, char * value, int size );
text * text_appendObject( text * this, text * object );
text * text_concatenate( text * this, char * value );
char * text_toNative( text * this );
char * text_whiteSpace( text * this, int whiteSpaceCount );
void text_free( text * this );
text text_new( char * value );
text * text_newPointer( char * value );
#endif

View File

@@ -0,0 +1,47 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <toolset.h>
void toolset_createHorisontalLine( toolset * this ) {
struct winsize w;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
for (int i = 0; i < w.ws_col; ++i)
{
printf("-");
};
printf("\n");
}
toolset toolset_new() {
toolset instance;
instance.__classIndex = 20;
return instance;
}
toolset * toolset_newPointer() {
struct toolset * pointer = malloc( sizeof ( struct toolset ) );
pointer->__classIndex = 20;
return pointer;
}

View File

@@ -0,0 +1,37 @@
#ifndef _toolset
#define _toolset
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <unistd.h>
#include <stdio.h>
#include <sys/ioctl.h>
typedef struct toolset{
unsigned short __classIndex;
} toolset;
void toolset_createHorisontalLine( toolset * this );
toolset toolset_new( );
toolset * toolset_newPointer( );
#endif

View File

@@ -0,0 +1,49 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <triangle.h>
void triangle_add( triangle * this, triangle * a ) {
}
triangle triangle_new() {
triangle instance;
instance.__classIndex = 28;
instance.a = vector2_newPointer( 1, 2 );
instance.b = vector2_new( 3, 400 );
instance.c = vector2_new( 5, 6 );
return instance;
}
triangle * triangle_newPointer() {
struct triangle * pointer = malloc( sizeof ( struct triangle ) );
pointer->__classIndex = 28;
pointer->a = vector2_newPointer( 1, 2 );
pointer->b = vector2_new( 3, 400 );
pointer->c = vector2_new( 5, 6 );
return pointer;
}

View File

@@ -0,0 +1,39 @@
#ifndef _triangle
#define _triangle
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <vector2.h>
typedef struct triangle{
unsigned short __classIndex;
vector2 * a;
vector2 b;
vector2 c;
} triangle;
void triangle_add( triangle * this, triangle * a );
triangle triangle_new( );
triangle * triangle_newPointer( );
#endif

View File

@@ -0,0 +1,197 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <unsignedIntegerArray.h>
int unsignedIntegerArray_length( unsignedIntegerArray * this ) {
return this->total;
}
unsigned float unsignedIntegerArray_get( unsignedIntegerArray * this, int index ) {
if ( index >= 0 && index < this->total ){
return this->items[index];
}
return NULL;
}
void unsignedIntegerArray_set( unsignedIntegerArray * this, int index, unsigned float item ) {
if ( index >= 0 && index < this->total ){
this->items[ index ] = item;
}
}
void unsignedIntegerArray_resize( unsignedIntegerArray * this, int capacity ) {
int * items = realloc( this->items, sizeof( int ) * capacity );
this->items = items;
this->capacity = capacity;
}
void unsignedIntegerArray_addVector2( unsignedIntegerArray * this, struct vector2 * item ) {
unsignedIntegerArray_add( this, item->x );
unsignedIntegerArray_add( this, item->y );
}
void unsignedIntegerArray_addVector3( unsignedIntegerArray * this, struct vector3 * item ) {
unsignedIntegerArray_add( this, item->x );
unsignedIntegerArray_add( this, item->y );
unsignedIntegerArray_add( this, item->z );
}
void unsignedIntegerArray_add( unsignedIntegerArray * this, unsigned int item ) {
if ( this->capacity == this->total ){
unsignedIntegerArray_resize( this, this->capacity * 2 );
}
this->items[ this->total++ ] = item;
}
void unsignedIntegerArray_delete( unsignedIntegerArray * this, int index ) {
if ( index < 0 || index >= this->total ){
return;
}
this->items[index] = 0.0;
for ( int i = index; i < this->total - 1; i++ ) {
this->items[i] = this->items[i + 1];
this->items[i + 1] = 0.0;
}
this->total--;
if ( this->total > 0 && this->total == this->capacity / 4 ){
unsignedIntegerArray_resize( this, this->capacity / 2 );
}
}
int unsignedIntegerArray_array_push( unsignedIntegerArray * this, unsigned int item ) {
unsignedIntegerArray_add( this, item );
return this->total;
}
void unsignedIntegerArray_unshift( unsignedIntegerArray * this, int item ) {
int length = this->total;
this->total++;
if ( this->capacity == this->total ){
unsignedIntegerArray_resize( this, this->capacity * 2 );
}
for ( int i = length - 1; i >= 0; --i ) {
this->items[ i + 1 ] = this->items[ i ];
}
this->items[ 0 ] = item;
}
unsigned int unsignedIntegerArray_pop( unsignedIntegerArray * this ) {
int length = this->total;
int lastIndex = length - 1;
int lastItem = unsignedIntegerArray_get( this, lastIndex );
unsignedIntegerArray_delete( this, lastIndex );
return lastItem;
}
unsignedIntegerArray unsignedIntegerArray_new() {
unsignedIntegerArray instance;
instance.__classIndex = 1;
instance.capacity = 10;
instance.total = 0;
instance.items = malloc( 10000000 );
return instance;
}
unsignedIntegerArray * unsignedIntegerArray_newPointer() {
struct unsignedIntegerArray * pointer = malloc( sizeof ( struct unsignedIntegerArray ) );
pointer->__classIndex = 1;
pointer->capacity = 10;
pointer->total = 0;
pointer->items = malloc( 10000000 );
return pointer;
}

View File

@@ -0,0 +1,67 @@
#ifndef _unsignedIntegerArray
#define _unsignedIntegerArray
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <vector2.h>
#include <vector3.h>
#include <text.h>
#include <char.h>
#include <stdlib.h>
typedef struct unsignedIntegerArray{
unsigned short __classIndex;
int capacity;
int total;
unsigned int * items;
} unsignedIntegerArray;
int unsignedIntegerArray_length( unsignedIntegerArray * this );
unsigned float unsignedIntegerArray_get( unsignedIntegerArray * this, int index );
void unsignedIntegerArray_set( unsignedIntegerArray * this, int index, unsigned float item );
void unsignedIntegerArray_resize( unsignedIntegerArray * this, int capacity );
void unsignedIntegerArray_addVector2( unsignedIntegerArray * this, struct vector2 * item );
void unsignedIntegerArray_addVector3( unsignedIntegerArray * this, struct vector3 * item );
void unsignedIntegerArray_add( unsignedIntegerArray * this, unsigned int item );
void unsignedIntegerArray_delete( unsignedIntegerArray * this, int index );
int unsignedIntegerArray_array_push( unsignedIntegerArray * this, unsigned int item );
void unsignedIntegerArray_unshift( unsignedIntegerArray * this, int item );
unsigned int unsignedIntegerArray_pop( unsignedIntegerArray * this );
unsignedIntegerArray unsignedIntegerArray_new( );
unsignedIntegerArray * unsignedIntegerArray_newPointer( );
#endif

51
application/target/user.c Normal file
View File

@@ -0,0 +1,51 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <user.h>
void user_constructor( user * this ) {
}
user user_new() {
user instance;
instance.__classIndex = 29;
instance.addresses = array_newPointer();
user_constructor( &instance);
return instance;
}
user * user_newPointer() {
struct user * pointer = malloc( sizeof ( struct user ) );
pointer->__classIndex = 29;
pointer->addresses = array_newPointer();
user_constructor( pointer );
return pointer;
}

43
application/target/user.h Normal file
View File

@@ -0,0 +1,43 @@
#ifndef _user
#define _user
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <array.h>
typedef struct user{
unsigned short __classIndex;
char * username;
int id;
int userlevel;
char * hash;
struct array * addresses;
} user;
void user_constructor( user * this );
user user_new( );
user * user_newPointer( );
#endif

View File

@@ -0,0 +1,106 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <vector2.h>
void vector2_constructor( vector2 * this, float x, float y ) {
this->x = x;
this->y = y;
}
vector2 * vector2_operator_plus( vector2 * this, vector2 * b ) {
vector2_add( this, b );
return this;
}
vector2 * vector2_operator_add( vector2 * this, struct vector2 * b ) {
return b;
}
void vector2_add( vector2 * this, vector2 * a ) {
this->x += a->x;
this->y += a->y;
}
void vector2_subtract( vector2 * this, vector2 * a ) {
this->x -= a->x;
this->y -= a->y;
}
int vector2_length( vector2 * this ) {
return this->x + this->y;
}
vector2 vector2_new(float x, float y) {
vector2 instance;
instance.__classIndex = 2;
vector2_constructor( &instance, x, y);
return instance;
}
vector2 * vector2_newPointer(float x, float y) {
struct vector2 * pointer = malloc( sizeof ( struct vector2 ) );
pointer->__classIndex = 2;
vector2_constructor( pointer , x, y);
return pointer;
}

View File

@@ -0,0 +1,57 @@
#ifndef _vector2
#define _vector2
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include <stdlib.h>
#include <define.c>
#include <stddef.h>
#include "time.h"
#include <stdbool.h>
#include "stdio.h"
typedef struct vector2{
unsigned short __classIndex;
float x;
float y;
} vector2;
void vector2_constructor( vector2 * this, float x, float y );
vector2 * vector2_operator_plus( vector2 * this, vector2 * b );
vector2 * vector2_operator_add( vector2 * this, struct vector2 * b );
void vector2_add( vector2 * this, vector2 * a );
void vector2_subtract( vector2 * this, vector2 * a );
int vector2_length( vector2 * this );
vector2 vector2_new( float x, float y );
vector2 * vector2_newPointer( float x, float y );
#endif

View File

@@ -0,0 +1,76 @@
/*
* This file is automaticaly generated, Please dont edit this file!
*/
#include <vector3.h>
void vector3_constructor( vector3 * this, float x, float y, float z ) {
this->x = x;
this->y = y;
this->z = z;
}
vector3 * vector3_operator_plus( vector3 * this, vector3 * b ) {
vector3_add( this, b );
return this;
}
vector3 * vector3_operator_add( vector3 * this, vector3 * b ) {
vector3_add( this, b );
return this;
}
void vector3_add( vector3 * this, vector3 * b ) {
this->x += b->x;
this->y += b->y;
this->z += b->z;
}
vector3 vector3_new(float x, float y, float z) {
vector3 instance;
instance.__classIndex = 3;
vector3_constructor( &instance, x, y, z);
return instance;
}
vector3 * vector3_newPointer(float x, float y, float z) {
struct vector3 * pointer = malloc( sizeof ( struct vector3 ) );
pointer->__classIndex = 3;
vector3_constructor( pointer , x, y, z);
return pointer;
}

View File

@@ -0,0 +1,45 @@
#ifndef _vector3
#define _vector3
// Macros
#include "stdlib.h"
extern char * __ClassNames[];
// Includes
#include "application.h"
typedef struct vector3{
unsigned short __classIndex;
float x;
float y;
float z;
} vector3;
void vector3_constructor( vector3 * this, float x, float y, float z );
vector3 * vector3_operator_plus( vector3 * this, vector3 * b );
vector3 * vector3_operator_add( vector3 * this, vector3 * b );
void vector3_add( vector3 * this, vector3 * b );
vector3 vector3_new( float x, float y, float z );
vector3 * vector3_newPointer( float x, float y, float z );
#endif