Fixed a ton of stuff with function templates. Works well now. Next up: multiple template types and fixing object definition ordering (both where templates should go and objects with other pointers)

This commit is contained in:
Nathan Braswell
2014-05-19 20:00:35 -04:00
parent b2c61b00f2
commit 39f945940d
8 changed files with 174 additions and 47 deletions

View File

@@ -21,3 +21,35 @@ void free(char* memPtr) {
"""
}
}
template <T> void free(T* memPtr) {
__if_comp__ __C__ {
__simple_passthrough__ """
free(memPtr);
"""
}
}
template <T> int sizeof() {
int result = 0;
T testObj;
__if_comp__ __C__ {
__simple_passthrough__ """
result = sizeof(testObj);
"""
}
return result;
}
template <T> T* new(int count) {
return malloc( sizeof<T>() * count );
}
template <T> T* new() {
return new<T>(1);
}
template <T> void delete(T* toDelete) {
free<T>(toDelete);
}