Skip to content

Commit

Permalink
⚰️ Remove async_function macro
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEEs committed Apr 28, 2021
1 parent ff857a7 commit 0e88eb8
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/components/web_extension.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
# 5. `JSObjectUtils`
module WebExtension
annotation JSCInstanceMethod; end
# See `JSCInstanceMethod`.
annotation Chainable; end
@@uuid = ""

Expand Down Expand Up @@ -100,12 +101,6 @@ module WebExtension
}
end

macro async_function(arg_name)
JSCFunction.new ->({{arg_name}} : Array(JSCPrimative | JSCFunction | JSCObject)) {
{{ yield }}
}
end

# JavaScript `undefined`
macro undefined
JSCPrimative.new
Expand Down Expand Up @@ -157,6 +152,29 @@ module WebExtension
end
end

#Exposes a Crystal's Class so it can be used in JavaScript
#
# * webextension.cr:
# ```crystal
# class File
# def initialize(p : [] of (JSCFunction | JSCObject | JSCPrimative))
# super(p.first.to_s)
# end
#
# @[JSCInstanceMethod]
# def content(p)
# self.seek(0)
# self.gets_to_end
# end
# end
# JSCContext.set_value "File", WebExtension.register_class(File)
#
# ```
# * index.js
# ```js
# var content = new File("./LICENSE").content();
# ```
# See more at `JSCInstanceMethod`.
macro register_class(type)
%kclass = JSC.jsc_register_class(
JSCContext.global_context,
Expand Down

0 comments on commit 0e88eb8

Please sign in to comment.