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

Method GetUserData

sdk/angelscript/source/as_scriptobject.cpp:518–541  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516}
517
518void *asCScriptObject::GetUserData(asPWORD type) const
519{
520 if( !extra )
521 return 0;
522
523 // There may be multiple threads reading, but when
524 // setting the user data nobody must be reading.
525 // TODO: runtime optimize: Would it be worth it to have a rwlock per object type?
526 asAcquireSharedLock();
527
528 for( asUINT n = 0; n < extra->userData.GetLength(); n += 2 )
529 {
530 if( extra->userData[n] == type )
531 {
532 void *userData = reinterpret_cast<void*>(extra->userData[n+1]);
533 asReleaseSharedLock();
534 return userData;
535 }
536 }
537
538 asReleaseSharedLock();
539
540 return 0;
541}
542
543void *asCScriptObject::SetUserData(void *data, asPWORD type)
544{

Callers

nothing calls this directly

Calls 3

asAcquireSharedLockFunction · 0.85
asReleaseSharedLockFunction · 0.85
GetLengthMethod · 0.45

Tested by

no test coverage detected