summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mszulecki2007-02-21 17:18:01 +0000
committerGravatar mszulecki2007-02-21 17:18:01 +0000
commitbab430316c0c5b88a59c1145a92c55bb55c7da11 (patch)
tree50b07e4dea9bc023b2cf0f91775c4cac9eac0362
parent83283f521dd59e3f5a4c4dda3ae61a6db4406684 (diff)
downloaddskel-bab430316c0c5b88a59c1145a92c55bb55c7da11.tar.gz
dskel-bab430316c0c5b88a59c1145a92c55bb55c7da11.tar.bz2
First attempt at an autotools D helloworld.
git-svn-id: http://svn.sukimashita.com/repos/dskel/trunk@2 4281df72-ff29-0410-8fee-2d9ac0c5f5a7
-rw-r--r--AUTHORS0
-rw-r--r--COPYING0
-rw-r--r--INSTALL0
-rw-r--r--NEWS0
-rw-r--r--README4
-rwxr-xr-xautogen.sh25
-rw-r--r--configure.ac43
-rw-r--r--src/Makefile.am11
-rwxr-xr-xsrc/helloworld.d93
9 files changed, 176 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/AUTHORS
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/COPYING
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/INSTALL
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..13cdc9e
--- /dev/null
+++ b/README
@@ -0,0 +1,4 @@
+This package should provide a sample skeleton of a GTK+ based application
+written in the D Programming Language.
+
+It makes use of the common autotools and the GNU D Compiler (GDC).
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..0128748
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,25 @@
+#/bin/bash
+
+#!/bin/sh
+
+PROJECT=gnome-observer-daemon
+
+topsrcdir=`dirname $0`
+if test x$topsrcdir = x ; then
+ topsrcdir=.
+fi
+
+(test -f $topsrcdir/configure.ac \
+ && test -f $topsrcdir/README \
+ && test -d $topsrcdir/src) || {
+ echo -n "**Error**: Directory "\`$topsrcdir\'" does not look like the"
+ echo " top-level $PROJECT directory"
+ exit 1
+}
+
+which gnome-autogen.sh || {
+ echo "You need to install gnome-common from the GNOME CVS"
+ exit 1
+}
+REQUIRED_AUTOMAKE_VERSION=1.7 . gnome-autogen.sh
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..01a7375
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,43 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT(README)
+
+PACKAGE=helloworld
+VERSION=1.0.0
+
+AM_INIT_AUTOMAKE($PACKAGE,$VERSION)
+AM_MAINTAINER_MODE
+
+AC_GNU_SOURCE
+
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+
+dnl Check for GNU D Compiler
+CC=gdc
+AC_PATH_PROG(GDC, $CC, no)
+
+if test "x$GDC" = "xno"; then
+ AC_MSG_ERROR([No D compiler found])
+fi
+
+AC_SUBST(GDC)
+
+dnl TODO: Check for duit GTK+ D Bindings
+AC_SUBST(DEPS_CFLAGS)
+AC_SUBST(DEPS_LIBS)
+
+AC_CONFIG_FILES([
+Makefile
+src/Makefile
+])
+
+AC_OUTPUT()
+
+dnl Configuration Summary
+echo ""
+echo "Configuration summary"
+echo ""
+echo " * Installation prefix = $prefix"
+echo " * D compiler: $GDC"
+echo ""
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..520df7e
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,11 @@
+SUFFIXES= .d
+
+.d.o:
+ $(GDC) $(DFLAGS) -c -o $@ $<
+
+bin_PROGRAMS = helloworld
+
+helloworld_SOURCES = helloworld.d
+helloworld_LDADD = $(DEPS_LIBS)
+
+AM_CPPFLAGS = $(DEPS_CFLAGS)
diff --git a/src/helloworld.d b/src/helloworld.d
new file mode 100755
index 0000000..c3e6843
--- /dev/null
+++ b/src/helloworld.d
@@ -0,0 +1,93 @@
+/* sh style script syntax is supported */
+
+/* Hello World in D
+ To compile:
+ dmd hello.d
+ or to optimize:
+ dmd -O -inline -release hello.d
+*/
+
+import std.stdio;
+
+void main(char[][] args)
+{
+ writefln("Hello World, Reloaded");
+
+ // auto type inference and built-in foreach
+ foreach (argc, argv; args)
+ {
+ // Object Oriented Programming
+ CmdLin cl = new CmdLin(argc, argv);
+ // Improved typesafe printf
+ writefln(cl.argnum, cl.suffix, " arg: %s", cl.argv);
+ // Automatic or explicit memory management
+ delete cl;
+ }
+
+ // Nested structs and classes
+ struct specs
+ {
+ // all members automatically initialized
+ int count, allocated;
+ }
+
+ // Nested functions can refer to outer
+ // variables like args
+ specs argspecs()
+ {
+ specs* s = new specs;
+ // no need for '->'
+ s.count = args.length; // get length of array with .length
+ s.allocated = typeof(args).sizeof; // built-in native type properties
+ foreach (argv; args)
+ s.allocated += argv.length * typeof(argv[0]).sizeof;
+ return *s;
+ }
+
+ // built-in string and common string operations
+ writefln("argc = %d, " ~ "allocated = %d",
+ argspecs().count, argspecs().allocated);
+}
+
+class CmdLin
+{
+ private int _argc;
+ private char[] _argv;
+
+public:
+ this(int argc, char[] argv) // constructor
+ {
+ _argc = argc;
+ _argv = argv;
+ }
+
+ int argnum()
+ {
+ return _argc + 1;
+ }
+
+ char[] argv()
+ {
+ return _argv;
+ }
+
+ char[] suffix()
+ {
+ char[] suffix = "th";
+ switch (_argc)
+ {
+ case 0:
+ suffix = "st";
+ break;
+ case 1:
+ suffix = "nd";
+ break;
+ case 2:
+ suffix = "rd";
+ break;
+ default:
+ break;
+ }
+ return suffix;
+ }
+}