Working toward new C inline style

This commit is contained in:
Nathan Braswell
2015-04-04 01:32:40 -04:00
parent 639f4ff0fb
commit e37836aea5
11 changed files with 172 additions and 123 deletions

View File

@@ -1,6 +1,6 @@
import string:*;
__if_comp__ __C__ __simple_passthrough__ """
__if_comp__ __C__ simple_passthrough """
#include <stdio.h>
"""
@@ -10,7 +10,7 @@ __if_comp__ __C__ __simple_passthrough__ """
|void| print(|char*| toPrint) {
__if_comp__ __C__ {
__simple_passthrough__ """
simple_passthrough(toPrint = toPrint::) """
printf(toPrint);
"""
}
@@ -32,7 +32,7 @@ __if_comp__ __C__ __simple_passthrough__ """
|void| print(|int| toPrint) {
__if_comp__ __C__ {
__simple_passthrough__ """
simple_passthrough(toPrint = toPrint::) """
printf("%d", toPrint);
"""
}
@@ -46,7 +46,7 @@ __if_comp__ __C__ __simple_passthrough__ """
|void| print(|float| toPrint) {
__if_comp__ __C__ {
__simple_passthrough__ """
simple_passthrough(toPrint = toPrint::) """
printf("%f", toPrint);
"""
}
@@ -55,7 +55,7 @@ __if_comp__ __C__ __simple_passthrough__ """
|void| print(|double| toPrint) {
__if_comp__ __C__ {
__simple_passthrough__ """
simple_passthrough(toPrint = toPrint::) """
printf("%f", toPrint);
"""
}

View File

@@ -1,4 +1,4 @@
__if_comp__ __C__ __simple_passthrough__ """
__if_comp__ __C__ simple_passthrough """
#include <math.h>
"""
@@ -16,11 +16,11 @@ __if_comp__ __C__ __simple_passthrough__ """
{
|double| ans = 0;
__if_comp__ __C__{
__simple_Passthrough__ """
simple_passthrough(arg = arg : ans = ans :) """
ans = atan(arg);
"""
}//end C wrapper
return ans;
}//end atan function
@@ -28,11 +28,11 @@ __if_comp__ __C__ __simple_passthrough__ """
{
|double| ans = 0;
__if_comp__ __C__{
__simple_Passthrough__ """
simple_passthrough(x = x, y = y : ans = ans :) """
ans = atan2(x,y);
"""
}//end C wrapper
return ans;
}//end atan2 function
@@ -40,11 +40,11 @@ __if_comp__ __C__ __simple_passthrough__ """
{
|double| ans = 0;
__if_comp__ __C__{
__simple_Passthrough__ """
simple_passthrough(arg = arg : ans = ans :) """
ans = acos(arg);
"""
}//end C wrapper
return ans;
}//end acos function
@@ -52,11 +52,11 @@ __if_comp__ __C__ __simple_passthrough__ """
{
|double| ans = 0;
__if_comp__ __C__{
__simple_Passthrough__ """
simple_passthrough(arg = arg : ans = ans :) """
ans = asin(arg);
"""
}//end C wrapper
return ans;
}//end asin function
@@ -64,11 +64,11 @@ __if_comp__ __C__ __simple_passthrough__ """
{
|double| ans = 0;
__if_comp__ __C__{
__simple_Passthrough__ """
simple_passthrough(arg = arg : ans = ans :) """
ans = tan(arg);
"""
}//end C wrapper
return ans;
}//end tan function
@@ -76,11 +76,11 @@ __if_comp__ __C__ __simple_passthrough__ """
{
|double| ans = 0;
__if_comp__ __C__{
__simple_Passthrough__ """
simple_passthrough(arg = arg : ans = ans :) """
ans = cos(arg);
"""
}//end C wrapper
return ans;
}//end cos function
@@ -88,11 +88,11 @@ __if_comp__ __C__ __simple_passthrough__ """
{
|double| ans = 0;
__if_comp__ __C__{
__simple_Passthrough__ """
simple_passthrough(arg = arg : ans = ans :) """
ans = sin(arg);
"""
}//end C wrapper
return ans;
}//end sin function

View File

@@ -1,4 +1,4 @@
__if_comp__ __C__ __simple_passthrough__ """
__if_comp__ __C__ simple_passthrough """
#include <stdlib.h>
"""
@@ -7,7 +7,7 @@ __if_comp__ __C__ __simple_passthrough__ """
template <T> |T*| malloc(|int| size) {
|T*| memPtr = 0;
__if_comp__ __C__ {
__simple_passthrough__ """
simple_passthrough( size = size : memPtr = memPtr :) """
memPtr = malloc(size);
"""
}
@@ -16,7 +16,7 @@ template <T> |T*| malloc(|int| size) {
template <T> |void| free(|T*| memPtr) {
__if_comp__ __C__ {
__simple_passthrough__ """
simple_passthrough(memPtr = memPtr ::) """
free(memPtr);
"""
}
@@ -26,7 +26,7 @@ template <T> |int| sizeof() {
|int| result = 0;
|T| testObj;
__if_comp__ __C__ {
__simple_passthrough__ """
simple_passthrough(testObj = testObj : result = result:) """
result = sizeof(testObj);
"""
}
@@ -55,10 +55,10 @@ template <T(Destructable)> |void| delete(|T*| toDelete, |int| itemCount) {
/* We specilize on the trait Destructable to decide on whether or not the destructor should be called */
template <T> |void| delete(|T*| toDelete) {
free(toDelete);
free<T>(toDelete);
}
template <T(Destructable)> |void| delete(|T*| toDelete) {
toDelete->destruct();
free(toDelete);
free<T>(toDelete);
}