Utilization of PIDL

Using Custom Build Rules

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:

Additional Dependencies : ..\..\..\util\PIDL.exe
Batching Separator :
Command Line : ..\..\..\util\PIDL.exe "$(InputPath)" -outdir .\
Display Name : PIDL
Execution Description : Compiling $(InputName).pidl ...
File Extensions : *.pidl
Name : PIDL Custom Build Rule
Outputs : $(InputDir)\$(InputName)_common.cpp;$(InputDir)\$(InputName)_common.h;$(InputDir)\$(InputName)_proxy.cpp;$(InputDir)\$(InputName)_proxy.h;$(InputDir)\$(InputName)_stub.cpp;$(InputDir)\$(InputName)_stub.h

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.

Using the Command Prompt (Command Prompt, cmd.exe)

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.

Using Customizations

Visual Stuido 2005, 2008 version

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.

Using include or import in PIDL content

As you develop your programs, you may want to include or import statements in your .pidl file.

#include "a/b/c.h"
 
class MyStub // PIDL compilation output
{
    ...
}

To do this, use the following inside your PIDL content.

#include "a/b/c.h" 
// for C++ language. semicolon is mandatory!

Marshaling

Using custom class types for RMI

// MyType.h
 
namespace Proud
{
    // The contents of the called RMI function are converted into a string and output.
    // Useful for creating logs.
    void AppendTextOut(String &a,const MyType &b);
 
    // Reads the contents of a custom type from the message buffer.
    CMessage& operator>>(CMessage &a, MyType &b);
 
    // Put the contents of the custom type into the message buffer.
    CMessage& operator<<(CMessage &a, const MyType &b);
}
 

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.

namespace Proud
{
    CMessage& operator>>(CMessage &a, MyType &b)
    {
        a>>b.x,b.y>>b.z>>b.w;
        return a;
    }
    CMessage& operator<<(CMessage &a, const MyType &b)
    {
        // Do not use a.UseInternalBuffer()!
        a<<b.x,b.y<<b.z<<b.w;
        return a;
    }
    void AppendTextOut(String &a,const MyType &b)
    {
        String f;
        f.Format(L"{x=%f,y=%f,z=%f,w=%f}",b.x,b.y,b.z,b.w);
        a+=f;
    }
}

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.

// Example1
#include "MyType.h"
#include "MyPIDL_proxy.h"
 
// Example2
#include "MyType.h"
#include "MyPIDL_stub.h"

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().