Box2D Forums

It is currently Sun May 19, 2013 7:47 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Wanting to port.... C#
PostPosted: Thu Oct 11, 2007 1:42 pm 
Offline

Joined: Sat Sep 15, 2007 3:21 am
Posts: 15
Since the beginning of this, the directory structure of where code is has changed a lot... are you going to stabilize so I can make changes that can receive updates from svn? :)

I did attempt to compile it with /CLR enabled, and it worked well (after selecting Debug DLL instead of Debug static library, and some other minor compiler option)... so maybe I should just implement a public reference class of world and use that... but there's still a lot o structures and pointers which don't work well in the 'managed' world...


Top
 Profile  
 
PostPosted: Thu Oct 11, 2007 4:23 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
The directory structure should be quite stable. The current layout is based on feedback I got on this forum and everybody seems to be happy with it. If it's not broken, I won't fix it.

The reason I use static libraries is so that I can send binary executables to people without having to fish out the DLLs they might need. This is also why I am using Freeglut.

Yes, lots of pointers. They make programming exciting, don't they? ;)


Top
 Profile  
 
PostPosted: Thu Oct 11, 2007 11:09 pm 
Offline

Joined: Sun Sep 23, 2007 2:35 pm
Posts: 803
BTW, the pointers that Erin uses switch quite easily to references, since they usually point in a straightforward way to objects, and usually when they are not used in that way he just uses them for array traversal. Only once in a while does something come up where references can't do the same job (in one function, he uses the pointer to calculate the index in an array, which a reference can't accomplish). In Java, a pointer to a base type (like a float or int) is more of a problem, since there you can't have references to built in types. But Erin doesn't do this very much, so that's good! (I think maybe once in the whole project did he do this, and we just made it use an array instead of an int)

As far as structs, these in almost every case turn right into classes where all the members are public, with no problems. The only tricky thing was the one union that was used, which there is no analogue for in Java, I don't know about C# - in Java, making it an inner class was the right solution (that leaves the external interface to the class intact, too), so if you can do that in C#, that's probably the way to go.


Top
 Profile  
 
PostPosted: Fri Oct 12, 2007 2:31 pm 
Offline

Joined: Sat Sep 15, 2007 3:21 am
Posts: 15
Erin Catto wrote:
Yes, lots of pointers. They make programming exciting, don't they? ;)


Oh I totally concur :) For like 4 years I haven't used an array other than the occasional char[] for strings.


Top
 Profile  
 
PostPosted: Fri Oct 12, 2007 2:37 pm 
Offline

Joined: Sat Sep 15, 2007 3:21 am
Posts: 15
ewjordan wrote:
(in one function, he uses the pointer to calculate the index in an array, which a reference can't accomplish).


Neither can C#...


ewjordan wrote:
The only tricky thing was the one union that was used, which there is no analogue for in Java, I don't know about C#


Nope, no uniions in C# either..


Top
 Profile  
 
PostPosted: Fri Oct 19, 2007 11:27 am 
Offline

Joined: Sat Sep 15, 2007 3:21 am
Posts: 15
d3x0r wrote:

ewjordan wrote:
The only tricky thing was the one union that was used, which there is no analogue for in Java, I don't know about C#


Nope, no uniions in C# either..


Oh - just stumbled across something....

By using attributes you can customize how structs are laid out in memory. For example, you can create what's known as a union in C/C++ by using the StructLayout(LayoutKind.Explicit) and FieldOffset attributes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group