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

21
LINES

< > BotCompany Repo | #1010614 // mountObjectOnObject

JavaX fragment (include)

1  
// returns previous mounted
2  
static O mountObjectOnObject(O mounter, O mounted, O key) {
3  
  if (mounted == null) null;
4  
  Map generalMap = vm_generalMap();
5  
  if (generalMap == null) fail("Please upgrade JavaX");
6  
  synchronized(generalMap) {
7  
    Map map = cast generalMap.get("mounts");
8  
    if (map == null) {
9  
      pcall-short {
10  
        map = (Map) nuForeignObject(javax(), className(javax()) + '$WeakIdentityHashMap);
11  
      }
12  
      if (map == null) map = new WeakIdentityHashMap; // older JavaX
13  
      generalMap.put("mounts", map);
14  
    }
15  
    Map m = cast map.get(mounted);
16  
    if (m == null)
17  
      map.put(mounted, m = new HashMap);
18  
      
19  
    ret m.put(key, mounter);
20  
  }
21  
}

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: 455 / 478
Version history: 2 change(s)
Referenced in: [show references]