Utilization of PIDL
Last updated
Last updated
Display Name : the name that will be displayed in Custom Build Rules. ex) PIDL Rule File Name : create a rule filename. ex) PIDL_Custom_Build_Rule Directory : specify the location where the rule file will be saved. ex) C:\XXX\YYY
The details of each setting are as follows:
After completing the settings, a PIDL Build Rule is added to Custom Build Rules as follows.
Check out the newly created rules file, and when you create a file in your project, you will see that the Build Tool is automatically selected as PIDL.
If the PIDL AddOn or Custom Build Rules are not available, you can compile via command prompt on the Windows OS.
For cs, you can compile it with the PIDL -cs command.
PIDL.exe is located in the util folder of the ProudNet installation path.
Both Debug and Release must be set to the same.
Do not follow the example with the path to PIDL.exe, but set the path to PIDL in the path where ProudNet is installed.
In this example, we created a Common - PIDL folder and specified it as the PIDL compile path (outdir).
Please do not follow that include path, but specify the required path for your project.
Check out the generated source files and include them in the Visual Studio project properties window to use them when you build.
Visual Stuido 2005, 2008 version
Custom Build Rules can be used to create rule files
One rule file with .rules extension
Visual Studio 2010 and later version
Can be used/cannot be created using Custom Build Rules
Three files are required: .props, .targets, and .xml. Unable to use the .rules file created from a previous version
Two ways to use customizations
1. After creating a project in Visual Studio 2005 or 2008, create a .rules file and set it to use, then convert the project to version 2010 or later. : When converting a project, .rules files are automatically converted to .props, .targets, and .xml.
2. Create .props, .targets, and .xml files and write your own XML code to use them
Visual Studio 2005, 2008 and Visual Studio 2010 and later versions have different defined macros. If the rule is not written in the macros used in the Visual Studio 2010 and later versions, you must convert to the macros used in the Visual Studio 2010 and later versions or modify .props, .targets, and .xml respectively after the conversion.
As you develop your programs, you may want to include or import statements in your .pidl file.
To do this, use the following inside your PIDL content.
Inside ProudNet's RMI functionality, we are using Proud.CMessage. And RMI parameters are marshaled through overloading of the above functions. Proud.CMessage is being used here. Proud.CMessage holds the message data used by ProudNet to turn RMIs into messages or read parameters from messages, and is used as a stream object.
An example of implementing a stream in a marshaling function is as follows.
Finally, before including the proxy and stub files created by the PIDL compiler, the header file where the above overloaded methods are declared must be included first.
See <installed folder>/sample/CustomTypeMarshal or <Sample/CasualGame/GCServer/FarmCommon.h> for examples of actual implementations. To verify that your own marshalling functionality works, use Proud.TestMarshal().
There are ways to marshal information about a character in an RMI parameter where each field is valid or invalid for different types of characters. You can implement different marshalling using switch/case statements or polymorphism of objects. Below is an example of using swich/case.
You can marshal data in bits to reduce the amount of data stored in the message. Proud.CMessage has the following methods of storing data in bit units.
Precautions of marshaling data in bits
The number of bits you want to record should not be outside the range of the actual value you want to record. For example, if you want to write an int and the value inside is actually negative, the first bit is 1. In this case, if you try to write 31 bits or less to reduce the amount of bits, the value of the first bit will be missing, so be aware of this when doing reading/writing in bits.
To marshal an enum type, implement a function like the one below.
By using the macro PROUDNET_SERIALIZE_ENUM already defined in ProudNet, the above implementation can be easily accomplished as follows.
ProudNet provides you with the ability to marshal a few basic types of collections (e.g., arrays). It supports Proud.CFastArray, Proud.CFastMap, std.vector and CAtlArray.
See the operator>>, operator<< override in marshaler.h for more details.
If you need marshaling of collection types other than those defined by default in marshaler.h, you will need to implement an override corresponding to the collection you need. For this, see Using custom class types for RMI or marshaler.h for examples already implemented.
If you want to marshal for a collection type that ProudNet does not yet support, use the following routine as a guide to write it.
When PIDL is written as above, the PIDL compiler compiles it as follows for the base type.
If you want to change the delivery method, use the keywords below.
Method | Description |
---|---|
Name of keyword | Description | Example usage |
---|---|---|
Name of keyword | Example (PIDL) | Example (output) |
---|---|---|
Proud.CMessage.ReadBits
Read in bit
Proud.CMessage.WriteBits
Write in bit
access
[C#] Setting access to proxy and stub classes in a namespace
[access=Permission name]
byval
Passing parameters as value
P2PChat([in] Proud::String a, [in, byval] int b);
global
Namespace access (currently global only)
global Simple 2000 { ... }
in
Enter parameters
Chat([in] string txt);
include
[C#] Insert include into the result
#include "a/b/c.cpp"
marshaler
[C#] Marshaller for custom types
[marshaler(cs) = SimpleCSharp.CMyMarshaler]
mutable
Passing a parameter as mutable (:=reference)
Chat([in, mutable] string txt);
private
[C#] Setting access to proxy and stub classes in a namespace
[access=private]
protected
[C#] Setting access to proxy and stub classes in a namespace
[access=protected]
public
[C#] Setting access to proxy and stub classes in a namespace
[access=public]
rename
Compiling with substitutions in a specific environment
rename cs(Proud::String, System.String);
using
[C#] Insert the using keyword in the result
using(cs) System.XXX;
None
Chat([in] int val);
...Chat(..., const int& val)...
byval
Chat([in, byval] int val);
...Chat(..., const int val)...
mutable
Chat([in, mutable] int val);
...Chat(..., int& val)...