Showing with 269 additions and 0 deletions.
  1. +3 −0 mak/COPY
  2. +106 −0 src/core/stdcpp/exception.d
  3. +146 −0 src/core/stdcpp/typeinfo.d
  4. +7 −0 win32.mak
  5. +7 −0 win64.mak
3 changes: 3 additions & 0 deletions mak/COPY
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ COPY=\
$(IMPDIR)\core\stdc\wchar_.d \
$(IMPDIR)\core\stdc\wctype.d \
\
$(IMPDIR)\core\stdcpp\typeinfo.d \
$(IMPDIR)\core\stdcpp\exception.d \
\
$(IMPDIR)\core\sys\unwind.d \
\
$(IMPDIR)\core\sys\freebsd\dlfcn.d \
Expand Down
106 changes: 106 additions & 0 deletions src/core/stdcpp/exception.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// Written in the D programming language.

/**
* Interface to C++ <exception>
*
* Copyright: Copyright (c) 2016 D Language Foundation
* License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: $(WEB digitalmars.com, Walter Bright)
* Source: $(DRUNTIMESRC core/stdcpp/_exception.d)
*/

module core.stdcpp.exception;

version (CRuntime_DigitalMars)
{
import core.stdcpp.typeinfo;

extern (C++, std)
{
alias void function() unexpected_handler;
unexpected_handler set_unexpected(unexpected_handler f) nothrow;
void unexpected();

alias void function() terminate_handler;
terminate_handler set_terminate(terminate_handler f) nothrow;
void terminate();

bool uncaught_exception();

class exception
{
this() nothrow { }
this(const exception) nothrow { }
//exception operator=(const exception) nothrow { return this; }
//virtual ~this() nothrow;
void dtor() { }
const(char)* what() const nothrow;
}

class bad_exception : exception
{
this() nothrow { }
this(const bad_exception) nothrow { }
//bad_exception operator=(const bad_exception) nothrow { return this; }
//virtual ~this() nothrow;
override const(char)* what() const nothrow;
}
}
}
else version (CRuntime_Glibc)
{
extern (C++, std)
{
alias void function() unexpected_handler;
unexpected_handler set_unexpected(unexpected_handler f) nothrow;
void unexpected();

alias void function() terminate_handler;
terminate_handler set_terminate(terminate_handler f) nothrow;
void terminate();

void unexpected();
pure bool uncaught_exception();

class exception
{
this();
//virtual ~this();
void dtor1();
void dtor2();
const(char)* what() const;
}

class bad_exception : exception
{
this();
//virtual ~this();
const(char)* what() const;
}
}
}
else version (CRuntime_Microsoft)
{
extern (C++, std)
{
class exception
{
this();
this(const exception);
//exception operator=(const exception) { return this; }
//virtual ~this();
void dtor() { }
const(char)* what() const;

private:
const(char)* mywhat;
bool dofree;
}

class bad_exception : exception
{
this(const(char)* msg = "bad exception");
//virtual ~this();
}
}
}
146 changes: 146 additions & 0 deletions src/core/stdcpp/typeinfo.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// Written in the D programming language.

/**
* Interface to C++ <typeinfo>
*
* Copyright: Copyright (c) 2016 D Language Foundation
* License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: $(WEB digitalmars.com, Walter Bright)
* Source: $(DRUNTIMESRC core/stdcpp/_typeinfo.d)
*/

module core.stdcpp.typeinfo;

