Created
October 24, 2017 15:03
-
-
Save dumganhar/90b2e706d8c98625de9217a76105d903 to your computer and use it in GitHub Desktop.
registerNativeRef.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jsb.__obj_ref_id = 0; | |
jsb.registerNativeRef = function (owner, target) { | |
if (owner && target && owner !== target) { | |
var targetID = target.__jsb_ref_id; | |
if (!targetID) | |
targetID = target.__jsb_ref_id = jsb.__obj_ref_id++; | |
var refs = owner.__nativeRefs; | |
if (!refs) { | |
refs = owner.__nativeRefs = {}; | |
} | |
if (!refs[targetID]) { | |
refs[targetID] = target; | |
} | |
} | |
}; | |
jsb.unregisterNativeRef = function (owner, target) { | |
if (owner && target && owner !== target) { | |
var targetID = target.__jsb_ref_id; | |
if (!targetID) | |
targetID = target.__jsb_ref_id = jsb.__obj_ref_id++; | |
var refs = owner.__nativeRefs; | |
if (!refs) { | |
return; | |
} | |
if (refs[targetID]) { | |
delete refs[targetID]; | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment