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:
trass3r 2010-01-06 20:25:45 +00:00
parent dd255a916d
commit 8431753ba3
58 changed files with 1297 additions and 1274 deletions

View file

@ -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

View file

@ -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
@ -155,7 +156,7 @@ class Ftp : DSFMLObject
* Returns:
* The response message
*/
char[] getMessage()
string getMessage()
{
return fromStringz(sfFtpResponse_GetMessage(m_ptr));
}
@ -206,7 +207,7 @@ class Ftp : DSFMLObject
* Returns:
* Directory name
*/
char[] getDirectory()
string getDirectory()
{
return fromStringz(sfFtpDirectoryResponse_GetDirectory(m_ptr));
}
@ -266,7 +267,7 @@ class Ftp : DSFMLObject
* Returns:
* Filename
*/
char[] opIndex(size_t index)
string opIndex(size_t index)
{
return fromStringz(sfFtpListingResponse_GetFilename(m_ptr, index));
}
@ -274,7 +275,7 @@ class Ftp : DSFMLObject
/**
* Foreach implementation
*/
int opApply(int delegate(char[]) dg)
int opApply(int delegate(string) dg)
{
size_t count = getCount();
int result;
@ -366,7 +367,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpResponse login(char[] username, char[] password)
FtpResponse login(string username, string password)
{
return new FtpResponse(sfFtp_Login(m_ptr, toStringz(username), toStringz(password)));
}
@ -413,7 +414,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpListingResponse getDirectoryListing(char[] directory = null)
FtpListingResponse getDirectoryListing(string directory = null)
{
return new FtpListingResponse(sfFtp_GetDirectoryListing(m_ptr, toStringz(directory)));
}
@ -427,7 +428,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpResponse changeDirectory(char[] directory)
FtpResponse changeDirectory(string directory)
{
return new FtpResponse(sfFtp_ChangeDirectory(m_ptr, toStringz(directory)));
}
@ -452,7 +453,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpResponse makeDirectory(char[] name)
FtpResponse makeDirectory(string name)
{
return new FtpResponse(sfFtp_MakeDirectory(m_ptr, toStringz(name)));
}
@ -466,7 +467,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpResponse deleteDirectory(char[] name)
FtpResponse deleteDirectory(string name)
{
return new FtpResponse(sfFtp_DeleteDirectory(m_ptr, toStringz(name)));
}
@ -481,7 +482,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpResponse renameFile(char[] name, char[] newName)
FtpResponse renameFile(string name, string newName)
{
return new FtpResponse(sfFtp_RenameFile(m_ptr, toStringz(name), toStringz(newName)));
}
@ -495,7 +496,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpResponse deleteFile(char[] name)
FtpResponse deleteFile(string name)
{
return new FtpResponse(sfFtp_DeleteFile(m_ptr, toStringz(name)));
}
@ -511,7 +512,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpResponse download(char[] distantFile, char[] destFile, FtpTransferMode mode = FtpTransferMode.BINARY)
FtpResponse download(string distantFile, string destFile, FtpTransferMode mode = FtpTransferMode.BINARY)
{
return new FtpResponse(sfFtp_Download(m_ptr, toStringz(distantFile), toStringz(destFile), mode));
}
@ -526,7 +527,7 @@ class Ftp : DSFMLObject
* Returns:
* Server response to the request
*/
FtpResponse upload(char[] localFile, char[] destFile, FtpTransferMode mode = FtpTransferMode.BINARY)
FtpResponse upload(string localFile, string destFile, FtpTransferMode mode = FtpTransferMode.BINARY)
{
return new FtpResponse(sfFtp_Upload(m_ptr, toStringz(localFile), toStringz(destFile), mode));
}
@ -575,7 +576,10 @@ private:
}
static this()
{
DllLoader dll = DllLoader.load("csfml-network");
debug
DllLoader dll = DllLoader.load("csfml-network-d");
else
DllLoader dll = DllLoader.load("csfml-network");
sfFtp_Create = cast(pf_sfFtp_Create)dll.getSymbol("sfFtp_Create");
sfFtp_Destroy = cast(pf_sfFtp_Destroy)dll.getSymbol("sfFtp_Destroy");

View file

@ -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
@ -99,7 +100,7 @@ class Http : DSFMLObject
* Returns:
* Value of the field, or enpty string if not found
*/
char[] getField(char[] field)
string getField(string field)
{
return fromStringz(sfHttpResponse_GetField(m_ptr, toStringz(field)));
}
@ -147,7 +148,7 @@ class Http : DSFMLObject
* Returns:
* the response body
*/
char[] getBody()
string getBody()
{
return fromStringz(sfHttpResponse_GetBody(m_ptr));
}
@ -203,7 +204,7 @@ class Http : DSFMLObject
* uri = Target URI ("/" by default -- index page)
* requestBody = Content of the request's body (empty by default)
*/
this(HttpMethod requestMethod = HttpMethod.GET, char[] uri = "/", char[] requestBody = "")
this(HttpMethod requestMethod = HttpMethod.GET, string uri = "/", string requestBody = "")
{
super(sfHttpRequest_Create());
sfHttpRequest_SetMethod(m_ptr, requestMethod);
@ -218,7 +219,7 @@ class Http : DSFMLObject
* field = name of the field to set (case-insensitive)
* value = value of the field
*/
void setField(char[] field, char[] value)
void setField(string field, string value)
{
sfHttpRequest_SetField(m_ptr, toStringz(field), toStringz(value));
}
@ -241,7 +242,7 @@ class Http : DSFMLObject
* uri = URI to request, local to the host.
* Returns:
*/
void setURI(char[] uri)
void setURI(string uri)
{
sfHttpRequest_SetURI(m_ptr, toStringz(uri));
}
@ -265,7 +266,7 @@ class Http : DSFMLObject
* Params:
* requestBody = Content of the request body.
*/
void setBody(char[] requestBody)
void setBody(string requestBody)
{
sfHttpRequest_SetBody(m_ptr, toStringz(requestBody));
}
@ -321,7 +322,7 @@ class Http : DSFMLObject
* host = Web server to connect to
* port = port to use for connection (0 by default -- use the standard port of the protocol)
*/
this(char[] host, ushort port = 0)
this(string host, ushort port = 0)
{
super(sfHttp_Create());
sfHttp_SetHost(m_ptr, toStringz(host), port);
@ -339,7 +340,7 @@ class Http : DSFMLObject
* host = Web server to connect to
* port = port to use for connection (0 by default -- use the standard port of the protocol)
*/
void setHost(char[] host, ushort port = 0)
void setHost(string host, ushort port = 0)
{
sfHttp_SetHost(m_ptr, toStringz(host), port);
}
@ -384,7 +385,10 @@ private:
static this()
{
DllLoader dll = DllLoader.load("csfml-network");
debug
DllLoader dll = DllLoader.load("csfml-network-d");
else
DllLoader dll = DllLoader.load("csfml-network");
sfHttp_Create = cast(pf_sfHttp_Create)dll.getSymbol("sfHttp_Create");
sfHttp_Destroy = cast(pf_sfHttp_Destroy)dll.getSymbol("sfHttp_Destroy");

View file

@ -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,7 +41,7 @@ struct IPAddress
* address = IP address ("xxx.xxx.xxx.xxx") or network name
*
*/
static IPAddress opCall(char[] address)
static IPAddress opCall(string address)
{
return sfIPAddress_FromString(toStringz(address));
}
@ -82,7 +83,7 @@ struct IPAddress
*/
bool isValid()
{
return cast(bool)sfIPAddress_IsValid(*this);
return cast(bool)sfIPAddress_IsValid(this);
}
/**
@ -152,7 +153,10 @@ extern (C)
static this()
{
DllLoader dll = DllLoader.load("csfml-network");
debug
DllLoader dll = DllLoader.load("csfml-network-d");
else
DllLoader dll = DllLoader.load("csfml-network");
sfIPAddress_FromBytes = cast(pf_sfIPAddress_FromBytes)dll.getSymbol("sfIPAddress_FromBytes");
sfIPAddress_FromString = cast(pf_sfIPAddress_FromString)dll.getSymbol("sfIPAddress_FromString");

View file

@ -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
@ -44,12 +45,12 @@ import dsfml.system.stringutil;
* Packet p = new Packet();
*
* int i = 32, j = 42;
* char[] k = hello;
* string k = hello;
*
* p.set(i, k, j); //Set the data in the packet
*
* int a, b;
* char[] c;
* string c;
* p.get(a, c, b); //Get data from the packet
*
* //...
@ -113,13 +114,13 @@ class Packet : DSFMLObject
* ----------
* Packet p = new Packet();
*
* char[] str1 = "Hi";
* char[] str2 = "Hello";
* string str1 = "Hi";
* string str2 = "Hello";
*
* p.set(str1, str2);
*
* // Retrieve str1 from packet
* char[] str3;
* string str3;
* p.get(str3);
*
* // Returns an array containing str1 and str2.
@ -169,7 +170,7 @@ class Packet : DSFMLObject
/**
* Add new variables to the packet
* Accept (u)byte, (u)short, (u)int, float, double, char[] and wchar[] types
* Accept (u)byte, (u)short, (u)int, float, double, string and wstring types
*/
Packet set(T...)(T t)
{
@ -180,7 +181,7 @@ class Packet : DSFMLObject
/**
* Retrieve data from the packet
* Accept (u)byte, (u)short, (u)int, float, double, char[] and wchar[] types
* Accept (u)byte, (u)short, (u)int, float, double, string and wstring types
*/
Packet get(T...)(ref T t)
{
@ -250,18 +251,18 @@ private:
{
data = sfPacket_ReadDouble(m_ptr);
}
void internalGet(ref char[] data)
void internalGet(ref string data)
{
scope char[] temp = new char[sfPacket_GetDataSize(m_ptr)];
scope string temp = new char[sfPacket_GetDataSize(m_ptr)];
sfPacket_ReadString(m_ptr, temp.ptr);
size_t l = fromStringz(temp.ptr).length;
data = new char[l];
data[] = temp[0 .. l];
}
void internalGet(ref wchar[] data)
void internalGet(ref wstring data)
{
scope wchar[] temp = new wchar[sfPacket_GetDataSize(m_ptr)];
scope wstring temp = new wchar[sfPacket_GetDataSize(m_ptr)];
sfPacket_ReadWideString(m_ptr, temp.ptr);
size_t l = fromStringz(temp.ptr).length;
data = new wchar[l];
@ -304,12 +305,12 @@ private:
{
sfPacket_WriteDouble(m_ptr, data);
}
void internalSet(char[] data)
void internalSet(string data)
{
sfPacket_WriteString(m_ptr, toStringz(data));
}
void internalSet(wchar[] data)
void internalSet(wstring data)
{
sfPacket_WriteWideString(m_ptr, toStringz(data));
}
@ -379,7 +380,10 @@ private:
static this()
{
DllLoader dll = DllLoader.load("csfml-network");
debug
DllLoader dll = DllLoader.load("csfml-network-d");
else
DllLoader dll = DllLoader.load("csfml-network");
sfPacket_Append = cast(pf_sfPacket_Append)dll.getSymbol("sfPacket_Append");
sfPacket_CanRead = cast(pf_sfPacket_CanRead)dll.getSymbol("sfPacket_CanRead");

View file

@ -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
@ -157,15 +158,18 @@ private:
static this()
{
DllLoader dll = DllLoader.load("csfml-network");
debug
DllLoader dll = DllLoader.load("csfml-network-d");
else
DllLoader dll = DllLoader.load("csfml-network");
static if (is (T : SocketTCP))
{
char[] symbol = "sfSelectorTCP";
string symbol = "sfSelectorTCP";
}
else static if (is (T : SocketUDP))
{
char[] symbol = "sfSelectorUDP";
string symbol = "sfSelectorUDP";
}
sfSelector_Add = cast(pf_sfSelector_Add)dll.getSymbol(symbol ~ "_Add");

View file

@ -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

View file

@ -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
@ -252,7 +253,10 @@ private:
static this()
{
DllLoader dll = DllLoader.load("csfml-network");
debug
DllLoader dll = DllLoader.load("csfml-network-d");
else
DllLoader dll = DllLoader.load("csfml-network");
sfSocketTCP_Accept = cast(pf_sfSocketTCP_Accept)dll.getSymbol("sfSocketTCP_Accept");
sfSocketTCP_Connect = cast(pf_sfSocketTCP_Connect)dll.getSymbol("sfSocketTCP_Connect");

View file

@ -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
@ -228,7 +229,10 @@ private:
static this()
{
DllLoader dll = DllLoader.load("csfml-network");
debug
DllLoader dll = DllLoader.load("csfml-network-d");
else
DllLoader dll = DllLoader.load("csfml-network");
sfSocketUDP_Bind = cast(pf_sfSocketUDP_Bind)dll.getSymbol("sfSocketUDP_Bind");
sfSocketUDP_Create = cast(pf_sfSocketUDP_Create)dll.getSymbol("sfSocketUDP_Create");