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

18
LINES

< > BotCompany Repo | #1033797 // Tok_GettableFields

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

Transpiled version (6230L) is out of date.

sclass Tok_GettableFields > Tok_SettableOrGettableFields {
  // causes problems because non-static inner classes cannot have
  // static functions
  settable bool addStaticFieldGetters = false;

  *() { super("gettable"); }
  
  S replacement() {
    ret tok_formatDollarVars(
      "$fMod $type $var aka $getVar() { ret $var; }\n" +
      (!addStaticFieldGetters ? "" : "static public Field $metaField() { ret findFieldOfClass(selfType.class, $quoted); }\n") +
      "$modifiers $type",
      metaField := "f_"  + var, quoted := quoted(var),
      fMod := joinWithSpace(functionModifiers()) + " public",
      modifiers := joinWithSpace(modifiers),
      +type, +var, getVar := "get" + firstToUpper(var));
  }
}

Author comment

Began life as a copy of #1033794

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033797
Snippet name: Tok_GettableFields
Eternal ID of this version: #1033797/12
Text MD5: aa83477fa4c2c5150f8c740f3412d7db
Author: stefan
Category: javax / transpiling
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-08 04:47:32
Source code size: 729 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 143 / 257
Version history: 11 change(s)
Referenced in: [show references]