OgreNet.Cegui_bindings - Is it necessary?

EagleEye

21-12-2005 17:26:10

I'm wondering why, exactly, there needs to be this 3rd (and tiny) project seperate from the OgreNet project.

The only header file referenced in the entire project is OgreCEGUIRenderer.h... the problem is, because it's seperate from the rest of the OgreNet project, it doesn't benefit from any of the custom wrapping done in the larger project.

I did a little looking around, and this OgreCEGUIRenderer.h is a part of the main OgreSDK... so I am experimenting with removing the unnecessary project, and including that OgreCEGUIRenderer.h in the main OgreNet project.

rastaman

21-12-2005 18:04:57

I dont think that will work the CEGUI renderer is a seperat dll (OgreGUIRenderer_d.dll)

I'v don some to finish warpping the rendere

OgreBindings.Cegui.i

%module (directors="1") OgreBindings_Cegui

%{
#define NOMINMAX

#include "Ogre.h"
#include "OgreCEGUIRenderer.h"

using namespace CEGUI;
%}

%include std_string.i

%apply const std::string & {std::string &};
%apply std::string & {std::string *};
%apply const std::string & {const Ogre::String &};
%apply std::string & {Ogre::String &};
%apply std::string & {Ogre::String *};
%apply std::string & {String &};

%include CLSCompliancy.i

%include OgrePlatform.h
%ignore Ogre::KeyCode;

%include OgrePrerequisites.h


%define DLLNonePtrType(CSTYPE, CTYPE)
#if defined(SWIGCSHARP)
%typemap(imtype) CTYPE "CSTYPE";
%typemap(cstype) CTYPE "CSTYPE";
%typemap(csbase) CTYPE "CSTYPE";
%typemap(csin) CTYPE "(CSTYPE)$csinput";
%typemap(csout, excode=SWIGEXCODE) CTYPE {
return (CSTYPE)($imcall);
}
#endif
%enddef

DLLNonePtrType(OgreDotNet.RenderQueueGroupID, Ogre::RenderQueueGroupID)
DLLNonePtrType(OgreDotNet.SceneType, Ogre::SceneType)
DLLNonePtrType(OgreDotNet.TexturePtr, Ogre::TexturePtr)

PTR_REF_TYPEMAPS(OgreDotNet.RenderWindow, Ogre::RenderWindow)
PTR_REF_TYPEMAPS(OgreDotNet.SceneManager, Ogre::SceneManager)
PTR_REF_TYPEMAPS(OgreDotNet.TexturePtr, Ogre::TexturePtr)


DLLNonePtrType( CeguiDotNet.QuadSplitMode, QuadSplitMode)
DLLNonePtrType( CeguiDotNet.Rect, Rect)
DLLNonePtrType( CeguiDotNet.Size, Size)

PTR_REF_TYPEMAPS(CeguiDotNet.ColourRect, ColourRect)
PTR_REF_TYPEMAPS(CeguiDotNet.ResourceProvider, ResourceProvider)
PTR_REF_TYPEMAPS(CeguiDotNet.Texture, Texture)
PTR_REF_TYPEMAPS(CeguiDotNet.RawDataContainer, RawDataContainer)
PTR_REF_TYPEMAPS(CeguiDotNet.Rect, const Rect)






%ignore CEGUI::CEGUIRQListener;

//%typemap(csbase) CEGUI::OgreCEGUIRenderer "CeguiDotNet.Renderer";
DLLNonePtrType( CeguiDotNet.Renderer, CEGUI::OgreCEGUIRenderer)

%typemap(cscode) CEGUI::OgreCEGUIRenderer
%{
public void Initialise()
{
base.Initialise( swigCPtr, swigCMemOwn );
}
%}
%include "OgreCEGUIRenderer.h"



%include OgreCEGUIResourceProvider.h
%include OgreCEGUITexture.h



CLSCompliancy.i

%typemap(ctype) unsigned char, uchar, uint8 "unsigned char"
%typemap(imtype) unsigned char, uchar, uint8 "byte"
%typemap(cstype) unsigned char, uchar, uint8 "byte"
%typemap(csin) unsigned char, uchar, uint8 "(byte)$csinput"
%typemap(csout, excode=SWIGEXCODE) unsigned char, uchar, uint8
{
return (byte)($imcall);
}
%typemap(csvarout) unsigned char, uchar, uint8
%{
get {
return (byte)($imcall);
}
%}


