OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
global.cpp
Go to the documentation of this file.
1
//----------------------------------------------------------------------------
2
// ObjectWindows
3
// Copyright (c) 1991, 1996 by Borland International, All Rights Reserved
4
//
5
/// \file
6
/// Global data required for every module using OWL
7
//----------------------------------------------------------------------------
8
9
#if defined(__BORLANDC__)
10
# pragma option -w-ccc
// Disable "Condition is always true/false"
11
# pragma option -w-inl
// Disable warning "Functions containing 'statement' is not expanded inline".
12
#endif
13
14
#include <
owl/pch.h
>
15
16
#include <
owl/applicat.h
>
17
18
#if defined(_MSC_VER)
19
#include <
owl/private/defs.h
>
20
#include <
owl/module.h
>
21
#endif
22
23
namespace
owl
{
24
25
OWL_DIAGINFO
;
26
DIAG_DEFINE_GROUP_INIT
(
OWL_INI
,
OwlMain
,
true
, 0);
27
28
class
_OWLCLASS
TDocTemplate
;
29
30
//
31
// Global module pointer representing this executable instance
32
// provides the default instance for resources contructed within this module
33
//
34
TModule
*
Module
= 0;
// Global Module ptr in each DLL/EXE
35
36
void
InitGlobalModule
(HINSTANCE hInstance)
37
{
38
if
(
Module
== NULL)
39
{
40
tchar
buffer[
_MAX_PATH
];
41
GetModuleFileName(hInstance, buffer,
_MAX_PATH
);
42
static
TModule
module(buffer, hInstance);
43
Module
= &
module
;
44
TRACEX
(
OwlMain
, 0,
"Global Module "
<< hInstance <<
", "
<< buffer <<
" created"
);
45
}
46
}
47
48
TModule
&
GetGlobalModule
()
49
{
50
if
(
Module
== NULL)
51
{
52
HINSTANCE hInstance = ::GetModuleHandle(NULL);
53
InitGlobalModule
(hInstance);
54
}
55
56
return
*
Module
;
57
}
58
59
}
// OWL namespace
60
61
using namespace
owl
;
62
63
//
64
// Document templates contructed before doc manager get linked in here
65
//
66
owl::TDocTemplate
*
DocTemplateStaticHead
= 0;
// initialize to no templates
67
68
//
69
// This mask deems when certain features are available.
70
// See GetDocTemplateHead and GetModulePtr below.
71
//
72
const
uint32
CompatibleVersionMask
= 0xFFF00000;
73
74
//
75
// Exported access to global variables for DLLs that use OWL
76
//
77
78
#if defined(BI_COMP_BORLANDC)
79
80
extern
"C"
{
81
TDocTemplate
** PASCAL
__declspec
(dllexport) GetDocTemplateHead(
uint32
version)
82
{
83
return
(version&
CompatibleVersionMask
) == (
OWLGetVersion
()&
CompatibleVersionMask
) ? &
DocTemplateStaticHead
:
nullptr
;
84
}
85
TModule
** PASCAL
__declspec
(dllexport)
86
GetModulePtr(
uint32
version)
87
{
88
return
(version&
CompatibleVersionMask
) == (
OWLGetVersion
()&
CompatibleVersionMask
) ? &
owl::Module
:
nullptr
;
89
}
90
}
91
92
#elif defined(BI_COMP_GNUC)
93
94
extern
"C"
{
95
__declspec
(dllexport)
TDocTemplate
** PASCAL GetDocTemplateHead(
uint32
version)
96
{
97
return
(version&
CompatibleVersionMask
) == (
OWLGetVersion
()&
CompatibleVersionMask
) ? &
DocTemplateStaticHead
: nullptr;
98
}
99
__declspec
(dllexport)
TModule
** PASCAL
100
GetModulePtr(
uint32
version)
101
{
102
return
(version&
CompatibleVersionMask
) == (
OWLGetVersion
()&
CompatibleVersionMask
) ? &
owl::Module
: nullptr;
103
}
104
}
105
106
#else
107
108
// EMF __export removed because it isn't needed in win32
109
/*__export*/
STDAPI_
(
TDocTemplate
**) GetDocTemplateHead(
uint32
version)
110
{
111
return
(version&
CompatibleVersionMask
) == (
OWLGetVersion
()&
CompatibleVersionMask
) ? &
DocTemplateStaticHead
:
nullptr
;
112
}
113
114
/*__export*/
STDAPI_
(
TModule
**) GetModulePtr(
uint32
version)
115
{
116
return
(version&
CompatibleVersionMask
) == (
OWLGetVersion
()&
CompatibleVersionMask
) ? &
owl::Module
:
nullptr
;
117
}
118
119
#endif
120
121
/* ========================================================================== */
122
applicat.h
Definition of class TApplication.
TRACEX
#define TRACEX(group, level, message)
Definition
checks.h:263
owl::TDocTemplate
TDocTemplate is an abstract base class that contains document template functionality.
Definition
doctpl.h:54
owl::TModule
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition
module.h:78
_MAX_PATH
#define _MAX_PATH
Definition
cygwin.h:97
DocTemplateStaticHead
owl::TDocTemplate * DocTemplateStaticHead
Templates constructed before app get linked onto this head pointer.
Definition
global.cpp:66
CompatibleVersionMask
const uint32 CompatibleVersionMask
Definition
global.cpp:72
STDAPI_
STDAPI_(TDocTemplate **) GetDocTemplateHead(uint32 version)
Definition
global.cpp:109
pch.h
module.h
Definition of class TModule.
OwlMain
STDAPI_(owl::TDocTemplate **) GetDocTemplateHead(owl STDAPI_(owl::TModule **) GetModulePtr(owl int OwlMain(int argc, TCHAR *argv[])
Main entry point for an Owl application.
Definition
module.h:394
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
owl::uint32
unsigned long uint32
Definition
number.h:34
owl::tchar
char tchar
Definition
defs.h:77
owl::Module
TModule * Module
Definition
global.cpp:34
owl::OWL_DIAGINFO
OWL_DIAGINFO
Definition
animctrl.cpp:14
owl::InitGlobalModule
void InitGlobalModule(HINSTANCE hInstance)
Definition
global.cpp:36
owl::GetGlobalModule
TModule & GetGlobalModule()
Definition
global.cpp:48
owl::DIAG_DEFINE_GROUP_INIT
DIAG_DEFINE_GROUP_INIT(OWL_INI, OwlApp, 1, 0)
owl::OWLGetVersion
uint32 OWLGetVersion()
Get version of OWL at runtime.
Definition
owl.cpp:43
__declspec
STDAPI __declspec(dllexport) DllRegisterCommand(LPCTSTR cmdLine)
Entry point for complete registration management via command line Don't let any exceptions blow back ...
Definition
ocreg.cpp:495
OWL_INI
#define OWL_INI
Definition
defs.h:170
defs.h
_OWLCLASS
#define _OWLCLASS
Definition
defs.h:338
source
owlcore
global.cpp
Generated by
1.18.0