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

27
LINES

< > BotCompany Repo | #1015824 // #Modules With Update Function [Dyn Module]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (7232L/47K).

!7

static SimpleLiveValue<S> output = new(S);
static Map<Class, Bool> hasUpdateMethod = weakHashMap();
static Method baseMethod;

static JComponent visualize() {
  ret centerLabel(makeBold(setFontSize(40, jLiveValueLabel(output))));
}

p {
  baseMethod = findInstanceMethod(getClass(creator(), 'main$Module), 'update);
}

svoid update {
  L modules = cast call(creator(), 'onModules);
  int count = 0;
  for (O m : modules) {
    Class c = m.getClass();
    Bool hasUpdate = hasUpdateMethod.get(c);
    if (hasUpdate == null)
      hasUpdateMethod.put(c,
        hasUpdate = findMethod(m, 'update) != baseMethod);
    if (hasUpdate) ++count;
  }
  output.set(str(count));
}

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: #1015824
Snippet name: #Modules With Update Function [Dyn Module]
Eternal ID of this version: #1015824/4
Text MD5: b74e4afd70cefa230cf71cb5cbaf8b95
Transpilation MD5: 2d21117f778ad0bfca0e754f9f9a407a
Author: stefan
Category:
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-28 04:05:27
Source code size: 674 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 495 / 1256
Version history: 3 change(s)
Referenced in: [show references]