.NETGURU
MC++ wrapper code problems with return enum type.
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vc.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

tzvika.visman@nospammsys.com
I write a MC++ wrapper for our company internal SDK that wrote in C++ native
code for writing application with this SDK over C# and other .NET languages
and most of my SDK API function return a status code that define as a enum
type.
Do I have other option then duplicate the enum from the c++ to the C# code
and write a MC++ class that look something like this:

public __gc class ManagedDokStatus

{

public:

ManagedDokStatus(DOK_STATUS statusCode):m_statusCode (statusCode ){}

__property int get_Status()

{

return static_cast<int> (m_statusCode);

}

private:

DOK_STATUS m_statusCode;

};

The DOK_STATUS type is the native c++ enum and from the C# code I done
something like this:

Declare the following enum:

enum C#DokStatus

{

// define the same c++ native enum attributes

};

And using the API like this:

return (C#DokStatus)(dok.getSerialNumber (ref serialNumber)).Status;

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Reply to this message...
 
    
charlee strong (VIP)
hi,
I assume you need to redefine the macros in your Managed wrapper.
That's what i'm doing in my project, I would like to get second openion:
for example, in my legacy unmanaged SDK, i have a class :
namespace UnManaged{
class Foo
{
enum MyEnum{ MODE1=0, MODE2 };
...
}
}
the wrapper will be:
class ManagedFoo
{
// Now i have a two ways to redefine
// Method : 1 Native enum - but which is not visible from C#
public:
enum MyEnum{ MODE1=0, MODE2 };
or
enum class MyEnum{ MODE1=0, MODE2}; // CLI enum - which is visible from C#
}

Is there a 3rd way by using typedef to redefine Unmaged enum in managed class?

"Click here to reveal e-mail address" wrote:

[Original message clipped]

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification