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

19
LINES

< > BotCompany Repo | #1004749 // exposeMethods

JavaX fragment (include)

static S exposeMethods(S s, L<S> methodNames) {
  ret exposeMethods(s, toStringArray(methodNames)); // TODO: optimize
}

static S exposeMethods(S s, S... methodNames) {
  new Matches m;
  if "call *" {
    L l;
    if (isIdentifier(m.unq(0)))
      l = ll(m.unq(0));
    else
      l = (L) unstructure(m.unq(0)); // we used to have safeUnstructure here
    S method = getString(l, 0);
    if (!contains(methodNames, method))
      fail("Method not allowed: " + method);
    ret ok2(structure(call(mc(), method, asObjectArray(subList(l, 1)))));
  }
  null;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1004749
Snippet name: exposeMethods
Eternal ID of this version: #1004749/2
Text MD5: b9e0820cfbf7d8b885f9710c4e129e31
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-24 16:52:13
Source code size: 575 bytes / 19 lines
Pitched / IR pitched: No / No
Views / Downloads: 562 / 575
Version history: 1 change(s)
Referenced in: #1005744 - exposeMethods2 - expose methods of an object. only for trusted clients because of unstructure
#1006654 - Standard functions list 2 (LIVE, continuation of #761)