-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathno_api_compat.nut
More file actions
160 lines (123 loc) · 4.25 KB
/
no_api_compat.nut
File metadata and controls
160 lines (123 loc) · 4.25 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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// generate dummy vscript api calls used in the benchmark script to run for sq.exe bytecode dumps
// DO NOT USE THIS IN-GAME, ONLY USE THIS FOR BYTECODE DUMPS
// IncludeScript( "popextensions/WIP/vscript_api_documentation" )
try { dofile( "./vscript_api_documentation.nut", true ) } catch (e) IncludeScript( "vscript_api_documentation" )
function UniqueString( suffix = "" ) {
local arr = array( 8 ).apply( @(_) 90 * rand() / RAND_MAX )
local str = "_"
foreach ( i, t in arr )
str += format( "%02x", t )
return format( "%s_%s", str, suffix )
}
function printl( msg ) { print(msg+"\n") }
::DummyEnt <- class {
name = ""
script_id = ""
scope = null
GetName = @() name
GetScriptScope = @() scope
GetScriptId = @() script_id
constructor( _name = "__benchmark_dummy" ) {
this.name = _name
this.script_id = UniqueString( _name.slice(1) )
this.scope = {
self = this
__vrefs = 1
__vname = this.script_id
}
}
}
foreach ( method in VSCRIPT_API_DOCS.ScriptFunctions.CBaseEntity.keys() )
if ( !(method in DummyEnt) )
DummyEnt[method] <- @(...) null
::Vector <- class {
x = 0.0
y = 0.0
z = 0.0
constructor( x = 0.0, y = 0.0, z = 0.0 ) {
this.x = x
this.y = y
this.z = z
}
Cross = @(...) Vector()
Scale = @(...) Vector()
Dot = @(...) 0.0
Length = @(...) 0.0
LengthSqr = @(...) 0.0
Length2D = @(...) 0.0
Length2DSqr = @(...) 0.0
Norm = @(...) 1.0
ToQuat = @(...) null
tostring = @() ToKVString()
ToKVString = @() format( "%g %g %g", x, y, z )
}
::QAngle <- Vector
local doc_to_type = {
void = null
any = null
handle = null
int = 0
bool = false
float = 0.0
string = ""
table = {}
array = []
Vector = Vector()
QAngle = QAngle()
}
foreach ( cls, methods in VSCRIPT_API_DOCS.ScriptFunctions ) {
if ( !(cls in __ROOT) )
__ROOT[cls] <- methods
foreach ( method, info in methods ) {
local return_type = strip( split( info.info, " " )[0] ).slice(1)
local return_val = null
// convert to valid squirrel type
if ( return_type in doc_to_type ) {
return_val = return_type == "table" || return_type == "array" ? clone doc_to_type[return_type] : doc_to_type[return_type]
}
// uppercase type is a class instance
else if (return_type[0] < 'a' )
return_val = null
if ( cls != "Globals" )
__ROOT[cls][method] <- @( ... ) return_val
else if ( !( method in __ROOT ) )
__ROOT[method] <- @( ... ) return_val
}
}
foreach ( cls, inst in { CEntities = "Entities", CScriptEntityOutputs = "EntityOutputs", CNavMesh = "NavMesh", CNetPropManager = "NetProps", CPlayerVoiceListener = "PlayerVoiceListener" } )
if ( cls in __ROOT )
__ROOT[inst] <- __ROOT[cls]
// class NetProps {
// GetPropInt = @(...) -1
// GetPropBool = @(...) false
// GetPropFloat = @(...) -1.0
// GetPropString = @(...) ""
// GetPropEntity = @(...) null
// GetPropVector = @(...) Vector()
// GetPropIntArray = @(...) -1
// GetPropBoolArray = @(...) false
// GetPropFloatArray = @(...) -1.0
// GetPropStringArray = @(...) ""
// GetPropEntityArray = @(...) null
// GetPropVectorArray = @(...) Vector()
// GetPropType = @(...) "null"
// GetTable = @(...) {}
// GetPropInfo = @(...) null
// GetPropArraySize = @(...) 0
// HasProp = @(...) false
// IsValid = @(...) false
// SetPropBool = @(...) null
// SetPropFloat = @(...) null
// SetPropStringArray = @(...) null
// SetPropFloatArray = @(...) null
// SetPropEntity = @(...) null
// SetPropString = @(...) null
// SetPropVectorArray = @(...) null
// SetPropInt = @(...) null
// SetPropEntityArray = @(...) null
// SetPropVector = @(...) null
// SetPropBoolArray = @(...) null
// SetPropIntArray = @(...) null
// }
// foreach ( override in overrides )
// __ROOT[override] <- @(...) null