Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1 @@
include ../example.mk

View File

@@ -0,0 +1,28 @@
module runme;
import tango.io.Stdout;
static import example;
void main() {
Stdout.formatln("ICONST = {} (should be 42)", example.ICONST);
Stdout.formatln("FCONST = {} (should be 2.18)", example.FCONST);
Stdout.formatln("CCONST = {} (should be 'x')", example.CCONST);
Stdout.formatln("CCONST2 = {} (this should be on a new line)", example.CCONST2);
Stdout.formatln("SCONST = {} (should be 'Hello World')", example.SCONST);
Stdout.formatln("SCONST2 = {} (should be '\"Hello World\"')", example.SCONST2);
Stdout.formatln("EXPR = {} (should be 48.55)", example.EXPR);
Stdout.formatln("iconst = {} (should be 37)", example.iconst);
Stdout.formatln("fconst = {} (should be 3.14)", example.fconst);
static if (is(typeof(example.EXTERN))) {
Stdout.formatln("EXTERN should not be defined, but is: {}.", example.EXTERN );
} else {
Stdout.formatln("EXTERN isn't defined (good)");
}
static if (is(typeof(example.FOO))) {
Stdout.formatln("FOO should not be defined, but is: {}.", example.FOO);
} else {
Stdout.formatln("FOO isn't defined (good)");
}
}

View File

@@ -0,0 +1,28 @@
module runme;
import std.stdio;
static import example;
void main() {
writefln("ICONST = %s (should be 42)", example.ICONST);
writefln("FCONST = %s (should be 2.1828)", example.FCONST);
writefln("CCONST = %s (should be 'x')", example.CCONST);
writefln("CCONST2 = %s (this should be on a new line)", example.CCONST2);
writefln("SCONST = %s (should be 'Hello World')", example.SCONST);
writefln("SCONST2 = %s (should be '\"Hello World\"')", example.SCONST2);
writefln("EXPR = %s (should be 48.5484)", example.EXPR);
writefln("iconst = %s (should be 37)", example.iconst);
writefln("fconst = %s (should be 3.14)", example.fconst);
static if (is(typeof(example.EXTERN))) {
writefln("EXTERN should not be defined, but is: %s.", example.EXTERN );
} else {
writeln("EXTERN isn't defined (good)");
}
static if (is(typeof(example.FOO))) {
writefln("FOO should not be defined, but is: %s.", example.FOO);
} else {
writeln("FOO isn't defined (good)");
}
}

View File

@@ -0,0 +1,32 @@
/* File : example.i */
%module example
/* Force the generated D code to use the C constant values rather than
retrieving them at runtime. You can also try disabling the feature and
compare the generated code. */
%dmanifestconst;
/* A few preprocessor macros */
#define ICONST 42
#define FCONST 2.1828
#define CCONST 'x'
#define CCONST2 '\n'
#define SCONST "Hello World"
#define SCONST2 "\"Hello World\""
/* This should work just fine */
#define EXPR ICONST + 3*(FCONST)
/* This shouldn't do anything */
#define EXTERN extern
/* Neither should this (BAR isn't defined) */
#define FOO (ICONST + BAR)
/* The following directives also produce constants */
%constant int iconst = 37;
%constant double fconst = 3.14;