Wooo actual scoping and better C interop

This commit is contained in:
Nathan Braswell
2015-04-10 00:37:31 -04:00
parent e37836aea5
commit e3aa531856
23 changed files with 194 additions and 46 deletions

View File

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

View File

@@ -5,9 +5,9 @@ __if_comp__ __C__ simple_passthrough """
/* we have a template versions so we don't have to cast (because we don't have that yet) */
template <T> |T*| malloc(|int| size) {
|T*| memPtr = 0;
|T*| memPtr;
__if_comp__ __C__ {
simple_passthrough( size = size : memPtr = memPtr :) """
simple_passthrough( size = size, memPtr = memPtr : memPtr = memPtr :) """
memPtr = malloc(size);
"""
}
@@ -23,11 +23,11 @@ template <T> |void| free(|T*| memPtr) {
}
template <T> |int| sizeof() {
|int| result = 0;
|T| testObj;
|int| result;
__if_comp__ __C__ {
simple_passthrough(testObj = testObj : result = result:) """
result = sizeof(testObj);
int result = sizeof(testObj);
"""
}
return result;