%typemap(ctype) short "short";
%typemap(imtype) short "Int16"
%typemap(cstype) short "Int16";
%typemap(csin) short "(Int16)$csinput";
%typemap(csout, excode=SWIGEXCODE) short
{
return (Int16)($imcall);
}
%typemap(csvarout) short
%{
get {
return (Int16)($imcall);
}
%}


%typemap(ctype) unsigned short, ushort, uint16 "unsigned short";
%typemap(imtype) unsigned short, ushort, uint16 "UInt16"
%typemap(cstype) unsigned short, ushort, uint16 "UInt16";
%typemap(csin) unsigned short, ushort, uint16 "(UInt16)$csinput";
%typemap(csout, excode=SWIGEXCODE) unsigned short, ushort, uint16
{
return (UInt16)($imcall);
}
%typemap(csvarout) unsigned short, ushort, uint16
%{
get {
return (UInt16)($imcall);
}
%}


%typemap(ctype) unsigned short &, ushort &, uint16 & "unsigned short &";
%typemap(imtype) unsigned short &, ushort &, uint16 & "ref UInt16"
%typemap(cstype) unsigned short &, ushort &, uint16 & "ref UInt16";
%typemap(in) unsigned short &, ushort &, uint16 & "$1 = ($1_ltype)&$input;"
%typemap(csin) unsigned short &, ushort &, uint16 & "ref $csinput";

%typemap(ctype) unsigned short *, ushort *, uint16 * "unsigned short *";
%typemap(imtype) unsigned short *, ushort *, uint16 * "ref UInt16"
%typemap(cstype) unsigned short *, ushort *, uint16 * "ref UInt16";
%typemap(in) unsigned short *, ushort *, uint16 * "$1 = ($1_ltype)$input;"
%typemap(csin) unsigned short *, ushort *, uint16 * "ref $csinput";
%typemap(csout, excode=SWIGEXCODE) unsigned short *, ushort *, uint16 *
{
return (UInt16)(new UIntPtr((int)$imcall).ToInt32());

}
%typemap(csvarout) unsigned short *, ushort *, uint16 *
%{
get {
return (UInt16)(new UIntPtr((int)$imcall).ToInt32());
}
%}





%typemap(ctype) unsigned int, uint, uint32 "unsigned int";
%typemap(imtype) unsigned int, uint, uint32 "UInt32";
%typemap(cstype) unsigned int, uint, uint32 "UInt32";
%typemap(csin) unsigned int, uint, uint32 "(UInt32)$csinput";
%typemap(csout, excode=SWIGEXCODE) unsigned int, uint, uint32
{
return (UInt32)($imcall);
}
%typemap(csvarout) unsigned int, uint, uint32
%{
get {
return (UInt32)($imcall);
}
%}


%typemap(ctype) unsigned int &, uint &, uint32 & "unsigned int &";
%typemap(imtype) unsigned int &, uint &, uint32 & "ref UInt32"
%typemap(cstype) unsigned int &, uint &, uint32 & "ref UInt32";
%typemap(in) unsigned int &, uint &, uint32 & "$1 = ($1_ltype)&$input;"
%typemap(csin) unsigned int &, uint &, uint32 & "ref $csinput"


%typemap(ctype) unsigned int *, uint *, uint32 * "unsigned int *";
%typemap(imtype) unsigned int *, uint *, uint32 * "ref UInt32"
%typemap(cstype) unsigned int *, uint *, uint32 * "ref UInt32";
%typemap(in) unsigned int *, uint *, uint32 * "$1 = ($1_ltype)$input;"
%typemap(csin) unsigned int *, uint *, uint32 * "ref $csinput"
%typemap(csout, excode=SWIGEXCODE) unsigned int *, uint *, uint32 *
{
return new UIntPtr((int)$imcall).ToInt32();
}
%typemap(csvarout) unsigned int *, uint *, uint32 *
%{
get {
return new UIntPtr((int)$imcall).ToInt32();
}
%}



%typemap(ctype) int & "int &";
%typemap(imtype) int & "ref Int32"
%typemap(cstype) int & "ref Int32";
%typemap(in) int & "$1 = ($1_ltype)&$input;"
%typemap(csin) int & "ref $csinput"

%typemap(ctype) int * "int *";
%typemap(imtype) int * "ref Int32"
%typemap(cstype) int * "ref Int32";
%typemap(in) int * "$1 = ($1_ltype)$input;"
%typemap(csin) int * "ref $csinput"
%typemap(csout, excode=SWIGEXCODE) int *
{
return new IntPtr((int)$imcall).ToInt32();
}
%typemap(csvarout) int *
%{
get {
return new IntPtr((int)$imcall).ToInt32();
}
%}


