Initial commit
This commit is contained in:
107
source/property.c
Normal file
107
source/property.c
Normal file
@@ -0,0 +1,107 @@
|
||||
|
||||
#include "property.h"
|
||||
|
||||
|
||||
|
||||
char * property_composePropertyValue( char * propertyValue, struct property * propertyInstance ) {
|
||||
|
||||
struct array * valueParts = text_split( propertyValue, " \t" );
|
||||
|
||||
int valuePartsLength = array_length( valueParts );
|
||||
|
||||
for (int i = 0; i < valuePartsLength; ++i)
|
||||
{
|
||||
char * valuePart = array_get( valueParts, i );
|
||||
|
||||
if( strcmp( valuePart, "new" ) == 0 ) {
|
||||
|
||||
char * afterNew = array_get( valueParts, i + 1 );
|
||||
|
||||
int argumentOpenIndex = text_findFirstCharacterIndex( propertyValue, "(" );
|
||||
|
||||
int newKeywordIndex = text_findFirstCharacterIndex( propertyValue, "new" ) + 3;
|
||||
|
||||
char * argumentText = text_removeWhiteSpaces( text_slice( propertyValue, argumentOpenIndex , strlen( propertyValue ) ) );
|
||||
|
||||
char * datatype = text_removeWhiteSpaces( text_slice( propertyValue, newKeywordIndex , argumentOpenIndex-1 ) );
|
||||
|
||||
|
||||
struct text * newMethodDecleration = text_new( "" );//datatype
|
||||
|
||||
text_append( newMethodDecleration, datatype );
|
||||
|
||||
text_append( newMethodDecleration, "_new" );
|
||||
|
||||
if( propertyInstance->isPointer == 1 ) {
|
||||
|
||||
text_append( newMethodDecleration, "Pointer" );
|
||||
|
||||
}
|
||||
|
||||
text_append( newMethodDecleration, argumentText );
|
||||
|
||||
|
||||
return newMethodDecleration->value;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//propertyInstance->value = propertyValue;
|
||||
|
||||
return propertyValue;
|
||||
|
||||
}
|
||||
|
||||
char * property_extractPropertyDeclaration( struct array * propertyParts, struct property * propertyInstance ) {
|
||||
|
||||
char * formattedDecleration = "";
|
||||
|
||||
int propertyPartsLength = array_length( propertyParts );
|
||||
|
||||
for ( int j = 0; j < propertyPartsLength; ++j )
|
||||
{
|
||||
char * part = (char *) array_get( propertyParts, j );
|
||||
|
||||
if( strcmp( part, "const" ) == 0 ) {
|
||||
|
||||
|
||||
} else if( strcmp( part, "volatile" ) == 0 ) {
|
||||
|
||||
|
||||
} else if( strcmp( part, "*" ) == 0 ) {
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
if( j < propertyPartsLength - 1 ) {
|
||||
|
||||
propertyInstance->datatype = part;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( j != 0 ){
|
||||
|
||||
formattedDecleration = text_concatenate( formattedDecleration, " " );
|
||||
|
||||
}
|
||||
|
||||
formattedDecleration = text_concatenate( formattedDecleration, part );
|
||||
|
||||
}
|
||||
|
||||
return formattedDecleration;
|
||||
|
||||
}
|
||||
|
||||
char * property_extractPropertyName( struct array * propertyParts ) {
|
||||
|
||||
int propertyPartsLength = array_length( propertyParts );
|
||||
|
||||
return text_copy( array_get( propertyParts, propertyPartsLength - 1 ) ) ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user