RPCGen.NET
- Distinct RPC/XDR IDL Compiler
RPCGen.NET
compiles RPC/XDR IDL ("*.x") files into C# client and server stubs.
Syntax
RPCGen.NET [
options ] filename.x
Description
The
RPCGen.NET command compiles RPC/XDR IDL ".x" files into C# client
and server stubs. You then integrate these stubs with your RPC client or
server application, compile the complete application , and run it together
with the Distinct ONC RPC/XDR for .NET DLL. The stubs are created as C# files
in the current directory. RPCGen.NET creates one main stub class file per
".x" file, which has the same name as the ".x" file but
has a ".cs" extension, as well as one C# class per data structure
defined in the ".x" file. The server stubs include an additional
stub for the server.
The main stub class is always derived from the class NetRPCClient. It defines
a constructor that connects the client to the server and one method for each
function defined in the RPC/XDR interface description. As with the C mapping,
the interface version number is automatically appended after an underscore to
the method names. All defined types in the interface description and the
types of the methods input and output parameters are mapped to equivalent C#
types.
XDR data
structures are mapped to C# types as follows.
|
XDR Data Structures
|
.NET Types
|
|
(unsigned) int
|
int
|
|
(unsigned) long
|
int
|
|
(unsigned) short
|
short
|
|
(unsigned) char
|
char
|
|
(unsigned) hyper
|
long
|
|
float
|
float
|
|
double
|
double
|
|
bool
|
boolean
|
|
string
|
String
|
|
opaque
|
byte array
|
|
fixed length array
|
C# array
|
|
variable length array
|
C# array
|
|
optional data (pointer-like *x)
|
Reference to an object of class
x. If x is a basic type, a special wrapper class XDRx which implements
XDRType is used instead.
|
|
enum x
|
Class x implements XDRType with
member variable int value and one constant int per enum constant.
|
|
struct x
|
Class x implements XDRType with
member variables for each struct member.
|
|
union x
|
Class x implements XDRType with
member variables for each union member including discriminant. No
overlaying of members is supported (neither for type conversion nor for
saving space).
|
|
typedef x y
|
Class x implements XDRType with
member variable value of the redefined type y.
|
Each generated class implements the XDRType interface. This interface defines
the methods for encoding and decoding the classes into and from an XDRStream.
You can define your own types (or alter the RPCGen.NET generated files) and
use them in RPC calls as long as they define these RFC 1832 (XDR) compliant
encoding and decoding methods.
RPCGen.NET
understands C-like comments (/* ... */) and it copies lines that are starting
with a "%" symbol to the beginning of all generated output files.
By default, RPCGen.NET runs a C/C++ preprocessor on the given ".x"
file before translating it to C#. It defines two symbols for this
preprocessor run. The symbol "RPCNET" is always defined. In
addition, a context symbol with the name of the top-level ".x" file
(without extension) is defined (i.e. "RPCGen.NET demo.x" defines a
symbol "demo"). This allows the writing of RPC/XDR specifications
with special C# related parts (although this is not recommended, it might
sometimes be necessary).
Options
|
-c command
|
Specifies the name of the C/C++
preprocessor to be used. The default is "cl /C /EP /nologo" (in
the current path). Specify the command line if you are using a different
preprocessor (for example, "/usr/ccs/lib/cpp" on Solaris systems).
|
|
-d
|
Removes all input lines from the
.x file which start with '%'. These lines often contain C specific comments
which are no longer needed.
|
|
-f
|
Names the generated class after
the name given in the "program" statement. Without this option,
the name of the generated class is based on the name of the .x file being
processed. This option is useful to override the default behavior if there
is no relationship between the class name and the name of the .x file.
|
|
-m
|
RPCGen.NET by default generates constructors
for XDR data types. If not required, this feature can be disabled by
specifying this option.
|
|
-n
|
Do not run the C/C++
preprocessor before translating the ".x" file. This option is
useful when you do not have a C compiler installed or you want to translate
a file that does not contain preprocessor directives.
|
|
-o class
|
Names the generated class as
specified by the class parameter. Without this option, the name of the
generated class is based on the name of the .x file being processed. This
option is useful to override the default behavior if there is no
relationship between the class name and the name of the .x file.
|
|
-O path
|
Specifies the destination path
where all generated files will be saved.
|
|
-p namespace
|
Specifies the namespace of the
generated stub files. By default the namespace is the name of the .x file
with an appended "RPC".
|
|
-P namespace
|
Specifies the package name of
the generated stub files, creates according subdirectories and places the
generated files there.
|
|
-S
|
Use this option to generate the
server side stubs.
|
|