Permalink
Browse files

Align UBF's predefined and builtin types with EEP 8

  • Loading branch information...
norton committed Sep 2, 2012
1 parent e61261c commit fe276dbc3fb92cb8784a87e64543d184bb9adac4
View
@@ -32,24 +32,24 @@
%%% Macros
%%%-------------------------------------------------------------------
-%% @doc ubf string helper
--define(S(X),
- #'#S'{value=X}).
-
%% @doc ubf proplist helper
-define(P(X),
#'#P'{value=X}).
+%% @doc ubf string helper
+-define(S(X),
+ #'#S'{value=X}).
+
%%%-------------------------------------------------------------------
%%% Records
%%%-------------------------------------------------------------------
-%% @doc ubf string record
--record('#S',
- {value="" :: string()}).
-
%% @doc ubf proplist record
-record('#P',
{value=[] :: [{term(),term()}]}).
+%% @doc ubf string record
+-record('#S',
+ {value="" :: string()}).
+
-endif. % -ifndef(ubf)
@@ -1,6 +1,6 @@
+NAME("irc").
-+VSN("ubf1.0").
++VSN("ubf2.0").
+STATE start
logon() => proceed() & active. %% Nick randomly assigned
@@ -18,8 +18,8 @@
EVENT => changeNameEvent(). %% Nick changes name
+ANYSTATE
- info() => string();
- description() => string();
+ info() => ubfstring();
+ description() => ubfstring();
contract() => term().
@@ -1,6 +1,6 @@
+NAME("irc").
-+VSN("ubf1.0").
++VSN("ubf2.0").
+TYPES
info() :: info;
@@ -9,10 +9,10 @@ contract() :: contract;
ok() :: ok;
bool() :: true | false;
-nick() :: string();
+nick() :: ubfstring();
oldnick() :: nick();
newnick() :: nick();
-group() :: string();
+group() :: ubfstring();
groups() :: [group()];
logon() :: logon;
@@ -21,9 +21,9 @@ listGroups() :: groups;
joinGroup() :: {join, group()};
leaveGroup() :: {leave, group()};
changeNick() :: {nick, nick()};
-msg() :: {msg, group(), string()};
+msg() :: {msg, group(), ubfstring()};
-msgEvent() :: {msg, nick(), group(), string()};
+msgEvent() :: {msg, nick(), group(), ubfstring()};
joinEvent() :: {joins, nick(), group()};
leaveEvent() :: {leaves, nick(), group()};
changeNameEvent() :: {changesName, oldnick(), newnick(), group()}.
@@ -44,8 +44,8 @@ changeNameEvent() :: {changesName, oldnick(), newnick(), group()}.
EVENT => changeNameEvent(). %% Nick changes name
+ANYSTATE
- info() => string();
- description() => string();
+ info() => ubfstring();
+ description() => ubfstring();
contract() => term().
@@ -1,6 +1,6 @@
+NAME("irc_types").
-+VSN("ubf1.0").
++VSN("ubf2.0").
+TYPES
info() :: info;
@@ -9,10 +9,10 @@ contract() :: contract;
ok() :: ok;
bool() :: true | false;
-nick() :: string();
+nick() :: ubfstring();
oldnick() :: nick();
newnick() :: nick();
-group() :: string();
+group() :: ubfstring();
groups() :: [group()];
logon() :: logon;
@@ -21,9 +21,9 @@ listGroups() :: groups;
joinGroup() :: {join, group()};
leaveGroup() :: {leave, group()};
changeNick() :: {nick, nick()};
-msg() :: {msg, group(), string()};
+msg() :: {msg, group(), ubfstring()};
-msgEvent() :: {msg, nick(), group(), string()};
+msgEvent() :: {msg, nick(), group(), ubfstring()};
joinEvent() :: {joins, nick(), group()};
leaveEvent() :: {leaves, nick(), group()};
changeNameEvent() :: {changesName, oldnick(), newnick(), group()}.
@@ -109,23 +109,23 @@ STRING = DQUOTE *(%x20-21 / %x23-7E) DQUOTE
NONEMTPYSTRING = DQUOTE 1*(%x20-21 / %x23-7E) DQUOTE
-predefinedtype = ('atom' "(" [atomattrs] ")")
- / ('boolean' "(" [booleanattrs] ")")
+predefinedtype = ('any' "(" [anyattrs] ")")
+ / ('none' "(" [noneattrs] ")")
+ / ('atom' "(" [atomattrs] ")")
/ ('binary' "(" [binaryattrs] ")")
/ ('float' "(" [floatattrs] ")")
/ ('integer' "(" [integerattrs] ")")
/ ('list' "(" [listattrs] ")")
- / ('proplist' "(" [proplistattrs] ")")
- / ('string' "(" [stringattrs] ")")
- / ('term' "(" [termattrs] ")")
/ ('tuple' "(" [tupleattrs] ")")
- / ('none' "(" [noneattrs] ")")
+
+anyattrs = anyattr
+ / (anyattr *WSP "," *WSP anyattrs)
+
+noneattrs = *WSP
atomattrs = atomattr
/ (atomattr *WSP "," *WSP atomattrs)
-booleanattrs = *WSP
-
binaryattrs = binaryattr
/ (binaryattr *WSP "," *WSP binaryattrs)
@@ -136,24 +136,11 @@ integerattrs = *WSP
listattrs = listattr
/ (listattr *WSP "," *WSP listattrs)
-proplistattrs = proplistattr
- / (proplistattr *WSP "," *WSP proplistattrs)
-
-stringattrs = stringattr
- / (stringattr *WSP "," *WSP stringattrs)
-
-termattrs = termattr
- / (termattr *WSP "," *WSP termattrs)
-
tupleattrs = tupleattr
/ (tupleattr *WSP "," *WSP tupleattrs)
-noneattrs = *WSP
-
+anyattr = 'nonempty' / 'nonundefined'
atomattr = 'ascii' / 'asciiprintable' / 'nonempty' / 'nonundefined'
binaryattr = 'ascii' / 'asciiprintable' / 'nonempty'
listattr = 'nonempty'
-proplistattr = 'nonempty'
-stringattr = 'ascii' / 'asciiprintable' / 'nonempty'
-termattr = 'nonempty' / 'nonundefined'
tupleattr = 'nonempty' / 'nonundefined'
@@ -9,15 +9,16 @@
%% Required (except keepalive/0) callback API for UBF stateless
%% implementations.
-export([info/0, description/0, keepalive/0]).
+-export([moduleStart/1, moduleRestart/1]).
-export([handlerStart/1, handlerStop/3, handlerRpc/1, handlerEvent/1]).
-import(ubf_plugin_handler, [sendEvent/2, install_handler/2]).
-compile({parse_transform,contract_parser}).
--add_contract("ubf_bertrpc_plugin").
+-add_contract("src/ubf_bertrpc_plugin").
--include("ubf.hrl").
--include("ubf_plugin_stateless.hrl").
+-include_lib("ubf/include/ubf.hrl").
+-include_lib("ubf/include/ubf_plugin_stateless.hrl").
info() ->
"I am a BERT-RPC server".
@@ -28,6 +29,14 @@ description() ->
keepalive() ->
ok.
+%% @doc start module
+moduleStart(_Args) ->
+ unused.
+
+%% @doc restart module
+moduleRestart(Args) ->
+ moduleStart(Args).
+
%% @doc start handler
handlerStart(_Args) ->
ack = install_handler(self(), fun handlerEvent/1),
Oops, something went wrong.

0 comments on commit fe276db

Please sign in to comment.