summaryrefslogtreecommitdiff
path: root/src/binder/inc/bindertypes.hpp
blob: 7d7e822871f8b8f2999ba9f5b2d8efdfd2f33e43 (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
// ============================================================
//
// BinderTypes.hpp
//


//
// Declares a bunch of binder classes, types and macros
//
// ============================================================

#ifndef __BINDER_TYPES_HPP__
#define __BINDER_TYPES_HPP__

#include "clrtypes.h"
#include "sstring.h"

#include "fusionhelpers.hpp"

extern void DECLSPEC_NORETURN ThrowOutOfMemory();

#ifndef S_TRUE
#define S_TRUE S_OK
#endif

class PEImage;
class PEAssembly;

namespace BINDER_SPACE
{
    class AssemblyVersion;
    class AssemblyName;
    class Assembly;
    
    class GACEntry;
    class GACVersionIterator;
    class GAC;

    class ContextEntry;
    class ExecutionContext;
    class InspectionContext;

    class PropertyMap;
    class ApplicationContext;

    class BindResult;
    class FailureCache;
    class AssemblyBinder;

#if defined(BINDER_DEBUG_LOG)
    class DebugLog;
#endif

#if defined(FEATURE_VERSIONING_LOG)
    class BindingLog;
    class CDebugLog;
#endif // FEATURE_VERSIONING_LOG

    namespace Tests
    {
        HRESULT Run();
    };
};

#define IF_FAIL_GO(expr)                        \
    hr = (expr);                                \
    if (FAILED(hr))                             \
    {                                           \
        goto Exit;                              \
    }

#define IF_FALSE_GO(expr)                       \
   if (!(expr)) {                               \
       hr = E_FAIL;                             \
       goto Exit;                               \
   }

#define GO_WITH_HRESULT(hrValue)                \
   hr = hrValue;                                \
   goto Exit;

#define IF_WIN32_ERROR_GO(expr)                 \
   if (!(expr))                                 \
   {                                            \
       hr = HRESULT_FROM_GetLastError();        \
       goto Exit;                               \
   }

#define NEW_CONSTR(Object, Constr)              \
    (Object) = new (nothrow) Constr;

#define SAFE_NEW_CONSTR(Object, Constr)         \
    (Object) = new (nothrow) Constr;            \
    if ((Object) == NULL)                       \
    {                                           \
        hr = E_OUTOFMEMORY;                     \
        goto Exit;                              \
    }

#define SAFE_NEW(Object, Class)                 \
    SAFE_NEW_CONSTR(Object, Class());

#define SAFE_RELEASE(objectPtr)                 \
    if ((objectPtr) != NULL)                    \
    {                                           \
        (objectPtr)->Release();                 \
        (objectPtr) = NULL;                     \
    }

#define SAFE_DELETE(objectPtr)                  \
    if ((objectPtr) != NULL)                    \
    {                                           \
        delete (objectPtr);                     \
        (objectPtr) = NULL;                     \
    }

#define SAFE_DELETE_ARRAY(objectPtr)            \
    if ((objectPtr) != NULL)                    \
    {                                           \
        delete[] (objectPtr);                   \
        (objectPtr) = NULL;                     \
    }

#define LENGTH_OF(x)                            \
    (sizeof(x) / sizeof(x[0]))

#include "debuglog.hpp"

#endif