Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

21
LINES

< > BotCompany Repo | #1010614 // mountObjectOnObject

JavaX fragment (include)

// returns previous mounted
static O mountObjectOnObject(O mounter, O mounted, O key) {
  if (mounted == null) null;
  Map generalMap = vm_generalMap();
  if (generalMap == null) fail("Please upgrade JavaX");
  synchronized(generalMap) {
    Map map = cast generalMap.get("mounts");
    if (map == null) {
      pcall-short {
        map = (Map) nuForeignObject(javax(), className(javax()) + '$WeakIdentityHashMap);
      }
      if (map == null) map = new WeakIdentityHashMap; // older JavaX
      generalMap.put("mounts", map);
    }
    Map m = cast map.get(mounted);
    if (m == null)
      map.put(mounted, m = new HashMap);
      
    ret m.put(key, mounter);
  }
}

Author comment

Began life as a copy of #1010611

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1010614
Snippet name: mountObjectOnObject
Eternal ID of this version: #1010614/3
Text MD5: 5040595e08da33df394a4c9ddb64a22d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-23 05:20:03
Source code size: 692 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 454 / 477
Version history: 2 change(s)
Referenced in: [show references]