code: function () {
              /*  determine parameters  */
              var params = $cs.params("guard", arguments, {
                  method: { pos: 0, valid: "string", req: true },
                  level:  { pos: 1, valid: "number", req: true }
              });
  
              /*  sanity check enter/leave method name  */
              var valid = false;
              var i;
              for (i = 0; i < _cs.states.length; i++) {
                  if (   _cs.states[i].enter === params.method
                      || _cs.states[i].leave === params.method) {
                      valid = true;
                      break;
                  }
              }
              if (!valid)
                  throw _cs.exception("guard", "no such declared enter/leave method: \""
                      + params.method + "\"");
  
              /*  ensure the guard slot exists  */
              if (!_cs.isdefined(this.__state_guards[params.method]))
                  this.__state_guards[params.method] = 0;
  
              /*  activate/deactivate guard  */
              var deactivate = false;
              if (params.level > 0)
                  /*  increase guard level  */
                  this.__state_guards[params.method] += params.level;
              else  if (params.level < 0) {
                  /*  decrease guard level  */
                  if (this.__state_guards[params.method] < (-params.level))
                      throw _cs.exception("guard", "guard level decrease request too large");
                  this.__state_guards[params.method] += params.level;
                  if (this.__state_guards[params.method] === 0)
                      deactivate = true;
              }
              else {
                  /*  reset guard level  */
                  this.__state_guards[params.method] = 0;
                  deactivate = true;
              }
              if (deactivate) {
                  /*  finally deactivate guard  */
                  delete this.__state_guards[params.method];
  
                  /*  give all pending state transitions
                      (which now might proceed) a chance  */
                  _cs.state_progression();
              }
          }
docs: /*  guard a state enter/leave method