version (CRuntime_DigitalMars)
{
import core.stdcpp.exception;

extern (C++, std)
{
class type_info
{
void* pdata;

public:
//virtual ~this();
void dtor() { } // reserve slot in vtbl[]

//bool operator==(const type_info rhs) const;
//bool operator!=(const type_info rhs) const;
final bool before(const type_info rhs) const;
final const(char)* name() const;
protected:
//type_info();
private:
//this(const type_info rhs);
//type_info operator=(const type_info rhs);
}

class bad_cast : core.stdcpp.exception.std.exception
{
this() nothrow { }
this(const bad_cast) nothrow { }
//bad_cast operator=(const bad_cast) nothrow { return this; }
//virtual ~this() nothrow;
override const(char)* what() const nothrow;
}

class bad_typeid : core.stdcpp.exception.std.exception
{
this() nothrow { }
this(const bad_typeid) nothrow { }
//bad_typeid operator=(const bad_typeid) nothrow { return this; }
//virtual ~this() nothrow;
override const (char)* what() const nothrow;
}
}
}
else version (CRuntime_Microsoft)
{
import core.stdcpp.exception;

struct __type_info_node
{
void* _MemPtr;
__type_info_node* _Next;
}

extern __gshared __type_info_node __type_info_root_node;

extern (C++, std)
{
class type_info
{

public:
//virtual ~this();
void dtor() { } // reserve slot in vtbl[]
//bool operator==(const type_info rhs) const;
//bool operator!=(const type_info rhs) const;
final bool before(const type_info rhs) const;
final const(char)* name(__type_info_node* p = &__type_info_root_node) const;

private:
void* pdata;
char _name[1];
//this(const type_info rhs);
//type_info operator=(const type_info rhs);
}

class bad_cast : core.stdcpp.exception.std.exception
{
this(const(char)* msg = "bad cast") { }
this(const bad_cast) { }
//virtual ~this();
}

class bad_typeid : core.stdcpp.exception.std.exception
{
this(const(char)* msg = "bad typeid") { }
this(const bad_typeid) { }
//virtual ~this();
}
}
}
else version (CRuntime_Glibc)
{
import core.stdcpp.exception;

extern (C++, __cxxabiv1)
{
class __class_type_info;
}

extern (C++, std)
{
class type_info
{
void dtor1(); // consume destructor slot in vtbl[]
void dtor2(); // consume destructor slot in vtbl[]
final const(char)* name();
final bool before(const type_info) const;
//bool operator==(const type_info) const;
bool __is_pointer_p() const;
bool __is_function_p() const;
bool __do_catch(const type_info, void**, uint) const;
bool __do_upcast(const __cxxabiv1.__class_type_info, void**) const;

const(char)* _name;
this(const(char)*);
}

class bad_cast : core.stdcpp.exception.std.exception
{
this();
//~this();
const(char)* what() const;
}

class bad_typeid : core.stdcpp.exception.std.exception
{
this();
//~this();
const(char)* what() const;
}
}
}
7 changes: 7 additions & 0 deletions win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ $(IMPDIR)\core\sync\semaphore.di : src\core\sync\semaphore.d

copydir: $(IMPDIR)
mkdir $(IMPDIR)\core\stdc
mkdir $(IMPDIR)\core\stdcpp
mkdir $(IMPDIR)\core\internal
mkdir $(IMPDIR)\core\sys\freebsd\sys
mkdir $(IMPDIR)\core\sys\linux\sys
Expand Down Expand Up @@ -336,6 +337,12 @@ $(IMPDIR)\core\stdc\wchar_.d : src\core\stdc\wchar_.d
$(IMPDIR)\core\stdc\wctype.d : src\core\stdc\wctype.d
copy $** $@

$(IMPDIR)\core\stdcpp\exception.d : src\core\stdcpp\exception.d
copy $** $@

$(IMPDIR)\core\stdcpp\typeinfo.d : src\core\stdcpp\typeinfo.d
copy $** $@

$(IMPDIR)\core\sys\unwind.d : src\core\sys\unwind.d
copy $** $@

Expand Down
7 changes: 7 additions & 0 deletions win64.mak
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ $(IMPDIR)\core\sync\semaphore.di : src\core\sync\semaphore.d

copydir: $(IMPDIR)
mkdir $(IMPDIR)\core\stdc
mkdir $(IMPDIR)\core\stdcpp
mkdir $(IMPDIR)\core\internal
mkdir $(IMPDIR)\core\sys\freebsd\sys
mkdir $(IMPDIR)\core\sys\linux\sys
Expand Down Expand Up @@ -344,6 +345,12 @@ $(IMPDIR)\core\stdc\wchar_.d : src\core\stdc\wchar_.d
$(IMPDIR)\core\stdc\wctype.d : src\core\stdc\wctype.d
copy $** $@

$(IMPDIR)\core\stdcpp\exception.d : src\core\stdcpp\exception.d
copy $** $@

$(IMPDIR)\core\stdcpp\typeinfo.d : src\core\stdcpp\typeinfo.d
copy $** $@

$(IMPDIR)\core\sys\unwind.d : src\core\sys\unwind.d
copy $** $@

Expand Down