diff options
author | Loïc Hoguin <[email protected]> | 2014-12-22 16:24:17 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2014-12-22 16:25:15 +0200 |
commit | 68c888981b1b81e922de86813effce14b0f06082 (patch) | |
tree | f8c21b55a90ee3462b62bd859a95d7f93cb4fe6c /plugins/bootstrap.mk | |
parent | 708812c67f4625d7f91c7ccd9388ecab61a8359d (diff) | |
download | erlang.mk-68c888981b1b81e922de86813effce14b0f06082.tar.gz erlang.mk-68c888981b1b81e922de86813effce14b0f06082.tar.bz2 erlang.mk-68c888981b1b81e922de86813effce14b0f06082.zip |
Improve the gen_fsm template
* Rename and add the default state functions `state_name/2,3`
* Rename the variable `State` into `StateData` as per documentation
Diffstat (limited to 'plugins/bootstrap.mk')
-rw-r--r-- | plugins/bootstrap.mk | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk index 6fba54c..0829de3 100644 --- a/plugins/bootstrap.mk +++ b/plugins/bootstrap.mk @@ -125,7 +125,9 @@ tpl_gen_fsm = "-module($(n))." \ "" \ "%% gen_fsm." \ "-export([init/1])." \ + "-export([state_name/2])." \ "-export([handle_event/3])." \ + "-export([state_name/3])." \ "-export([handle_sync_event/4])." \ "-export([handle_info/3])." \ "-export([terminate/3])." \ @@ -143,22 +145,28 @@ tpl_gen_fsm = "-module($(n))." \ "%% gen_fsm." \ "" \ "init([]) ->" \ - " {ok, initial_state, \#state{}}." \ + " {ok, state_name, \#state{}}." \ "" \ - "handle_event(_Event, StateName, State) ->" \ - " {next_state, StateName, State}." \ + "state_name(_Event, StateData) ->" \ + " {next_state, state_name, StateData}." \ "" \ - "handle_sync_event(_Event, _From, StateName, State) ->" \ - " {reply, ignored, StateName, State}." \ + "handle_event(_Event, StateName, StateData) ->" \ + " {next_state, StateName, StateData}." \ "" \ - "handle_info(_Info, StateName, State) ->" \ - " {next_state, StateName, State}." \ + "state_name(_Event, _From, StateData) ->" \ + " {reply, ignored, state_name, StateData}." \ "" \ - "terminate(_Reason, _StateName, _State) ->" \ + "handle_sync_event(_Event, _From, StateName, StateData) ->" \ + " {reply, ignored, StateName, StateData}." \ + "" \ + "handle_info(_Info, StateName, StateData) ->" \ + " {next_state, StateName, StateData}." \ + "" \ + "terminate(_Reason, _StateName, _StateData) ->" \ " ok." \ "" \ - "code_change(_OldVsn, StateName, State, _Extra) ->" \ - " {ok, StateName, State}." + "code_change(_OldVsn, StateName, StateData, _Extra) ->" \ + " {ok, StateName, StateData}." tpl_cowboy_http = "-module($(n))." \ "-behaviour(cowboy_http_handler)." \ "" \ |