Skip to content

Instantly share code, notes, and snippets.

@shannah
Created July 28, 2014 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shannah/dbdc271568487d998b94 to your computer and use it in GitHub Desktop.
Save shannah/dbdc271568487d998b94 to your computer and use it in GitHub Desktop.
Mirah macros for private and protected methods
class MirahClass
macro def self.protected(mthd:MethodDefinition)
anno = Annotation.new(@call.name.position, Constant.new(SimpleString.new('org.mirah.jvm.types.Modifiers')),
[HashEntry.new(SimpleString.new('access'), SimpleString.new('PROTECTED'))])
mthd.annotations.add(anno)
mthd.setParent(nil)
mthd
end
macro def self.private(mthd:MethodDefinition)
anno = Annotation.new(@call.name.position, Constant.new(SimpleString.new('org.mirah.jvm.types.Modifiers')),
[HashEntry.new(SimpleString.new('access'), SimpleString.new('PRIVATE'))])
mthd.annotations.add(anno)
mthd.setParent(nil)
mthd
end
macro def self.package_private(mthd:MethodDefinition)
anno = Annotation.new(@call.name.position, Constant.new(SimpleString.new('org.mirah.jvm.types.Modifiers')),
[HashEntry.new(SimpleString.new('access'), SimpleString.new('DEFAULT'))])
mthd.annotations.add(anno)
mthd.setParent(nil)
mthd
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment