|
Revision 78:4a04b6759f98, 1.2 kB
(checked in by John Reimer <terminal.node@gmail.com>, 7 months ago)
|
Clean up directory names
|
| Line | |
|---|
| 1 |
module test; |
|---|
| 2 |
|
|---|
| 3 |
import dwt.internal.gtk.c.cairo; |
|---|
| 4 |
import tango.core.Traits; |
|---|
| 5 |
import tango.io.Stdout; |
|---|
| 6 |
import tango.stdc.stdio; |
|---|
| 7 |
|
|---|
| 8 |
struct lock { |
|---|
| 9 |
static void lock() { printf("lock\n");} |
|---|
| 10 |
static void unlock() { printf("unlock\n");} |
|---|
| 11 |
} |
|---|
| 12 |
|
|---|
| 13 |
const static char[] mm = "Inside outer cairo_version"; |
|---|
| 14 |
|
|---|
| 15 |
template NameOfFunc(alias f) { |
|---|
| 16 |
// Note: highly dependent on the .stringof formatting |
|---|
| 17 |
// the value begins with "& " which is why the first two chars are cut off |
|---|
| 18 |
const char[] NameOfFunc = (&f).stringof[2 .. $]; |
|---|
| 19 |
} |
|---|
| 20 |
|
|---|
| 21 |
template ForwardGtkOsCFunc( alias cFunc ) { |
|---|
| 22 |
alias ParameterTupleOf!(cFunc) P; |
|---|
| 23 |
alias ReturnTypeOf!(cFunc) R; |
|---|
| 24 |
mixin("public static R " ~ NameOfFunc!(cFunc) ~ "( P p ){ |
|---|
| 25 |
lock.lock(); |
|---|
| 26 |
scope(exit) lock.unlock(); |
|---|
| 27 |
Stdout (mm).newline; |
|---|
| 28 |
return cFunc(p); |
|---|
| 29 |
}"); |
|---|
| 30 |
} |
|---|
| 31 |
|
|---|
| 32 |
public class OS { |
|---|
| 33 |
mixin ForwardGtkOsCFunc!(cairo_version); |
|---|
| 34 |
mixin ForwardGtkOsCFunc!(cairo_version_string); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
void main() |
|---|
| 38 |
{ |
|---|
| 39 |
Stdout ("calling cairo_version...").newline; |
|---|
| 40 |
int p = OS.cairo_version(); |
|---|
| 41 |
int i = cairo_version(); |
|---|
| 42 |
Stdout.formatln("OS.cairo_version() returns: {} cairo_version() returns: {}", p, i ).newline; |
|---|
| 43 |
printf("OS.cairo_version_string returns: %s\n", cairo_version_string() ); |
|---|
| 44 |
} |
|---|