Wren::Class
Mixin that when included in a class, adds macros for defining foreign and native Wren methods attached to the class
class MyClass
include Wren::Class
foreign_def self.method1 do
"response1"
end
native_def self.method2 do
<<-WREN
"response2"
WREN
end
end
Constants
WREN_METHODS = [] of Wren::Method
Instance methods
instance_handle
SourceMacros
foreign_def(name, &block)
Define a method in foreign Crystal code, callable from either Wren or Crystal. Does not support foreign constructs
class MyClass
include Wren::Class
foreign_def self.my_method do |arg1|
case arg1
when String
"foo " + arg1
end
end
end
MyClass.my_method("bar") # => "foo bar"
native_def(name, *args, construct = false, &code)
Define a method in native Wren code, callable from either Wren or Crystal. Cannot be modified at runtime.
class MyClass
include Wren::Class
native_def self.my_method, arg1, <<-WREN
return "foo " + arg1
WREN
end
MyClass.my_method("bar") # => "foo bar"