%typemap(ctype) double * "double *";
%typemap(imtype) double * "ref Double"
%typemap(cstype) double * "ref Double";
%typemap(in) double * "$1 = ($1_ltype)$input;"
%typemap(csin) double * "ref $csinput"

%typemap(ctype) double & "double &";
%typemap(imtype) double & "ref Double"
%typemap(cstype) double & "ref Double";
%typemap(in) double & "$1 = ($1_ltype)&$input;"
%typemap(csin) double & "ref $csinput"


%typemap(ctype) float * "float *";
%typemap(imtype) float * "ref Single"
%typemap(cstype) float * "ref Single";
%typemap(in) float * "$1 = ($1_ltype)$input;"
%typemap(csin) float * "ref $csinput"

%typemap(ctype) float & "float &";
%typemap(imtype) float & "ref Single"
%typemap(cstype) float & "ref Single";
%typemap(in) float & "$1 = ($1_ltype)&$input;"
%typemap(csin) float & "ref $csinput"



%typemap(ctype) unsigned long, ulong, size_t "unsigned long";
%typemap(imtype) unsigned long, ulong, size_t "UInt32";
%typemap(cstype) unsigned long, ulong, size_t "UInt32";
%typemap(csin) unsigned long, ulong, size_t "(UInt32)$csinput";
%typemap(csout, excode=SWIGEXCODE) unsigned long, ulong, size_t
{
return (UInt32)($imcall);
}
%typemap(csvarout) unsigned long, ulong, size_t
%{
get {
return (UInt32)($imcall);
}
%}


%typemap(cstype) ResourceHandle "int";
%typemap(csin) ResourceHandle "(uint)$csinput";
%typemap(csout, excode=SWIGEXCODE) ResourceHandle
{
return (int)($imcall);
}
%typemap(csvarout) ResourceHandle
%{
get {
return(int)($imcall);
}
%}

%define VOID_PTR_TYPEMAP(TYPE, CTYPE)
%typemap(ctype) TYPE "CTYPE"
%typemap(imtype) TYPE "IntPtr"
%typemap(cstype) TYPE "IntPtr"
%typemap(in) TYPE %{ $1 = (CTYPE)$input; %}
%typemap(out) TYPE %{ $result = $1; %}
%typemap(csin) TYPE "$csinput"
%typemap(csout, excode=SWIGEXCODE) TYPE
{
return new IntPtr((int)$imcall);
}
%typemap(csvarin) TYPE
%{
set {
$imcall;
}
%}
%typemap(csvarout) TYPE
%{
get {
return new IntPtr((int)$imcall);
}
%}
%enddef
VOID_PTR_TYPEMAP( void *, void * )
VOID_PTR_TYPEMAP( void[ANY], void * )
VOID_PTR_TYPEMAP( void[], void * )
VOID_PTR_TYPEMAP( uchar *, unsigned char * )
VOID_PTR_TYPEMAP( unsigned char *, unsigned char * )
VOID_PTR_TYPEMAP( unsigned char **, unsigned char ** )



//pointer typemaps:
%define PTR_REF_TYPEMAPS(CSTYPE, CTYPE)
#if defined(SWIGCSHARP)
%typemap(ctype) CTYPE *, CTYPE & "void *"
%typemap(imtype) CTYPE *, CTYPE & "IntPtr"
%typemap(cstype) CTYPE *, CTYPE & "CSTYPE"
%typemap(csin) CTYPE *, CTYPE & "CSTYPE.getCPtr($csinput).Handle"
%typemap(csout, excode=SWIGEXCODE) CTYPE *, CTYPE & {
IntPtr cPtr = $imcall;
return (cPtr == IntPtr.Zero) ? null : new CSTYPE(cPtr, $owner);
}
%typemap(in) CTYPE *, CTYPE & %{ $1 = (CTYPE *)$input; %}
%typemap(out) CTYPE *, CTYPE & %{ $result = (void *)$1; %}
#endif
%enddef

