forked from elixir-desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwx.ex
More file actions
33 lines (29 loc) · 973 Bytes
/
Copy pathwx.ex
File metadata and controls
33 lines (29 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# TODO: less stringy metaprogramming
defmodule Desktop.Wx do
@moduledoc """
Elixir version of the constants found in the wx.hrl file, reduced to what is needed in this sample only.
"""
@constants ~w(
ID_ANY ID_EXIT DEFAULT_FRAME_STYLE NO_BORDER EXPAND HORIZONTAL VERTICAL
ITEM_SEPARATOR ITEM_NORMAL ITEM_CHECK ITEM_RADIO
ICON_WARNING ICON_ERROR ICON_QUESTION ICON_INFORMATION
MAJOR_VERSION MINOR_VERSION RELEASE_NUMBER IMAGE_QUALITY_HIGH )
gets =
Enum.sort(@constants)
|> Enum.map(fn const -> "get(wx#{const}) -> ?wx#{const}" end)
|> Enum.join(";\n ")
File.write!(
__DIR__ <> "/../../src/desktop_wx.erl",
"""
-module(desktop_wx).
-include_lib("wx/include/wx.hrl").
-export([get/1]).
#{gets}.
"""
)
@constants
|> Enum.map(&String.to_atom("wx" <> &1))
|> Enum.each(fn prefixed_constant ->
def unquote(prefixed_constant)(), do: :desktop_wx.get(unquote(prefixed_constant))
end)
end