-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.cpp
More file actions
81 lines (66 loc) · 1.87 KB
/
db.cpp
File metadata and controls
81 lines (66 loc) · 1.87 KB
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
// Copyright © 2001 CCP ehf.
// Defines the entry point for the DLL application.
#include "StdAfx.h"
#include "Utils.h"
#include "NSession.h"
#include <Blue.h>
const char* g_moduleName = "_db";
// reduce CRT link
extern "C" void _setargv(){}
extern "C" void _setenvp(){}
//--------------------------------------------------------------------
// BlueClientStart
//--------------------------------------------------------------------
static struct PyModuleDef ModuleDef = {
PyModuleDef_HEAD_INIT,
CCP_STRINGIZE( CCP_CONCATENATE( _db, CCP_BUILD_FLAVOR ) ),
"",
-1,
NULL
};
PyObject* BlueClientStart( HINSTANCE instance )
{
CCP_LOG( "DB Lib starting" );
// Init Python related
PyObject* module = PyModule_Create( &ModuleDef );
PyObject* dict = PyModule_GetDict(module);
Utilities::InitUtilities(dict);
#define INSERT(name, object) \
if (PyDict_SetItemString(dict, name, (PyObject*)object) < 0)\
return nullptr;
INSERT("NSession", NSession::GetType());
return module;
}
static HINSTANCE gInstance = NULL;
BOOL APIENTRY DllMain(HINSTANCE instance, DWORD reason, LPVOID)
{
if (reason == DLL_PROCESS_ATTACH)
{
gInstance = instance;
BeClasses->RegisterClasses( BlueRegistration::GetClassRegs() );
}
else if (reason == DLL_PROCESS_DETACH)
{
BeClasses->UnregisterClasses( BlueRegistration::GetClassRegs() );
}
else if (reason == DLL_THREAD_ATTACH)
{
}
return TRUE;
}
//--------------------------------------------------------------------
// initdb - python dll module entry function
//--------------------------------------------------------------------
extern "C" __declspec( dllexport ) PyObject*
CCP_CONCATENATE( PyInit__db, CCP_BUILD_FLAVOR )()
{
auto* context = GetTaskletBlockingRequestContext();
if( !context->Init() )
{
return nullptr;
}
// Init Blue related
PyObject* module = BlueClientStart( gInstance );
CoInitialize(0);
return module;
}