doom3-gpl
Doom 3 GPL source release
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
neo
openal
idal.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# create win32 source for OpenAL on-demand loading from AL API definitions
3
# a set of defines al* -> idal*
4
# typedefs and code pointer functions definition
5
6
# 1: get linking with no OpenAL DLL link in anymore
7
# i.e. have the defines and the code pointer working
8
# 2: do the load code
9
10
import
time
11
12
funcs = [
13
[
'ALenum'
,
'alGetError'
,
'ALvoid'
],
14
[
'ALvoid'
,
'alGenBuffers'
,
'ALsizei'
,
'ALuint *'
],
15
[
'ALboolean'
,
'alIsSource'
,
'ALuint'
],
16
[
'ALvoid'
,
'alSourceStop'
,
'ALuint'
],
17
[
'ALvoid'
,
'alGetSourcei'
,
'ALuint'
,
'ALenum'
,
'ALint *'
],
18
[
'ALint'
,
'alGetInteger'
,
'ALenum'
],
19
[
'ALCvoid'
,
'alcSuspendContext'
,
'ALCcontext *'
],
20
[
'ALCboolean'
,
'alcMakeContextCurrent'
,
'ALCcontext *'
],
21
[
'ALCvoid'
,
'alcProcessContext'
,
'ALCcontext *'
],
22
[
'ALCvoid'
,
'alcDestroyContext'
,
'ALCcontext *'
],
23
[
'ALCubyte *'
,
'alcGetString'
,
'ALCdevice *'
,
'ALCenum'
],
24
[
'ALvoid'
,
'alBufferData'
,
'ALuint'
,
'ALenum'
,
'ALvoid *'
,
'ALsizei'
,
'ALsizei'
],
25
[
'ALvoid'
,
'alDeleteBuffers'
,
'ALsizei'
,
'ALuint *'
],
26
[
'ALboolean'
,
'alIsExtensionPresent'
,
'ALubyte *'
],
27
[
'ALvoid'
,
'alDeleteSources'
,
'ALsizei'
,
'ALuint *'
],
28
[
'ALenum'
,
'alGetEnumValue'
,
'ALubyte *'
],
29
[
'ALvoid *'
,
'alGetProcAddress'
,
'ALubyte *'
],
30
[
'ALCcontext *'
,
'alcCreateContext'
,
'ALCdevice *'
,
'ALCint *'
],
31
[
'ALCdevice *'
,
'alcOpenDevice'
,
'ALubyte *'
],
32
[
'ALvoid'
,
'alListenerfv'
,
'ALenum'
,
'ALfloat*'
],
33
[
'ALvoid'
,
'alSourceQueueBuffers'
,
'ALuint'
,
'ALsizei'
,
'ALuint *'
],
34
[
'ALvoid'
,
'alSourcei'
,
'ALuint'
,
'ALenum'
,
'ALint'
],
35
[
'ALvoid'
,
'alListenerf'
,
'ALenum'
,
'ALfloat'
],
36
[
'ALCvoid'
,
'alcCloseDevice'
,
'ALCdevice *'
],
37
[
'ALboolean'
,
'alIsBuffer'
,
'ALuint'
],
38
[
'ALvoid'
,
'alSource3f'
,
'ALuint'
,
'ALenum'
,
'ALfloat'
,
'ALfloat'
,
'ALfloat'
],
39
[
'ALvoid'
,
'alGenSources'
,
'ALsizei'
,
'ALuint *'
],
40
[
'ALvoid'
,
'alSourcef'
,
'ALuint'
,
'ALenum'
,
'ALfloat'
],
41
[
'ALvoid'
,
'alSourceUnqueueBuffers'
,
'ALuint'
,
'ALsizei'
,
'ALuint *'
],
42
[
'ALvoid'
,
'alSourcePlay'
,
'ALuint'
],
43
]
44
45
def
warningHeader
( f ):
46
f.write(
'// generated header. do not edit\n'
)
47
f.write(
'// '
+ __file__ +
'\n'
)
48
f.write(
'// '
+ time.asctime() +
'\n\n'
)
49
50
def
genIDALFunc
( f, declare ):
51
if
( declare ):
52
extern =
'extern '
53
else
:
54
extern =
''
55
for
func
in
funcs:
56
f.write( extern + func[0] +
' ( ALAPIENTRY * id'
+ func[1] +
' )( '
)
57
i = 2
58
while
( i < len( func ) ):
59
if
( i != 2 ):
60
f.write(
', '
)
61
f.write( func[i] )
62
i += 1
63
if
( declare ):
64
f.write(
' );\n'
)
65
else
:
66
f.write(
' ) = NULL;\n'
)
67
68
def
genDefineMapping
( f ):
69
for
func
in
funcs:
70
fname = func[1]
71
f.write(
'#define %s id%s\n'
% ( fname, fname ) )
72
73
def
genIDALInit
( f ):
74
for
func
in
funcs:
75
# annoying casting
76
cast = func[0] +
' ( ALAPIENTRY * ) ( '
77
i = 2
78
while
( i < len( func ) ):
79
if
( i != 2 ):
80
cast +=
', '
81
cast += func[i]
82
i += 1
83
cast +=
' )'
84
# function
85
f.write(
'id'
+ func[1] +
' = ( '
+ cast +
' )GetProcAddress( h, "'
+ func[1] +
'" );\n'
)
86
f.write(
'if ( !id'
+ func[1] +
') {\n return "'
+ func[1] +
'";\n}\n'
)
87
88
if
__name__ ==
'__main__'
:
89
f = open(
'idal.h'
,
'w'
)
90
warningHeader
( f )
91
genIDALFunc
( f,
True
)
92
f.write(
'\n'
)
93
genDefineMapping
( f )
94
f.close()
95
f = open(
'idal.cpp'
,
'w'
)
96
warningHeader
( f )
97
genIDALFunc
( f,
False
)
98
f.write(
'\n'
);
99
f.write(
'const char* InitializeIDAL( HMODULE h ) {\n'
)
100
genIDALInit
( f )
101
f.write(
'return NULL;\n'
);
102
f.write(
'};\n'
)
103
f.close()
idal.genDefineMapping
def genDefineMapping
Definition:
idal.py:68
idal.warningHeader
def warningHeader
Definition:
idal.py:45
idal.genIDALFunc
def genIDALFunc
Definition:
idal.py:50
idal.genIDALInit
def genIDALInit
Definition:
idal.py:73
This page is maintained by
Wladimir van der Laan
. Generated on Mon Nov 17 2014 12:23:24 for doom3-gpl by
1.8.6
.