MCPcopy Create free account
hub / github.com/anjo76/angelscript / SetUserData

Method SetUserData

sdk/angelscript/source/as_module.cpp:138–166  ·  view source on GitHub ↗

interface

Source from the content-addressed store, hash-verified

136
137// interface
138void *asCModule::SetUserData(void *data, asPWORD type)
139{
140 // As a thread might add a new new user data at the same time as another
141 // it is necessary to protect both read and write access to the userData member
142 ACQUIREEXCLUSIVE(m_engine->engineRWLock);
143
144 // It is not intended to store a lot of different types of userdata,
145 // so a more complex structure like a associative map would just have
146 // more overhead than a simple array.
147 for( asUINT n = 0; n < m_userData.GetLength(); n += 2 )
148 {
149 if( m_userData[n] == type )
150 {
151 void *oldData = reinterpret_cast<void*>(m_userData[n+1]);
152 m_userData[n+1] = reinterpret_cast<asPWORD>(data);
153
154 RELEASEEXCLUSIVE(m_engine->engineRWLock);
155
156 return oldData;
157 }
158 }
159
160 m_userData.PushLast(type);
161 m_userData.PushLast(reinterpret_cast<asPWORD>(data));
162
163 RELEASEEXCLUSIVE(m_engine->engineRWLock);
164
165 return 0;
166}
167
168// interface
169void *asCModule::GetUserData(asPWORD type) const

Callers 4

GetControllerScriptMethod · 0.45
StoreMethod · 0.45
StoreMethod · 0.45
TestExecuteFunction · 0.45

Calls 2

PushLastMethod · 0.80
GetLengthMethod · 0.45

Tested by 3

StoreMethod · 0.36
StoreMethod · 0.36
TestExecuteFunction · 0.36