Files

274 lines
4.3 KiB
C
Raw Permalink Normal View History

2025-11-17 10:28:09 +01:00
/*
* 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;
}