r7161: - Add support for "aliases" for pidls scalar types and add a few aliases.
authorJelmer Vernooij <jelmer@samba.org>
Wed, 1 Jun 2005 00:34:28 +0000 (00:34 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:21 +0000 (13:17 -0500)
- Define __PIDL__ when preprocessing IDL files.
- Remove a couple of useless defines from rpcecho.idl
rpcecho.idl now works in both pidl and midl
(althought pidl is a bit pedantic and gives two warnings)

source/build/pidl/idl.pm
source/build/pidl/idl.yp
source/build/pidl/typelist.pm
testprogs/win32/rpcecho/rpcecho.idl

index 156a3435e60ae4c718f61b6ad32642b8f2285f94..8b6cf3956e0f649bf1d805f6884b1ff856515c45 100644 (file)
@@ -2470,7 +2470,7 @@ sub parse_idl($$)
        if (! defined $cpp) {
                $cpp = "cpp"
        }
        if (! defined $cpp) {
                $cpp = "cpp"
        }
-       my $data = `$cpp -xc $filename`;
+       my $data = `$cpp -D__PIDL__ -xc $filename`;
        $/ = $saved_delim;
 
     $self->YYData->{INPUT} = $data;
        $/ = $saved_delim;
 
     $self->YYData->{INPUT} = $data;
index e28323762760b896d4bededadfe9e4eecf2e3214..b556b064b42d495daf468cfd6b915daf340fd754 100644 (file)
@@ -384,7 +384,7 @@ sub parse_idl($$)
        if (! defined $cpp) {
                $cpp = "cpp"
        }
        if (! defined $cpp) {
                $cpp = "cpp"
        }
-       my $data = `$cpp -xc $filename`;
+       my $data = `$cpp -D__PIDL__ -xc $filename`;
        $/ = $saved_delim;
 
     $self->YYData->{INPUT} = $data;
        $/ = $saved_delim;
 
     $self->YYData->{INPUT} = $data;
index a8600cedbe84edc0fbe0e12125340e199cba07d0..cc8504e80f4fa276e778d3d56aaa7c2fa22c38ff 100644 (file)
@@ -153,7 +153,7 @@ sub mapScalarType($)
 
        # it's a bug when a type is not in the list
        # of known scalars or has no mapping
 
        # it's a bug when a type is not in the list
        # of known scalars or has no mapping
-       return $scalars->{$name}{C_TYPE} if defined($scalars->{$name}) and defined($scalars->{$name}{C_TYPE});
+       return $typedefs{$name}->{DATA}->{C_TYPE} if defined($typedefs{$name}) and defined($typedefs{$name}->{DATA}->{C_TYPE});
 
        die("Unknown scalar type $name");
 }
 
        die("Unknown scalar type $name");
 }
@@ -225,11 +225,27 @@ sub RegisterScalars()
                $typedefs{$k} = {
                        NAME => $k,
                        TYPE => "TYPEDEF",
                $typedefs{$k} = {
                        NAME => $k,
                        TYPE => "TYPEDEF",
-                       DATA => {
-                               TYPE => "SCALAR",
-                               NAME => $k
-                       }
+                       DATA => $scalars->{$k}
                };
                };
+               $typedefs{$k}->{DATA}->{TYPE} = "SCALAR";
+               $typedefs{$k}->{DATA}->{NAME} = $k;
+       }
+}
+
+my $aliases = {
+       "DWORD" => "uint32",
+       "int" => "int32",
+       "WORD" => "uint16",
+       "char" => "uint8",
+       "long" => "int32",
+       "short" => "int16",
+       "hyper" => "HYPER_T"
+};
+
+sub RegisterAliases()
+{
+       foreach my $k (keys %{$aliases}) {
+               $typedefs{$k} = $typedefs{$aliases->{$k}};
        }
 }
 
        }
 }
 
@@ -304,5 +320,6 @@ sub LoadIdl($)
 }
 
 RegisterScalars();
 }
 
 RegisterScalars();
+RegisterAliases();
 
 1;
 
 1;
index 38fa58af411cb87138e25ed3e312bc8a76088f2a..3802d3c67840b9e25f1bc73701cb4984a6caccff 100644 (file)
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#ifndef __PIDL__
+#define unistr [string] wchar_t *
+#endif
+
 [
 uuid(60a15ec5-4de8-11d7-a637-005056a20182),
 version(1.0)
 [
 uuid(60a15ec5-4de8-11d7-a637-005056a20182),
 version(1.0)
@@ -45,13 +49,6 @@ interface rpcecho
                [in] int len,
                [out] [size_is(len)] char out_data[]
        );
                [in] int len,
                [out] [size_is(len)] char out_data[]
        );
-
-#define unistr [string] wchar_t *
-#define uint8 char
-#define uint16 short
-#define uint32 long
-#define HYPER_T hyper
-
        const long myconstant = 42;
 
        /* test strings */
        const long myconstant = 42;
 
        /* test strings */
@@ -60,36 +57,35 @@ interface rpcecho
                [out]  unistr *s2
                );
 
                [out]  unistr *s2
                );
 
-
        /* test some alignment issues */
        typedef struct {
        /* test some alignment issues */
        typedef struct {
-               uint8 v;
+               char v;
        } echo_info1;
 
        typedef struct {
        } echo_info1;
 
        typedef struct {
-               uint16 v;
+               short v;
        } echo_info2;
 
        typedef struct {
        } echo_info2;
 
        typedef struct {
-               uint32 v;
+               long v;
        } echo_info3;
 
        typedef struct {
        } echo_info3;
 
        typedef struct {
-               HYPER_T v;
+               hyper v;
        } echo_info4;
 
        typedef struct {
        } echo_info4;
 
        typedef struct {
-               uint8 v1;
-               HYPER_T v2;
+               char v1;
+               hyper v2;
        } echo_info5;
 
        typedef struct {
        } echo_info5;
 
        typedef struct {
-               uint8 v1;
+               char v1;
                echo_info1 info1;
        } echo_info6;
 
        typedef struct {
                echo_info1 info1;
        } echo_info6;
 
        typedef struct {
-               uint8 v1;
+               char v1;
                echo_info4 info4;
        } echo_info7;
 
                echo_info4 info4;
        } echo_info7;
 
@@ -139,13 +135,13 @@ interface rpcecho
                );
 
        typedef struct {
                );
 
        typedef struct {
-               uint32 x;
-               [size_is(x)] uint16 surrounding[*];
+               long x;
+               [size_is(x)] short surrounding[*];
        } echo_Surrounding;
 
        void echo_TestSurrounding(
                [in,out,ref] echo_Surrounding *data
        );
 
        } echo_Surrounding;
 
        void echo_TestSurrounding(
                [in,out,ref] echo_Surrounding *data
        );
 
-       uint16 echo_TestDoublePointer([in] uint16 ***data);
+       short echo_TestDoublePointer([in] short ***data);
 }
 }