initial commit of DSFML2
some basic things work, much still has to be done - made as few changes as possible to make it compile under D2 - removed system.thread, use standard threads - lots of other changes git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1333 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
dd255a916d
commit
8431753ba3
58 changed files with 1297 additions and 1274 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -40,6 +41,6 @@ public import
|
|||
dsfml.system.mutex,
|
||||
dsfml.system.randomizer,
|
||||
dsfml.system.sleep,
|
||||
dsfml.system.thread,
|
||||
// dsfml.system.thread, // thread isn't used anywhere in the library and D threading is nice, so the user can safely use standard threads
|
||||
dsfml.system.vector2,
|
||||
dsfml.system.vector3;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -31,9 +32,10 @@ version (Tango)
|
|||
}
|
||||
else
|
||||
{
|
||||
import std.c.stdlib;
|
||||
import std.gc;
|
||||
|
||||
public import core.memory;
|
||||
}
|
||||
|
||||
/*
|
||||
struct GC
|
||||
{
|
||||
static void* malloc(uint size)
|
||||
|
@ -56,7 +58,8 @@ else
|
|||
std.gc.removeRange(ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
* Template for native non-GCed allocation for interaction between C and D threads.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -85,7 +86,10 @@ private:
|
|||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-system-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
|
||||
sfClock_Create = cast(pf_sfClock_Create)dll.getSymbol("sfClock_Create");
|
||||
sfClock_Destroy = cast(pf_sfClock_Destroy)dll.getSymbol("sfClock_Destroy");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -27,12 +28,38 @@ module dsfml.system.common;
|
|||
|
||||
public import dsfml.system.dllloader;
|
||||
|
||||
// type aliases for D2
|
||||
package
|
||||
{
|
||||
alias const(char) cchar;
|
||||
alias const(wchar) cwchar;
|
||||
alias const(dchar) cdchar;
|
||||
alias immutable(char) ichar;
|
||||
alias immutable(wchar) iwchar;
|
||||
alias immutable(dchar) idchar;
|
||||
alias const(char)[] cstring;
|
||||
}
|
||||
|
||||
// used to mixin code function
|
||||
string loadFromSharedLib(string fname)
|
||||
{
|
||||
return fname ~ " = " ~ "cast(typeof(" ~ fname ~ ")) dll.getSymbol(\"" ~ fname ~ "\");";
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for all DSFML classes.
|
||||
*/
|
||||
class DSFMLObject
|
||||
{
|
||||
this(void* ptr, bool preventDelete = false)
|
||||
private:
|
||||
bool m_preventDelete;
|
||||
|
||||
protected:
|
||||
void* m_ptr;
|
||||
|
||||
public:
|
||||
|
||||
this(void* ptr, bool preventDelete = false)
|
||||
{
|
||||
m_ptr = ptr;
|
||||
}
|
||||
|
@ -61,10 +88,4 @@ class DSFMLObject
|
|||
{
|
||||
assert(m_ptr !is null, "Problem occurs with a null pointer in " ~ this.toString);
|
||||
}
|
||||
|
||||
protected:
|
||||
void* m_ptr;
|
||||
|
||||
private:
|
||||
bool m_preventDelete;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -59,16 +60,16 @@ static this()
|
|||
}
|
||||
}
|
||||
|
||||
private void report(char[] msg, char[] lib, char[] symb)
|
||||
private void report(string msg, string lib, string symb)
|
||||
{
|
||||
char[] str = "Loading error. Reason : " ~ msg ~ " (library : " ~ lib ~ ", symbol : " ~ symb ~ ")";
|
||||
string str = "Loading error. Reason : " ~ msg ~ " (library : " ~ lib ~ ", symbol : " ~ symb ~ ")";
|
||||
version (Tango)
|
||||
{
|
||||
Cerr(str).newline;
|
||||
}
|
||||
else
|
||||
{
|
||||
fwritefln(stderr, str);
|
||||
stderr.writeln(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,15 +79,15 @@ private void report(char[] msg, char[] lib, char[] symb)
|
|||
*/
|
||||
class DllLoader
|
||||
{
|
||||
static DllLoader load(char[] library)
|
||||
static DllLoader load(string library)
|
||||
{
|
||||
version (Windows)
|
||||
{
|
||||
char[] libraryName = library ~ ".dll";
|
||||
string libraryName = library ~ ".dll";
|
||||
}
|
||||
version (linux)
|
||||
{
|
||||
char[] libraryName = "lib" ~ library ~ ".so";
|
||||
string libraryName = "lib" ~ library ~ ".so";
|
||||
}
|
||||
|
||||
if (libraryName in alreadyLoaded)
|
||||
|
@ -106,7 +107,7 @@ class DllLoader
|
|||
close();
|
||||
}
|
||||
|
||||
void* getSymbol(char[] symbolName)
|
||||
void* getSymbol(string symbolName)
|
||||
{
|
||||
void* symb;
|
||||
version (Tango)
|
||||
|
@ -152,7 +153,7 @@ class DllLoader
|
|||
}
|
||||
|
||||
private:
|
||||
this(char[] libraryPath)
|
||||
this(string libraryPath)
|
||||
{
|
||||
m_libPath = libraryPath;
|
||||
|
||||
|
@ -184,6 +185,6 @@ private:
|
|||
MODULEHANDLE m_lib;
|
||||
}
|
||||
|
||||
static DllLoader[char[]] alreadyLoaded;
|
||||
char[] m_libPath;
|
||||
static DllLoader[string] alreadyLoaded;
|
||||
string m_libPath;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -27,7 +28,7 @@ module dsfml.system.exception;
|
|||
|
||||
class LoadingException : Exception
|
||||
{
|
||||
this(char[] msg)
|
||||
this(string msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ class LoadingException : Exception
|
|||
|
||||
class NullParameterException : Exception
|
||||
{
|
||||
this(char[] msg)
|
||||
this(string msg)
|
||||
{
|
||||
super(msg);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -84,7 +85,10 @@ private:
|
|||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-system-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
|
||||
sfMutex_Create = cast(pf_sfMutex_Create)dll.getSymbol("sfMutex_Create");
|
||||
sfMutex_Destroy = cast(pf_sfMutex_Destroy)dll.getSymbol("sfMutex_Destroy");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -119,7 +120,10 @@ private:
|
|||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-system-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
|
||||
sfRandom_SetSeed = cast(pf_sfRandom_SetSeed)dll.getSymbol("sfRandom_SetSeed");
|
||||
sfRandom_GetSeed = cast(pf_sfRandom_GetSeed)dll.getSymbol("sfRandom_GetSeed");
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -36,7 +37,11 @@ extern(C)
|
|||
|
||||
static this()
|
||||
{
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
debug
|
||||
DllLoader dll = DllLoader.load("csfml-system-d");
|
||||
else
|
||||
DllLoader dll = DllLoader.load("csfml-system");
|
||||
|
||||
|
||||
sfSleep = cast(pf_sfSleep)dll.getSymbol("sfSleep");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -25,12 +26,20 @@
|
|||
|
||||
module dsfml.system.stringutil;
|
||||
|
||||
// version (Tango)
|
||||
// {
|
||||
// public import tango.stdc.stringz;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
import std.traits; // for Unqual
|
||||
|
||||
/*
|
||||
version (Tango)
|
||||
{
|
||||
public import tango.stdc.stringz;
|
||||
}
|
||||
else
|
||||
{
|
||||
public import std.string;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
T* toStringz(T)(T[] str)
|
||||
{
|
||||
if (str is null)
|
||||
|
@ -38,14 +47,15 @@ module dsfml.system.stringutil;
|
|||
else if (str.length && str[$ - 1] is T.init)
|
||||
return str.ptr;
|
||||
|
||||
T[] ret = new T[str.length + 1];
|
||||
auto ret = new Unqual!(T)[str.length + 1];
|
||||
|
||||
ret[0 .. str.length] = str[0 .. $];
|
||||
ret[str.length] = 0;
|
||||
|
||||
return ret.ptr;
|
||||
return cast(T*) ret.ptr;
|
||||
}
|
||||
|
||||
|
||||
size_t stringLength(T)(T* p)
|
||||
{
|
||||
if (p is null || *p == T.init)
|
||||
|
@ -63,107 +73,10 @@ module dsfml.system.stringutil;
|
|||
|
||||
T[] fromStringz(T)(T* ptr)
|
||||
{
|
||||
T[] ret = new T[stringLength(ptr)];
|
||||
auto ret = new Unqual!(T)[stringLength(ptr)];
|
||||
ret[0..$] = ptr[0..ret.length];
|
||||
|
||||
return ret;
|
||||
return cast(T[]) ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /*
|
||||
// * Tango equivalent functions
|
||||
// *
|
||||
// * Author : Keinfarbton
|
||||
// * Licence : BSD style
|
||||
// */
|
||||
// char* toStringz(char[] s)
|
||||
// {
|
||||
// if (s.ptr)
|
||||
// if (!(s.length && s[$-1] is 0))
|
||||
// s = s ~ '\0';
|
||||
// return s.ptr;
|
||||
// }
|
||||
//
|
||||
// char[] fromStringz (char* s)
|
||||
// {
|
||||
// size_t i;
|
||||
//
|
||||
// if (s)
|
||||
// while (*(s+i))
|
||||
// ++i;
|
||||
//
|
||||
// return s ? s[0 .. i] : null;
|
||||
// }
|
||||
//
|
||||
// wchar* toString16z(wchar[] s)
|
||||
// {
|
||||
// if (s.ptr)
|
||||
// if (!(s.length && s[$-1] is 0))
|
||||
// s = s ~ '\0';
|
||||
// return s.ptr;
|
||||
// }
|
||||
//
|
||||
// wchar[] fromString16z (wchar* s)
|
||||
// {
|
||||
// size_t i;
|
||||
//
|
||||
// if (s)
|
||||
// while (*(s+i))
|
||||
// ++i;
|
||||
//
|
||||
// return s ? s[0 .. i] : null;
|
||||
// }
|
||||
//
|
||||
// dchar* toString32z (dchar[] s)
|
||||
// {
|
||||
// if (s.ptr)
|
||||
// if (!(s.length && s[$-1] is 0))
|
||||
// s = s ~ "\0"d;
|
||||
// return s.ptr;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// dchar[] fromString32z (dchar* s)
|
||||
// {
|
||||
// size_t i;
|
||||
//
|
||||
// if (s)
|
||||
// while (*(s+i))
|
||||
// ++i;
|
||||
//
|
||||
// return s ? s[0 .. i] : null;
|
||||
// }
|
||||
// }
|
||||
version (UnitTest)
|
||||
{
|
||||
void main()
|
||||
{
|
||||
|
||||
}
|
||||
unittest
|
||||
{
|
||||
char[] str = "Test";
|
||||
char[] espaceStr = "string with espace";
|
||||
|
||||
dchar[] strW = "Test"d;
|
||||
dchar[] espaceStrW = "string with espace"d;
|
||||
|
||||
char[] empty = "";
|
||||
dchar[] emptyW = ""d;
|
||||
|
||||
char[] nullStr = null;
|
||||
dchar[] nullStrW = null;
|
||||
|
||||
assert(fromStringz(toStringz(str)) == str);
|
||||
assert(fromStringz(toStringz(espaceStr)) == espaceStr);
|
||||
assert(fromStringz(toStringz(strW)) == strW);
|
||||
assert(fromStringz(toStringz(espaceStrW)) == espaceStrW);
|
||||
|
||||
assert(fromStringz(toStringz(empty)) == empty);
|
||||
assert(fromStringz(toStringz(emptyW)) == emptyW);
|
||||
|
||||
assert(fromStringz(toStringz(nullStr)) == nullStr);
|
||||
assert(fromStringz(toStringz(nullStrW)) == nullStrW);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,216 +0,0 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
* liable for any damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute
|
||||
* it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented;
|
||||
* you must not claim that you wrote the original software.
|
||||
* If you use this software in a product, an acknowledgment
|
||||
* in the product documentation would be appreciated but
|
||||
* is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such,
|
||||
* and must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any
|
||||
* source distribution.
|
||||
*/
|
||||
|
||||
module dsfml.system.thread;
|
||||
|
||||
version(Tango)
|
||||
{
|
||||
static import tango.core.Thread;
|
||||
alias tango.core.Thread.Thread DThread;
|
||||
}
|
||||
else
|
||||
{
|
||||
static import std.thread;
|
||||
alias std.thread.Thread DThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Thread defines a simple thread abstraction.
|
||||
*
|
||||
* Examples:
|
||||
* Can be a base class (you need to override void run(void) method) :
|
||||
* --------------------
|
||||
* class MyThread : Thread
|
||||
* {
|
||||
* void function()
|
||||
* {
|
||||
* this.launch();
|
||||
* }
|
||||
*
|
||||
* //Thread entry point
|
||||
* protected void run()
|
||||
* {
|
||||
* }
|
||||
* }
|
||||
* --------------------
|
||||
*
|
||||
* or
|
||||
*
|
||||
* --------------------
|
||||
* void main()
|
||||
* {
|
||||
* Thread t = new Thread(&threadStart);
|
||||
* t.launch();
|
||||
* t.wait(); //Wait the end of t thread
|
||||
* }
|
||||
*
|
||||
* //Thread entry point
|
||||
* void threadStart (void* userData)
|
||||
* {
|
||||
*
|
||||
* }
|
||||
* --------------------
|
||||
*
|
||||
* or
|
||||
*
|
||||
* --------------------
|
||||
* void main()
|
||||
* {
|
||||
* MyObject foo = new MyObject();
|
||||
* Thread t = new Thread(&foo.bar);
|
||||
* t.launch();
|
||||
* t.wait(); //Wait the end of t thread
|
||||
* }
|
||||
*
|
||||
* class MyObject
|
||||
* {
|
||||
* void bar(void* user)
|
||||
* {
|
||||
* //...
|
||||
* }
|
||||
* }
|
||||
* --------------------
|
||||
*/
|
||||
class Thread
|
||||
{
|
||||
/**
|
||||
* Construct the thread from a function pointer.
|
||||
*
|
||||
* Params:
|
||||
* func = Entry point of the thread
|
||||
* userData = Data to pass to the thread function (NULL by default)
|
||||
*
|
||||
*/
|
||||
this(void function(void*) func, void* userData = null)
|
||||
{
|
||||
m_t = new DThread(&threadStart);
|
||||
|
||||
m_func = func;
|
||||
m_userData = userData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the thread from a delegate.
|
||||
*
|
||||
* Params:
|
||||
* dg = Entry point of the thread
|
||||
* userData = Data to pass to the thread function (NULL by default)
|
||||
*
|
||||
*/
|
||||
this(void delegate(void*) dg, void* userData = null)
|
||||
{
|
||||
m_t = new DThread(&threadStart);
|
||||
|
||||
m_dg = dg;
|
||||
m_userData = userData;
|
||||
|
||||
m_isDelegate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the thread
|
||||
*/
|
||||
final void launch()
|
||||
{
|
||||
if (!m_running)
|
||||
{
|
||||
m_t.start();
|
||||
m_running = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait until the thread finishes
|
||||
*/
|
||||
final void wait()
|
||||
{
|
||||
if(m_running)
|
||||
{
|
||||
version (Tango)
|
||||
{
|
||||
m_t.join();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_t.wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Protected constructor
|
||||
*/
|
||||
this()
|
||||
{
|
||||
m_t = new DThread(&threadStart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method in class derived from Thread.
|
||||
*/
|
||||
void run()
|
||||
{
|
||||
if (m_isDelegate)
|
||||
this.m_dg(this.m_userData);
|
||||
else
|
||||
this.m_func(this.m_userData);
|
||||
}
|
||||
|
||||
private:
|
||||
DThread m_t;
|
||||
bool m_isDelegate;
|
||||
bool m_running;
|
||||
|
||||
union
|
||||
{
|
||||
void function(void*) m_func;
|
||||
void delegate(void*) m_dg;
|
||||
}
|
||||
|
||||
void* m_userData;
|
||||
|
||||
/*
|
||||
* Thread entry point
|
||||
*/
|
||||
version (Tango)
|
||||
{
|
||||
final void threadStart()
|
||||
{
|
||||
run();
|
||||
m_running = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
final int threadStart()
|
||||
{
|
||||
run();
|
||||
m_running = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -56,7 +57,7 @@ struct Vector2(T)
|
|||
{
|
||||
x += other.x;
|
||||
y += other.y;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (-=) overload
|
||||
|
@ -64,7 +65,7 @@ struct Vector2(T)
|
|||
{
|
||||
x -= other.x;
|
||||
y -= other.y;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (+) overload
|
||||
|
@ -90,7 +91,7 @@ struct Vector2(T)
|
|||
{
|
||||
x *= i;
|
||||
y *= i;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (/) overload
|
||||
|
@ -104,11 +105,11 @@ struct Vector2(T)
|
|||
{
|
||||
x /= i;
|
||||
y /= i;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
///
|
||||
int opEquals(Vector2 other)
|
||||
const bool opEquals(ref const(Vector2) other)
|
||||
{
|
||||
return (x == other.x) && (y == other.y);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* DSFML - SFML Library binding in D language.
|
||||
* DSFML - SFML Library wrapper for the D programming language.
|
||||
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
|
||||
* Copyright (C) 2010 Andreas Hollandt
|
||||
*
|
||||
* This software is provided 'as-is', without any express or
|
||||
* implied warranty. In no event will the authors be held
|
||||
|
@ -59,7 +60,7 @@ struct Vector3(T)
|
|||
x += other.x;
|
||||
y += other.y;
|
||||
z += other.z;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (-=) overload
|
||||
|
@ -68,7 +69,7 @@ struct Vector3(T)
|
|||
x -= other.x;
|
||||
y -= other.y;
|
||||
z -= other.z;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (+) overload
|
||||
|
@ -95,7 +96,7 @@ struct Vector3(T)
|
|||
x *= i;
|
||||
y *= i;
|
||||
z *= i;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// (/) overload
|
||||
|
@ -110,11 +111,11 @@ struct Vector3(T)
|
|||
x /= i;
|
||||
y /= i;
|
||||
z /= i;
|
||||
return *this;
|
||||
return this;
|
||||
}
|
||||
|
||||
///
|
||||
int opEquals(Vector3 other)
|
||||
const bool opEquals(ref const(Vector3) other)
|
||||
{
|
||||
return (x == other.x) && (y == other.y) && (z == other.z) ;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue