123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- //////////////////////////////////////////////////////////////////////////////
- //
- // Copyright 2015 Autodesk, Inc. All rights reserved.
- //
- // Use of this software is subject to the terms of the Autodesk license
- // agreement provided at the time of installation or download, or which
- // otherwise accompanies this software in either electronic or hard copy form.
- //
- //////////////////////////////////////////////////////////////////////////////
- //
- // DESCRIPTION:
- //
- // This file contains the extension to the standard set of primitive-
- // type names that should be shared by all Autodesk developers, both
- // in-house and third-party. All new code and modules written in C++
- // should use these type names along with those supplied by C++ itself
- // (for example, int, long, float, double, etc.)
- //
- // Note that C++ 11 (and VC11) now provide standard fixed size integer types
- // such as int16_t, int32_t, etc, and those are now used here. Developers
- // are encouraged to migrate over to using the standard C++ types and
- // the Adesk::Int* and UInt* types may eventually be deprecated.
- //
- // See adeskabb.h for abbreviations of the following names.
- #ifndef _ADESK_H
- #define _ADESK_H
- #include <stdint.h> // int16_t, uint32_t, etc
- #include "AdAChar.h" // ACHAR typedef
- #if __LP64__
- // We need this defined on the 64-bit OS X builds to avoid
- // method overloading conficts between Adesk::Int32 and
- // Adesk::Boolean.
- //
- // We also receive better type checking when Boolean is bool
- #define Adesk_Boolean_is_bool 1
- #define Adesk_Int32_is_int 1
- #endif
- #pragma pack (push, 8)
- #if defined(_MSC_VER)
- // Use _MSC_VER to detect that we are building on Windows. This
- // test will need to be updated a bit when we start supporting the Intel
- // compiler.
- //
- #define _ADESK_WINDOWS_ 1
- #ifndef stdgnu
- #define stdgnu std
- #endif
- #ifndef stdtr1
- #define stdtr1 std::tr1
- #endif
- #elif defined(__APPLE__) && defined(__MACH__)
- #define _ADESK_MAC_ 1
- #define __w64
- #if __LP64__
- #define _AC64
- #endif //__LP64__
-
- #ifdef _LIBCPP_VERSION
- //Clang libc++
- #ifndef stdgnu
- #define stdgnu std
- #endif
- #ifndef stdtr1
- #define stdtr1 std
- #endif
- #else
- //GCC libstdc++
- #define _GCCSTDLIB_
- #ifndef stdgnu
- #define stdgnu __gnu_cxx
- #endif
- #ifndef stdtr1
- #define stdtr1 std::tr1
- #endif
- #endif
- #endif //defined(__APPLE__) && defined(__MACH__)
- struct Adesk
- {
- // The types Int8, Int16 and Int32 will be conditionally compiled
- // to guarantee that each one represents an integer type of exactly
- // 8, 16 and 32 bits respectively. These are to be used only when
- // the EXACT size of the integer is critical.
- //
- // We also need to be sure to use the Adesk::Int32 and Adesk::UInt32
- // datatypes rather than a long now that we support OSX 64-bit builds.
- //
- // Unlike Windows-64, on OSX-64 , a long is 64-bits. Any code that
- // assumes sizeof(int) == sizeof(long) will potentially have bugs. The
- // fix is to consistently use Adesk::Int32 and Adesk::UInt32 in place
- // of longs so we can normalize this all between the two platforms.
- //
- typedef int8_t Int8;
- typedef int16_t Int16;
- //
- // The unsigned versions of the above types.
- //
- typedef uint8_t UInt8;
- typedef uint16_t UInt16;
- #ifdef Adesk_Int32_is_int
- typedef int32_t Int32;
- typedef uint32_t UInt32;
- #ifndef Adesk_Boolean_is_bool
- #error Boolean_is_bool must be defined if Int32_is_int
- #endif
- #else
- // can't use int if Adesk::Boolean is already using it..
- typedef unsigned long UInt32;
- typedef long Int32;
- #endif
- typedef int64_t Int64;
- typedef uint64_t UInt64;
- // Convenient abbreviations (use optionally).
- // Todo: consider removing these from adesk.h
- //
- typedef unsigned char uchar;
- typedef unsigned short ushort;
- typedef unsigned int uint;
- // integer/unsigned integers that can hold a pointer value.
- // These change size depending on the platform and should NEVER
- // be streamed out to permanent storage.
- #if !defined(_WIN64) && !defined (_AC64)
- static_assert(sizeof(long) == 4, "long size in 32-bit windows build?");
- static_assert(sizeof(void *) == 4, "ptr size in 32-bit windows build?");
- // Using __w64 let's us catch potential errors at compile time
- // when /Wp64 is enabled. Also, we use long, instead of int,
- // in the 32-bit build. That's for compatibility with the Int32
- // and UInt32 types.
- //
- typedef __w64 long LongPtr;
- typedef __w64 unsigned long ULongPtr;
- //
- typedef __w64 int IntPtr;
- typedef __w64 unsigned int UIntPtr;
- #else // _WIN64 || _AC64
- static_assert(sizeof(void *) == 8, "ptr size in 64-bit build?");
- typedef int64_t LongPtr;
- typedef uint64_t ULongPtr;
- typedef int64_t IntPtr;
- typedef uint64_t UIntPtr;
- #endif // _WIN64 || _AC64
- typedef LongPtr IntDbId;
- typedef IntPtr GsMarker;
- // Logical type (Note: never use int when Boolean is intended!)
- // Please transition from Boolean type to native bool..
- //
- #ifdef Adesk_Boolean_is_bool
- typedef bool Boolean;
- static const bool kFalse = false;
- static const bool kTrue = true;
- #else
- typedef int Boolean;
- enum { kFalse = 0, kTrue = 1 };
- #endif
- };
- // Please transition from NULL macro to native nullptr..
- #undef NULL
- #define NULL 0
- #ifdef _ADESK_MAC_
- #ifdef nil
- #undef nil
- #endif
- #define nil __DARWIN_NULL
- #endif
- #pragma pack (pop)
- // Use ADESK_NO_VTABLE on base classes which:
- // 1. have virtual methods
- // 2. are never instantiated
- // 3. have a ctor and/or a dtor
- // 4. do not call any virtual methods in the ctor or dtor
- // This allows the compiler to avoid assigning a vtable pointer at
- // the top of the base class's ctor and dtor. So the vtable itself
- // and any methods it points to which aren't used elsewhere can be
- // omitted by the linker and reduce overall space.
- //
- // Make sure though that the base class is never instantiated. Making
- // the ctor protected or using pure virtual methods can help with this.
- //
- #if defined(_MSC_VER)
- #define ADESK_NO_VTABLE __declspec(novtable)
- #define ADESK_STDCALL __stdcall
- #define ADESK_DEPRECATED __declspec(deprecated)
- #define ADESK_DEPRECATED_MSG(MSG) __declspec(deprecated(MSG))
- #define ADESK_DATA_IMPORT __declspec(dllimport)
- #else
- #define ADESK_NO_VTABLE
- // The GCC 4.0 compiler doesn't seem to support the stdcall attribute
- // for 64-bit builds. If we use it, we just get a ton of warnings
- // from the compiler mentioning that it isn't supported.
- #if defined(__LP64__) || defined(_ADESK_IOS_)
- #define ADESK_STDCALL
- #else
- #define ADESK_STDCALL __attribute__((stdcall))
- #endif // __LP64__
-
- #define ADESK_DEPRECATED __attribute__((__deprecated__))
- #define ADESK_DEPRECATED_MSG(MSG) __attribute__((__deprecated__))
- #define ADESK_DATA_IMPORT extern
- // Redefine __declspec(method) for gcc
- #define __declspec(method) __declspec_##method
- #define _declspec(method) __declspec_##method
- #define __declspec_selectany __attribute__ ((__weak__))
- #define __declspec_dllexport __attribute__ ((__visibility__("default")))
- #define __declspec_dllimport
- #define __declspec_noinline __attribute__ ((__noinline__))
- #define __declspec_noreturn __attribute__ ((__noreturn__))
- #define __declspec_deprecated __attribute__ ((__deprecated__))
- #define __declspec_novtable
- #define __declspec_allocate(name) __attribute__ ((section("__DATA," name)))
- #endif //_MSC_VER
- #ifdef _MSC_EXTENSIONS
- #define ADESK_OVERRIDE override
- #if defined(_MSC_VER) && (_MSC_VER <= 1600) //VS2010 and earlier
- #define ADESK_SEALED sealed
- #else
- #define ADESK_SEALED final
- #endif
- #else //_MSC_EXTENSIONS
- #define ADESK_OVERRIDE
- #define ADESK_SEALED
- #endif //_MSC_EXTENSIONS
- #define MIGRATION_ERRORS
- #if defined(_MSC_VER) && defined (MIGRATION_ERRORS)
- #define ADESK_SEALED_VIRTUAL virtual
- #if !defined(ADESK_SEALED)
- #define ADESK_SEALED sealed
- #endif //ADESK_SEALED
- #else //MIGRATION_ERRORS
- #define ADESK_SEALED_VIRTUAL
- #define ADESK_SEALED
- #endif //MIGRATION_ERRORS
- //
- // Compiler indentification
- //
- #if defined(__INTEL_COMPILER) || defined (_MSC_VER)
- #define ADESK_FORCE_INLINE __forceinline
- #else //__INTEL_COMPILER || _MSC_VER
- #define ADESK_FORCE_INLINE inline
- #endif //__INTEL_COMPILER || _MSC_VER
- #ifdef _ADESK_WINDOWS_
- #define VA_ARG_WCHAR(ap, t) va_arg(ap, wchar_t)
- #else
- #define VA_ARG_WCHAR(ap, t) va_arg(ap, int)
- #endif
- #ifdef _ADESK_UNITTEST_
- #ifdef ADESK_SEALED
- #undef ADESK_SEALED
- #endif
- #define ADESK_SEALED
- #endif
- #endif //_ADESK_H
|