aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/game/color.tm10
-rw-r--r--examples/http/http.tm18
-rw-r--r--examples/threads/threads.tm18
3 files changed, 23 insertions, 23 deletions
diff --git a/examples/game/color.tm b/examples/game/color.tm
index c7ba557a..f8702570 100644
--- a/examples/game/color.tm
+++ b/examples/game/color.tm
@@ -12,12 +12,12 @@ struct Color(r,g,b:Num,a=1.0):
func draw_rectangle(c:Color, pos:Vec2, size:Vec2):
inline C {
DrawRectangle(
- (int)($pos.$x), (int)($pos.$y), (int)($size.$x), (int)($size.$y),
+ (int)(_$pos.$x), (int)(_$pos.$y), (int)(_$size.$x), (int)(_$size.$y),
((Color){
- (int8_t)(uint8_t)(255.*$c.$r),
- (int8_t)(uint8_t)(255.*$c.$g),
- (int8_t)(uint8_t)(255.*$c.$b),
- (int8_t)(uint8_t)(255.*$c.$a),
+ (int8_t)(uint8_t)(255.*_$c.$r),
+ (int8_t)(uint8_t)(255.*_$c.$g),
+ (int8_t)(uint8_t)(255.*_$c.$b),
+ (int8_t)(uint8_t)(255.*_$c.$a),
})
);
}
diff --git a/examples/http/http.tm b/examples/http/http.tm
index 425a7ba5..e7221b2c 100644
--- a/examples/http/http.tm
+++ b/examples/http/http.tm
@@ -11,16 +11,16 @@ func _send(method:_Method, url:Text, data:Text?, headers=[:Text] -> HTTPResponse
chunks := @[:Text]
save_chunk := func(chunk:CString, size:Int64, n:Int64):
chunks:insert(inline C:Text {
- Text$format("%.*s", $size*$n, $chunk)
+ Text$format("%.*s", _$size*_$n, _$chunk)
})
return n*size
inline C {
CURL *curl = curl_easy_init();
struct curl_slist *chunk = NULL;
- curl_easy_setopt(curl, CURLOPT_URL, Text$as_c_string($url));
- curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, $save_chunk.fn);
- curl_easy_setopt(curl, CURLOPT_WRITEDATA, $save_chunk.userdata);
+ curl_easy_setopt(curl, CURLOPT_URL, Text$as_c_string(_$url));
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _$save_chunk.fn);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, _$save_chunk.userdata);
}
when method is POST:
@@ -29,7 +29,7 @@ func _send(method:_Method, url:Text, data:Text?, headers=[:Text] -> HTTPResponse
}
if posting := data:
inline C {
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Text$as_c_string($posting));
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Text$as_c_string(_$posting));
}
is PUT:
inline C {
@@ -37,7 +37,7 @@ func _send(method:_Method, url:Text, data:Text?, headers=[:Text] -> HTTPResponse
}
if putting := data:
inline C {
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Text$as_c_string($putting));
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Text$as_c_string(_$putting));
}
is PATCH:
inline C {
@@ -45,7 +45,7 @@ func _send(method:_Method, url:Text, data:Text?, headers=[:Text] -> HTTPResponse
}
if patching := data:
inline C {
- curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Text$as_c_string($patching));
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Text$as_c_string(_$patching));
}
is DELETE:
inline C {
@@ -56,7 +56,7 @@ func _send(method:_Method, url:Text, data:Text?, headers=[:Text] -> HTTPResponse
for header in headers:
inline C {
- chunk = curl_slist_append(chunk, Text$as_c_string($header));
+ chunk = curl_slist_append(chunk, Text$as_c_string(_$header));
}
inline C {
@@ -70,7 +70,7 @@ func _send(method:_Method, url:Text, data:Text?, headers=[:Text] -> HTTPResponse
if (res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
- curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &$code);
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &_$code);
if (chunk)
curl_slist_free_all(chunk);
curl_easy_cleanup(curl);
diff --git a/examples/threads/threads.tm b/examples/threads/threads.tm
index 16beb9bc..99bb83b4 100644
--- a/examples/threads/threads.tm
+++ b/examples/threads/threads.tm
@@ -13,11 +13,11 @@ struct Mutex(_mutex:@Memory):
func do_locked(m:Mutex, fn:func(); inline):
inline C {
- pthread_mutex_lock((pthread_mutex_t*)$m.$_mutex);
+ pthread_mutex_lock((pthread_mutex_t*)_$m.$_mutex);
}
fn()
inline C {
- pthread_mutex_unlock((pthread_mutex_t*)$m.$_mutex);
+ pthread_mutex_unlock((pthread_mutex_t*)_$m.$_mutex);
}
struct ThreadCondition(_cond:@Memory):
@@ -33,17 +33,17 @@ struct ThreadCondition(_cond:@Memory):
func wait(c:ThreadCondition, m:Mutex; inline):
inline C {
- pthread_cond_wait((pthread_cond_t*)$c.$_cond, (pthread_mutex_t*)$m.$_mutex);
+ pthread_cond_wait((pthread_cond_t*)_$c.$_cond, (pthread_mutex_t*)_$m.$_mutex);
}
func signal(c:ThreadCondition; inline):
inline C {
- pthread_cond_signal((pthread_cond_t*)$c.$_cond);
+ pthread_cond_signal((pthread_cond_t*)_$c.$_cond);
}
func broadcast(c:ThreadCondition; inline):
inline C {
- pthread_cond_broadcast((pthread_cond_t*)$c.$_cond);
+ pthread_cond_broadcast((pthread_cond_t*)_$c.$_cond);
}
struct Guard(mutex=Mutex.new(), cond=ThreadCondition.new()):
@@ -59,24 +59,24 @@ struct PThread(_thread:@Memory):
return PThread(
inline C : @Memory {
pthread_t *thread = new(pthread_t);
- pthread_create(thread, NULL, $fn.fn, $fn.userdata);
+ pthread_create(thread, NULL, _$fn.fn, _$fn.userdata);
thread
}
)
func join(t:PThread):
inline C {
- pthread_join(*(pthread_t*)$t.$_thread, NULL);
+ pthread_join(*(pthread_t*)_$t.$_thread, NULL);
}
func cancel(t:PThread):
inline C {
- pthread_cancel(*(pthread_t*)$t.$_thread);
+ pthread_cancel(*(pthread_t*)_$t.$_thread);
}
func detatch(t:PThread):
inline C {
- pthread_detach(*(pthread_t*)$t.$_thread);
+ pthread_detach(*(pthread_t*)_$t.$_thread);
}
func main():