Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Steve Officer
committed
Feb 17, 2012
1 parent
5d6f1f1
commit c698bd6
Showing
5 changed files
with
74 additions
and
1 deletion.
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
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,25 @@ | ||
namespace DicomDSL | ||
|
||
import System | ||
import Boo.Lang.Compiler.Ast | ||
|
||
final class ShortStringMacro(TagMacro): | ||
"""Description of SHMacro""" | ||
public def constructor(): | ||
pass | ||
|
||
VR: | ||
get: return "SH" | ||
|
||
def ReadTagValues(data_arguments as ExpressionCollection): | ||
values = List[of string](data_arguments.Count) | ||
for arg in data_arguments: | ||
raise TagException(arg.LexicalInfo, "The tag values must be a $NodeType.StringLiteralExpression") if arg.NodeType != NodeType.StringLiteralExpression | ||
v = (arg as StringLiteralExpression).Value | ||
raise TagException(arg.LexicalInfo, "An $VR value cannot contain the LF character.") if char(0x0A) in v | ||
raise TagException(arg.LexicalInfo, "An $VR value cannot contain the FF character.") if char(0x0C) in v | ||
raise TagException(arg.LexicalInfo, "An $VR value cannot contain the CR character.") if char(0x0D) in v | ||
raise TagException(arg.LexicalInfo, "An $VR value cannot contain the \\ character.") if char(0x5C) in v | ||
values.Add(v) | ||
return values | ||
|
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,33 @@ | ||
namespace DicomDSL | ||
|
||
import System | ||
import Boo.Lang.Compiler.Ast | ||
|
||
final class SignedLongMacro(TagMacro): | ||
"""Description of SLMacro""" | ||
public def constructor(): | ||
pass | ||
|
||
public static final error_msg = "The tag values must be positive or negative integers" | ||
|
||
VR: | ||
get: return "SL" | ||
|
||
private def AssertValueIsLong(node as Expression): | ||
raise TagException(node.LexicalInfo, error_msg) if node.NodeType != NodeType.IntegerLiteralExpression | ||
|
||
def ReadTagValues(data_arguments as ExpressionCollection): | ||
# This can't actually return its values as a string because it needs to be serialized as an integer" | ||
values = List[of string](data_arguments.Count) | ||
for arg in data_arguments: | ||
if arg.NodeType == NodeType.UnaryExpression: | ||
expr = arg as UnaryExpression | ||
raise TagException(arg.LexicalInfo, error_msg) if expr.Operator != UnaryOperatorType.UnaryNegation | ||
AssertValueIsLong(expr.Operand) | ||
v = -(expr.Operand as IntegerLiteralExpression).Value | ||
else: | ||
AssertValueIsLong(arg) | ||
v = (arg as IntegerLiteralExpression).Value | ||
values.Add(v.ToString()) | ||
return values | ||
|
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,12 @@ | ||
namespace DicomDSL | ||
|
||
import System | ||
import System.Collections.Generic | ||
|
||
# This will have a child macro called SequenceItemMacro and the tags will be nested below this. | ||
# Tags pass TagNode up to SequenceItem, SequenceItem passes TagNode collection up to Sequence, Sequence passes the whole thing up to Dicom Macro | ||
macro SQ: | ||
all_tags = self.__macro["tags"] as IEnumerable[of KeyValuePair[of uint, byte]] | ||
for tag in all_tags: | ||
print "$tag.Key : $tag.Value" | ||
|