-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CommandLine] Rewrite mode dispatch to use a new ModeCondition object…
…. Remove lots of old crufty code. Several misc cleanups
- Loading branch information
1 parent
e69e868
commit 0631b95
Showing
4 changed files
with
96 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
class Rosella.CommandLine.ModeCondition | ||
{ | ||
function is_satisfied(var args) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
class Rosella.CommandLine.ModeCondition.FlagSet : Rosella.CommandLine.ModeCondition | ||
{ | ||
var flagname; | ||
|
||
function FlagSet(string flagname) | ||
{ | ||
self.flagname = flagname; | ||
} | ||
|
||
function is_satisfied(var args) | ||
{ | ||
string flagname = string(self.flagname); | ||
int value = args[flagname]; | ||
return value; | ||
} | ||
} | ||
|
||
class Rosella.CommandLine.ModeCondition.ScalarValue : Rosella.CommandLine.ModeCondition | ||
{ | ||
var name; | ||
var value; | ||
|
||
function ScalarValue(string name, string value) | ||
{ | ||
self.name = name; | ||
self.value = value; | ||
} | ||
|
||
function is_satisfied(var args) | ||
{ | ||
string name = self.name; | ||
string expectedvalue = self.value; | ||
string actualvalue = args[name]; | ||
if (expectedvalue == actualvalue) | ||
return true; | ||
return false; | ||
} | ||
} | ||
|
||
class Rosella.CommandLine.ModeCondition.GenericFunc : Rosella.CommandLine.ModeCondition | ||
{ | ||
var func; | ||
|
||
function GenericFunc(var f) | ||
{ | ||
self.func = f; | ||
} | ||
|
||
function is_satisfied(var args) | ||
{ | ||
var f = self.func; | ||
return f(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters