blob: 88f20952cc9ef88bdb889398da8d631a23ac8a4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved
* written by Walter Bright
* http://www.digitalmars.com
* Distributed under the Boost Software License, Version 1.0.
* http://www.boost.org/LICENSE_1_0.txt
* https://github.com/dlang/dmd/blob/master/src/dmd/root/dcompat.h
*/
#pragma once
#include "dsystem.h"
/// Represents a D [ ] array
template<typename T>
struct DArray
{
size_t length;
T *ptr;
DArray() : length(0), ptr(NULL) { }
DArray(size_t length_in, T *ptr_in)
: length(length_in), ptr(ptr_in) { }
};
struct DString : public DArray<const char>
{
DString() : DArray<const char>() { }
DString(const char *ptr)
: DArray<const char>(ptr ? strlen(ptr) : 0, ptr) { }
DString(size_t length, const char *ptr)
: DArray<const char>(length, ptr) { }
};
/// Corresponding C++ type that maps to D size_t
#if __APPLE__ && __i386__
// size_t is 'unsigned long', which makes it mangle differently than D's 'uint'
typedef unsigned d_size_t;
#elif MARS && DMD_VERSION >= 2079 && DMD_VERSION <= 2081 && \
__APPLE__ && __SIZEOF_SIZE_T__ == 8
// DMD versions between 2.079 and 2.081 mapped D ulong to uint64_t on OS X.
typedef uint64_t d_size_t;
#else
typedef size_t d_size_t;
#endif
|