]> git.cworth.org Git - vogl/blob - src/libbacktrace_test/mainlib.cpp
Initial vogl checkin
[vogl] / src / libbacktrace_test / mainlib.cpp
1 /**************************************************************************
2  *
3  * Copyright 2013-2014 RAD Game Tools and Valve Software
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  *
24  **************************************************************************/
25
26 /*
27  * mainlib.cpp
28  */
29 #if defined _WIN32 || defined __CYGWIN__
30   #ifdef BUILDING_DLL
31     #ifdef __GNUC__
32       #define DLL_PUBLIC __attribute__ ((dllexport))
33     #else
34       #define DLL_PUBLIC __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
35     #endif
36   #else
37     #ifdef __GNUC__
38       #define DLL_PUBLIC __attribute__ ((dllimport))
39     #else
40       #define DLL_PUBLIC __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
41     #endif
42   #endif
43   #define DLL_LOCAL
44 #else
45   #if __GNUC__ >= 4
46     #define DLL_PUBLIC __attribute__ ((visibility ("default")))
47     #define DLL_LOCAL  __attribute__ ((visibility ("hidden")))
48   #else
49     #define DLL_PUBLIC
50     #define DLL_LOCAL
51   #endif
52 #endif
53
54 typedef void (PFN)(void);
55
56 namespace nsA
57 {
58 namespace nsB
59 {
60 namespace nsC
61 {
62
63 class xxx
64 {
65 public:
66     xxx(PFN *pfn) : m_pfn(pfn), m_docall(false) {}
67     ~xxx()
68     {
69         if (m_docall)
70         {
71             foobar();
72         }
73     }
74
75     int foobar();
76
77     xxx operator+(const xxx & x);
78
79     PFN *m_pfn;
80     bool m_docall;
81 };
82
83
84 xxx xxx::operator+(const xxx & x)
85 {
86     xxx x2(m_pfn);
87
88 //    x2.foobar();
89     x2.m_docall = true;
90
91     return *this;
92 }
93
94 int xxx::foobar()
95 {
96     m_pfn();
97     return 0;
98 }
99
100 } // ns3
101 } // ns2
102 } // ns1
103
104 static int z(PFN *pfn, int a, float b)
105 {
106     nsA::nsB::nsC::xxx x(pfn);
107     nsA::nsB::nsC::xxx y(pfn);
108
109     x = x + y;
110     return 1;
111 }
112
113 DLL_PUBLIC int yyy(PFN *pfn)
114 {
115     return z(pfn, 0, 0.0f);
116 }