"Fossies" - the Fresh Open Source Software Archive

Member "dmd2/src/dmd/dmd/root/dcompat.h" (20 Nov 2020, 1275 Bytes) of package /linux/misc/dmd.2.094.2.linux.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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