blob: 66d1a0c86ad23fa4d4d2d45e7e4b170cb309545f [file] [log] [blame]
Christopher Piro094823a2007-07-18 00:26:12 +00001%%% Copyright (c) 2007- Facebook
2%%% Distributed under the Thrift Software License
Christopher Pirode11d852007-11-18 02:10:20 +00003%%%
Christopher Piro094823a2007-07-18 00:26:12 +00004%%% 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 Piro93a06642007-09-18 06:23:33 +00009-define(DEFINE_ATTR(Attr), attr(This, get, Attr, _Value) -> This#?MODULE.Attr;
Christopher Piro094823a2007-07-18 00:26:12 +000010 attr(This, set, Attr, Value) -> This#?MODULE{Attr=Value}
11).
Christopher Piro93a06642007-09-18 06:23:33 +000012
Christopher Piro094823a2007-07-18 00:26:12 +000013%%% 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 Piro93a06642007-09-18 06:23:33 +000018-define(FORMAT_ATTR(Attr),
Christopher Pirode11d852007-11-18 02:10:20 +000019 io_lib:write_atom(Attr) ++ "=" ++ io_lib:print(?ATTR(Attr))
Christopher Piro094823a2007-07-18 00:26:12 +000020).
21
Christopher Pirode11d852007-11-18 02:10:20 +000022-define(ATTR_DUMMY,
23 attr(dummy, dummy, dummy, dummy) ->
24 exit(dummy_attr_used)
Christopher Piro094823a2007-07-18 00:26:12 +000025).