Christopher Piro | 094823a | 2007-07-18 00:26:12 +0000 | [diff] [blame] | 1 | %%% Copyright (c) 2007- Facebook |
| 2 | %%% Distributed under the Thrift Software License |
Christopher Piro | de11d85 | 2007-11-18 02:10:20 +0000 | [diff] [blame] | 3 | %%% |
Christopher Piro | 094823a | 2007-07-18 00:26:12 +0000 | [diff] [blame] | 4 | %%% See accompanying file LICENSE or visit the Thrift site at: |
| 5 | %%% http://developers.facebook.com/thrift/ |
| 6 | |
| 7 | -define(CLASS(Obj), element(1, Obj)). |
| 8 | |
Christopher Piro | 93a0664 | 2007-09-18 06:23:33 +0000 | [diff] [blame] | 9 | -define(DEFINE_ATTR(Attr), attr(This, get, Attr, _Value) -> This#?MODULE.Attr; |
Christopher Piro | 094823a | 2007-07-18 00:26:12 +0000 | [diff] [blame] | 10 | attr(This, set, Attr, Value) -> This#?MODULE{Attr=Value} |
| 11 | ). |
Christopher Piro | 93a0664 | 2007-09-18 06:23:33 +0000 | [diff] [blame] | 12 | |
Christopher Piro | 094823a | 2007-07-18 00:26:12 +0000 | [diff] [blame] | 13 | %%% static: use only if you're sure This is class ?MODULE and not a super/subclass |
| 14 | -define(ATTR(Attr), This#?MODULE.Attr). |
| 15 | |
| 16 | %%% convenience for implementing inspect/1 |
| 17 | %%% e.g. -> "foo=5" |
Christopher Piro | 93a0664 | 2007-09-18 06:23:33 +0000 | [diff] [blame] | 18 | -define(FORMAT_ATTR(Attr), |
Christopher Piro | de11d85 | 2007-11-18 02:10:20 +0000 | [diff] [blame] | 19 | io_lib:write_atom(Attr) ++ "=" ++ io_lib:print(?ATTR(Attr)) |
Christopher Piro | 094823a | 2007-07-18 00:26:12 +0000 | [diff] [blame] | 20 | ). |
| 21 | |
Christopher Piro | de11d85 | 2007-11-18 02:10:20 +0000 | [diff] [blame] | 22 | -define(ATTR_DUMMY, |
| 23 | attr(dummy, dummy, dummy, dummy) -> |
| 24 | exit(dummy_attr_used) |
Christopher Piro | 094823a | 2007-07-18 00:26:12 +0000 | [diff] [blame] | 25 | ). |