-
Notifications
You must be signed in to change notification settings - Fork 10
Mapping function signatures
In "PL/SQL Developer Plug-In interface Documentation" which is shiped with PL/SQL Developer installation and is in <PL/SQL Developer home>\plugindoc directory, all functions signature are given in C++ and Delphi languages using their data types. In order to call PL/SQL Developer callback functions from the plug-in or PL/SQL Developer to call plug-in's exported functions, the correct function signature must be used. In other words, data types must match. Parameter name does not affect signature, thus any name you like can be used.
According to "PL/SQL Developer Plug-In interface Documentation", the number of data types is limited to 3:
...Boolean (32 bit), Integer (32 bit) and zero terminated strings.
This table provides mapping rules between C#, C++ and Delphi data types.
| C++ | Delphi | C# |
|---|---|---|
| char* | PChar | string, when passing as an argument IntPtr, when using as return type |
| char** | var PChar | out string |
| int | int | int |
| void | procedure | void |
| BOOL | Bool | [MarshalAs(UnmanagedType.Bool)] bool |
| void* | Pointer | IntPtr |
See Passing and returning arguments for more details on passing arguments to and receiving values back from the unmanaged code.
Some examples of matching function signatures.
Tip: different names, maching your naming convention, can be used for functions and parameters names. Not necessarilly those given in the API documentation. Names do not affect signature. Anyway it is recommended that looking at the name of your function you could easily map it to the name in the API documentation. For instance, IDE_RefreshMenus could be IdeRefreshMenus. See Recommended naming for some hints.
IDE_RefreshMenus:
void IDE_RefreshMenus(int ID); // C++
procedure IDE_RefreshMenus(ID: Integer); // Delphi
void IDE_RefreshMenus(int id); // C#
IDE_SetMenuCheck:
void IDE_SetMenuCheck(int ID, int Index, BOOL Enabled); //C++
procedure IDE_SetMenuCheck(ID, Index: Integer; Enabled: Bool); // Delphi
void IDE_SetMenuCheck(int id, int index, [MarshalAs(UnmanagedType.Bool)] bool enabled); // C#
IDE_SetConnection (note how return value is marshalled):
BOOL IDE_SetConnection(char *Username, char *Password, char *Database); // C++
function IDE_SetConnection(Username, Password, Database: PChar): Bool; // Delphi
[return: MarshalAs(UnmanagedType.Bool)]
bool IDE_SetConnection(string username, string password, string db); // C#
IDE_GetConnectionInfo (demonstrates usage of out parameters):
void IDE_GetConnectionInfo(char **Username, char **Password, char **Database); // C++
procedure IDE_GetConnectionInfo(var Username, Password, Database: PChar); // Delphi
void IDE_GetConnectionInfo(out string username, out string password, out string db); // C#
Introduction
Main concepts
- Anatomy of the plug-in
- Exporting DLL functions
- Using callbacks
Misc
- Using menu items
- Accepting commands in the command window
- Validating DLL exports
- Working with color preferences
- Referencing external C# assemblies