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

28
LINES

< > BotCompany Repo | #1024896 // tok_qFunctions - "q {" for running function in module queue

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

Libraryless. Click here for Pure Java version (3829L/22K).

svoid tok_qFunctions(LS tok) {
  tok_qFunctions(tok, "q", "dm_q");
  tok_qFunctions(tok, "runInQAndWait", "dm_runInQAndWait");
}

svoid tok_qFunctions(LS tok, S keyword, S function) {
  int i;
  while ((i = jfind_check(keyword, tok, "void <id> " + keyword + " {")) >= 0) {
    int bracket = findCodeTokens(tok, i, false, "{");
    int j = findEndOfBracketPart(tok, bracket);
    clearTokens(tok, i+4, i+6);
    tok.set(bracket, "{ " + function + "(module(), r {");
    tok.set(j-1, "}); }");
    reTok(tok, i+4, j);
  }
  
  while ((i = jfind_check(keyword, tok, ") " + keyword + " {")) >= 0) {
    int opening = findBeginningOfBracketPart(tok, i);
    S fname = assertIdentifier(get(tok, opening-2));
    int bracket = findCodeTokens(tok, i, false, "{");
    int j = findEndOfBracketPart(tok, bracket);
    clearTokens(tok, i+2, i+4);
    tok.set(bracket, "{ " + function + "(module(), r {");
    tok.set(j-1, "}); }");
    reTok(tok, i+4, j);
    tok_makeArgumentsFinal(tok, opening, i);
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024896
Snippet name: tok_qFunctions - "q {" for running function in module queue
Eternal ID of this version: #1024896/4
Text MD5: 0cf9ea9abb8f1fee195d4f4aeabd2102
Transpilation MD5: 50c53266e07db8f877406341437506e4
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-07-24 02:25:35
Source code size: 1024 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 245 / 358
Version history: 3 change(s)
Referenced in: [show references]