Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
libdeng2|scriptsys: Clearing the state of a Process completely
  • Loading branch information
skyjake committed May 10, 2013
1 parent 4023d7e commit c73664d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doomsday/libdeng2/include/de/scriptsys/process.h
Expand Up @@ -94,6 +94,13 @@ class DENG2_PUBLIC Process
/// Determines the current depth of the call stack.
duint depth() const;

/**
* Resets the process to an empty state. All existing content in the
* process's context stack is removed, leaving the process in a similar
* state than after construction.
*/
void clear();

/**
* Starts running the given script. Note that the process must be
* in the FINISHED state for this to be a valid operation.
Expand Down
8 changes: 8 additions & 0 deletions doomsday/libdeng2/src/scriptsys/process.cpp
Expand Up @@ -54,6 +54,14 @@ Process::~Process()
clearStack();
}

void Process::clear()
{
_state = Stopped;
clearStack();
_stack.push_back(new Context(Context::BaseProcess, this));
_workingPath = "/";
}

void Process::clearStack(duint downToLevel)
{
while(depth() > downToLevel)
Expand Down

0 comments on commit c73664d

Please sign in to comment.