Attached Files | opp_msgc.patch [^] (6,562 bytes) 2014-01-28 11:49 [Show Content] [Hide Content]--- opp_msgc (Kopie) 2014-01-21 13:21:18.571690000 +0100
+++ opp_msgc 2014-01-28 12:14:15.608766014 +0100
@@ -172,12 +172,7 @@
}
$hfilenamewithoutdir = $hfile;
$hfilenamewithoutdir =~ s|^.*/||;
- $hdef = $hfilenamewithoutdir;
- $hdef =~ s|^.*/||;
- $hdef =~ s|\.[^.]*$|_H_|;
- $hdef = '_'.$hdef;
- $hdef =~ tr/[a-z]/[A-Z]/;
- $hdef =~ s/[^a-zA-Z0-9]/_/g;
+
$ccfile = $filename;
$ccfile =~ s|\.[^.]*$|$ccsuffix|;
if ($here)
@@ -211,6 +206,69 @@
open(H,">$hfile") || die "$filename: Error: cannot open output file $hfile";
open(CC,">$ccfile") || die "$filename: Error: cannot open output file $ccfile";
+ # pre-register some OMNeT++ classes so that one doesn't need to announce them
+ #
+ # @classes contains fully qualified names (ie with namespace); keys to the other hashes are fully qualified as well
+ #
+ # note: $classtype values:
+ # 'cownedobject' ==> subclasses from cOwnedObject
+ # 'cnamedobject' ==> subclasses from cNamedObject but NOT from cOwnedObject
+ # 'cobject' ==> subclasses from cObject but NOT from cNamedObject
+ # 'foreign' ==> non-cObject class (classes announced as "class noncobject" or "extends void")
+ # 'struct' ==> struct (no member functions)
+ #
+ @classes = ('cObject', 'cNamedObject', 'cOwnedObject', 'cMessage', 'cPacket');
+ $classtype{'cObject'} = 'cobject';
+ $classtype{'cNamedObject'} = 'cnamedobject';
+ $classtype{'cOwnedObject'} = 'cownedobject';
+ $classtype{'cMessage'} = 'cownedobject';
+ $classtype{'cPacket'} = 'cownedobject';
+
+ @enums = ();
+
+ # some regex patterns
+ $RESERVED_WORDS = 'namespace|cplusplus|struct|message|packet|class|noncobject|'
+ . 'enum|extends|abstract|readonly|properties|fields|bool|char|short|'
+ . 'int|long|double|unsigned|string|true|false'
+ . 'float|int8|int16|int32|int64|uint8|uint16|uint32|uint64'
+ . '|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t'
+ . 'for|while|if|else|do|enum|class|struct|typedef|public|private'
+ . '|protected|auto|register|sizeof|void|new|delete|explicit|static'
+ . '|extern|return|try|catch';
+
+ $PRIMITIVE_TYPES = 'bool|float|double|simtime_t|string|((unsigned )?(char|short|int|long))|(u?int(8|16|32|64)(_t)?)';
+
+ $NAME = '([A-Za-z_][A-Za-z0-9_]*)'; # 1 group
+ $QNAME = "((::)?($NAME\:\:)*$NAME)"; # 5 groups
+
+ $CPLUSPLUS_BLOCK = '\bcplusplus\s+{{(.*?)}};?'; # 1 group (contains body)
+ $NAMESPACE_DECL = '\bnamespace\s+([A-Za-z0-9_:]+)\s*;'; # 1 group (contains name)
+
+ # parse namespace decl
+ # note: we remove the decl from the source, and mark its place with a '<namespace>' marker string
+ $namespacename = "";
+ while ($msg =~ s/$NAMESPACE_DECL/<namespace>/s)
+ {
+ if ($namespacename ne "") {
+ print "$filename: Error: multiple namespace declarations\n"; $ret=1;
+ }
+
+ $namespacename = $1;
+
+ if (!($namespacename =~ /^$QNAME$/)) {
+ print "$filename: Error: wrong syntax in namespace name '$namespacename'\n"; $ret=1;
+ }
+
+ $namespacename =~ s/^:://;
+ }
+
+ $hdef = $hfilenamewithoutdir;
+ $hdef =~ s|^.*/||;
+ $hdef =~ s|\.[^.]*$|_H_|;
+ $hdef = '_'.$namespacename.'_'.$hdef;
+ $hdef =~ tr/[a-z]/[A-Z]/;
+ $hdef =~ s/[^a-zA-Z0-9]/_/g;
+
print H "//\n// Generated file, do not edit! Created by opp_msgc $MSGC_VERSION from $filename.\n//\n\n";
print H "#ifndef $hdef\n";
print H "#define $hdef\n\n";
@@ -272,44 +330,6 @@
}
print CC "\n\n";
- # pre-register some OMNeT++ classes so that one doesn't need to announce them
- #
- # @classes contains fully qualified names (ie with namespace); keys to the other hashes are fully qualified as well
- #
- # note: $classtype values:
- # 'cownedobject' ==> subclasses from cOwnedObject
- # 'cnamedobject' ==> subclasses from cNamedObject but NOT from cOwnedObject
- # 'cobject' ==> subclasses from cObject but NOT from cNamedObject
- # 'foreign' ==> non-cObject class (classes announced as "class noncobject" or "extends void")
- # 'struct' ==> struct (no member functions)
- #
- @classes = ('cObject', 'cNamedObject', 'cOwnedObject', 'cMessage', 'cPacket');
- $classtype{'cObject'} = 'cobject';
- $classtype{'cNamedObject'} = 'cnamedobject';
- $classtype{'cOwnedObject'} = 'cownedobject';
- $classtype{'cMessage'} = 'cownedobject';
- $classtype{'cPacket'} = 'cownedobject';
-
- @enums = ();
-
- # some regex patterns
- $RESERVED_WORDS = 'namespace|cplusplus|struct|message|packet|class|noncobject|'
- . 'enum|extends|abstract|readonly|properties|fields|bool|char|short|'
- . 'int|long|double|unsigned|string|true|false'
- . 'float|int8|int16|int32|int64|uint8|uint16|uint32|uint64'
- . '|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t'
- . 'for|while|if|else|do|enum|class|struct|typedef|public|private'
- . '|protected|auto|register|sizeof|void|new|delete|explicit|static'
- . '|extern|return|try|catch';
-
- $PRIMITIVE_TYPES = 'bool|float|double|simtime_t|string|((unsigned )?(char|short|int|long))|(u?int(8|16|32|64)(_t)?)';
-
- $NAME = '([A-Za-z_][A-Za-z0-9_]*)'; # 1 group
- $QNAME = "((::)?($NAME\:\:)*$NAME)"; # 5 groups
-
- $CPLUSPLUS_BLOCK = '\bcplusplus\s+{{(.*?)}};?'; # 1 group (contains body)
- $NAMESPACE_DECL = '\bnamespace\s+([A-Za-z0-9_:]+)\s*;'; # 1 group (contains name)
-
# encode cplusplus blocks in a copy of msg, so that we don't accidentally match namespace keywords in them
$tmp = $msg;
%cppblocks = {};
@@ -344,23 +364,6 @@
}
print H "\n";
- # parse namespace decl
- # note: we remove the decl from the source, and mark its place with a '<namespace>' marker string
- $namespacename = "";
- while ($msg =~ s/$NAMESPACE_DECL/<namespace>/s)
- {
- if ($namespacename ne "") {
- print "$filename: Error: multiple namespace declarations\n"; $ret=1;
- }
-
- $namespacename = $1;
-
- if (!($namespacename =~ /^$QNAME$/)) {
- print "$filename: Error: wrong syntax in namespace name '$namespacename'\n"; $ret=1;
- }
-
- $namespacename =~ s/^:://;
- }
foreach my $i (split("::", $namespacename)) {
if ($i =~ /^($RESERVED_WORDS)$/) {
print "$filename: Error: namespace name '$i' is a reserved word\n"; $ret=1;
|