%define CONST_PTR_REF_TYPEMAPS(CSTYPE, CTYPE)
#if defined(SWIGCSHARP)
%typemap(ctype) const CTYPE *& "void *"
%typemap(imtype) const CTYPE *& "IntPtr"
%typemap(cstype) const CTYPE *& "CSTYPE"
%typemap(csin) const CTYPE *& "CSTYPE.getCPtr($csinput).Handle"
%typemap(csout) const CTYPE *& {
IntPtr cPtr = $imcall;
return (cPtr == IntPtr.Zero) ? null : new CSTYPE(cPtr, $owner);
}
%typemap(in) const CTYPE *& (CTYPE *temp = 0) %{
temp = (CTYPE *)$input;
$1 = &temp;
%}
%typemap(out) const CTYPE *& %{ $result = (void *)*$1; %}
#endif
%enddef




// ***************************************************************************************
// The following typemaps are required to be able to wrap another library that use
// OgreDotNet.
// They make the constructors and the getCPtr() methods accessible, so the other wrapper
// can create OgreDotNet objects.
// ***************************************************************************************

// Proxy classes (base classes, ie, not derived classes)
%typemap(csbody) SWIGTYPE %{
private HandleRef swigCPtr;
protected bool swigCMemOwn;

public $csclassname(IntPtr cPtr, bool cMemoryOwn) {
swigCMemOwn = cMemoryOwn;
swigCPtr = new HandleRef(this, cPtr);
}

static public HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
}
%}


// Derived proxy classes
%typemap(csbody_derived) SWIGTYPE %{
private HandleRef swigCPtr;

public $csclassname(IntPtr cPtr, bool cMemoryOwn) : base($modulePINVOKE.$csclassnameUpcast(cPtr), cMemoryOwn) {
swigCPtr = new HandleRef(this, cPtr);
}

static public HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
}
%}

// Typewrapper classes
%typemap(csbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
private HandleRef swigCPtr;

public $csclassname(IntPtr cPtr, bool futureUse) {
swigCPtr = new HandleRef(this, cPtr);
}

protected $csclassname() {
swigCPtr = new HandleRef(null, IntPtr.Zero);
}

static public HandleRef getCPtr($csclassname obj) {
return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
}
%}

EagleEye

21-12-2005 18:24:03

My point is that it doesn't NEED to be a seperate DLL... it's just another extension of the original Ogre project.

OgreCEGUIRenderer.h refers to a the core OGRE header files, and ultimately, if you were to wrap the project completely, you'd end up redoing all of the Ogre wrapping.

rastaman

21-12-2005 18:59:19

it references both Ogre and CEGUI.
We could put it in OgreDotNet. but what will that gain? we dont have to rewrap Ogre, see in the OgreBindings.Cegui.i i tell it to use the OgreDotNet.xxx and CeguiDotNet.xxx objects.

EagleEye

21-12-2005 19:22:04

Okay, what you say sounds reasonable.

EagleEye

21-12-2005 21:45:21

I'm getting the following:


C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(69,67): error CS0122: 'CeguiDotNet.Rect.getCPtr(CeguiDotNet.Rect)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(69,114): error CS0122: 'CeguiDotNet.Texture.getCPtr(CeguiDotNet.Texture)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(69,155): error CS0122: 'CeguiDotNet.Rect.getCPtr(CeguiDotNet.Rect)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(69,202): error CS0122: 'CeguiDotNet.ColourRect.getCPtr(CeguiDotNet.ColourRect)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(87,43): error CS0122: 'CeguiDotNet.Texture.Texture(System.IntPtr, bool)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(92,43): error CS0122: 'CeguiDotNet.Texture.Texture(System.IntPtr, bool)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(97,43): error CS0122: 'CeguiDotNet.Texture.Texture(System.IntPtr, bool)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(102,43): error CS0122: 'CeguiDotNet.Texture.Texture(System.IntPtr, bool)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(107,43): error CS0122: 'CeguiDotNet.ResourceProvider.ResourceProvider(System.IntPtr, bool)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(111,74): error CS0122: 'CeguiDotNet.Texture.getCPtr(CeguiDotNet.Texture)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIRenderer.cs(169,43): error CS0122: 'CeguiDotNet.Texture.Texture(System.IntPtr, bool)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIResourceProvider.cs(44,98): error CS0122: 'CeguiDotNet.RawDataContainer.getCPtr(CeguiDotNet.RawDataContainer)' is inaccessible due to its protection level
C:\Documents and Settings\Jared\My Documents\Visual Studio Projects\ogreaddons\ogredotnet\OgreNet.Cegui\OgreCEGUIResourceProvider.cs(49,90): error CS0122: 'CeguiDotNet.RawDataContainer.getCPtr(CeguiDotNet.RawDataContainer)' is inaccessible due to its protection level

Build complete -- 13 errors, 20 warnings