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

15
LINES

< > BotCompany Repo | #1025861 - tok_timedCachedFunctions - use class TimedCache (single object cache)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2792L/18K).

static void tok_timedCachedFunctions(LS tok) { pcall {
  int i;
  while ((i = jfind(tok, "static timedCached[*.*] <id>")) >= 0) {
    int bracket1 = indexOf(tok, "]", i);
    S time = joinSubList(tok, i+6, bracket1-1);
    int bracket = indexOf(tok, "(", bracket1);
    S fName = assertIdentifier(tok.get(bracket-2));
    S type = joinSubList(tok, bracket1+2, bracket-3);
    S boxedType = tok_toNonPrimitiveTypes(type);
    
    replaceTokens(tok, i, bracket-1, "static TimedCache<\*boxedType*/> \*fName*/_cache = new TimedCache(\*time*/, f \*fName*/_load);\n"
      + "static \*type*/ \*fName*/() { ret \*fName*/_cache!; }\n\n" + "static \*boxedType*/ \*fName*/_load");
    reTok(tok, i, bracket-3);
  }
}}

Author comment

Began life as a copy of #1010513

download  show line numbers  debug dex   

Travelled to 2 computer(s): mqqgnosmbjvj, tvejysmllsmz

No comments. add comment

Snippet ID: #1025861
Snippet name: tok_timedCachedFunctions - use class TimedCache (single object cache)
Eternal ID of this version: #1025861/4
Text MD5: 29dc896bb36ccfab9dd527d3dbeb3164
Transpilation MD5: 4862d17f6f19fea5303cef93dd255c6b
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-10-27 16:16:50
Source code size: 722 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 14 / 49
Version history: 3 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1025861 & http://1025861.tinybrain.de