[Mono-list] C# & AIX Compatibility!!

Jonathan Pryor jonpryor@vt.edu
22 Jul 2003 08:35:30 -0400


I am not aware of any efforts to port Mono to AIX.  It's also unlikely
to happen very soon, as (IIRC) AIX runs on a PowerPC-compatible
platform, and PowerPC support is rather lacking right now.  That should
change in the future, but the time-frame is unknown.

Which leaves (*gasp*) the option of rewriting the code in C++.  Or,
trying to convince your client to use Linux on Intel hardware, instead
of AIX.

As far as the "rewrite in C++" route goes, I'm not aware of any articles
or websites that suggest how to go about this.  I wouldn't think it
particularly difficult, however, unless heavy use of System.Reflection
or the runtime infrastructure is used (e.g. AppDomains, loading
Assemblies at runtime, use of System.Object.GetType(), etc.).  I am not
aware of any C++ equivalent for the runtime infrastructure.

However, if the runtime is used minimally (hopefully true in your case),
language conversion shouldn't be too difficult.  Indexers would map do a
operator[] on the appropriate class.  However, since C# makes it so easy
to distinguish between get and set access on the returned value,
operator[] will need to return a new class (a proxy), which uses an
implicit conversion operator for the get operation, and operator= for
the set operation.  For example:

	/* implements get/set functionality */
	struct IntProxy {
		operator int () const {/* ... */}
		IntProxy& operator=(const int& n) {/* ... */}
	};

	struct Segment {
		/* for the indexer */
		IntProxy operator[](const std::string& idx);
	};

Properties can be simulated (using the same proxy technique shown
above), but is likely overkill.  Just using set/get methods is likely
the simpler approach:

	struct HasProperties {
		/* Name property */
		std::string Name() const;
		void Name(const std::string& name);
	};

 - Jon

On Tue, 2003-07-22 at 00:25, Anand Ramani wrote:
> Hi,
> I have a query regd C# wrt non-Windows platorm(AIX to
> be specific).
> 
> Our client has an existing C# class library(part of
> server component) and his client webapp invokes it. 
> 
> Now he wants the server component to run on Windows
> and AIX. Is there any way i can make use of exisiting
> C# code in AIX?
> 
> If not, can you give me some info/tips/URLs in
> rewriting
> the C# code onto C++?
> 
> 1. especially indexers
> for eg: public RouteSegment RouteSegment
> {
> get { return (RouteSegment)this[ROUTE_SEGMENT]; }
> set { this[ROUTE_SEGMENT] = value; }
> }
> 
> where this[] is implemented in a different .cs file
> and RouteSegment is a class (different .cs file) and
> ROUTE_SEGMENT is a public string const declared in a
> differnt .cs file
> 
> 2. Properties
> 
> Let me know whether there are any reference
> material/urls pertaining to C#->C++
> migration/compatibility
> 
> thanks
> Anand
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software
> http://sitebuilder.yahoo.com
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list