IronRuby and XNA. Super and Generics

Hi guys!

Im playing with XNA trying to run the simplest xna example: To show a
SpriteBatch on screen.

After some tests I found some problems:

1- The “Microsoft::Xna::Framework::Game” expects that we implement
some methods like “Update”, “Drawn” etc, and inside the method we have
to call the base class (super) actual method passing some parameters.

If I try to do this:

def update(game_time)
  super(game_time)
end

I get this error:

my_game.rb:23:in update': wrong number or type of arguments forupdate’ (ArgumentError)
from Snippets.scripting:0:in Update' from Microsoft.Xna.Framework.Game:0:inRun’
from program.rb:23:in `main’
from :0

2- XNA uses generic functions to load the game contents. How can I
convert the code above to IronRuby?

// This is a texture we can render.
Texture2D myTexture;

protected override void LoadContent()
{
myTexture = Content.Load(“mytexture”);
}

Can IronRuby consume generics?

Thanks!

We can’t consume generic methods today. It’s on the list of things to do
though.

You can work around this by defining a concrete method in C# that calls
the appropriate generic method and call the concrete method from
IronRuby.

Thanks,
-John

For the first problem, does it work if you just use “super” without any
arguments?

Hi Curt!

Unfortunatelly it does not work. The error returned is the same. :frowning:

2008/11/26 Curt H. [email protected]:

Thanks John!

I will do that.

Just for curiosity, what will be the syntax to call generic methods? :slight_smile:

2008/11/26 John L. (IRONRUBY) [email protected]:

On Wed, Nov 26, 2008 at 12:04 PM, Tomas M. <
[email protected]> wrote:

I’m thinking of something like:

myTexture = content.load of(Texture2D), “mytexture”

I.e. we would add Kernel#of method that takes a list of classes/modules and
returns a special object representing generic parameters that binder would
use for selecting the right method.

We are open for more ideas.

Couldn’t you just send in the constant? What would the Kernel#of method
do
for you?

myTexture = content.load Texture2D, “mytexture”

Or, could you use method_missing?

myTexture = content.load_Texture2D “mytexture”

Tomas

I’m thinking of something like:

myTexture = content.load of(Texture2D), “mytexture”

I.e. we would add Kernel#of method that takes a list of classes/modules
and returns a special object representing generic parameters that binder
would use for selecting the right method.

We are open for more ideas.

Tomas

What if the method has signature m(object x, … T…). How do we
know you don’t want to pass the value of constant Texture2D as x? “of”
would wrap it into an internal class that would be known as carrying
generic parameter types and always unwrapped.

load_Texture2D clashes with name mangling and is not composable. What if
you want to call method with parameter Dictionary<string, List>?
With “of” you would do:

load of(Dictionary.of(System::String, List.of(Object))

Tomas

From: [email protected]
[mailto:[email protected]] On Behalf Of Mike M.
Sent: Wednesday, November 26, 2008 12:02 PM
To: [email protected]
Subject: Re: [Ironruby-core] IronRuby and XNA. Super and Generics

On Wed, Nov 26, 2008 at 12:04 PM, Tomas M.
<[email protected]mailto:[email protected]>
wrote:
I’m thinking of something like:

myTexture = content.load of(Texture2D), “mytexture”

I.e. we would add Kernel#of method that takes a list of classes/modules
and returns a special object representing generic parameters that binder
would use for selecting the right method.

We are open for more ideas.

Couldn’t you just send in the constant? What would the Kernel#of method
do for you?

myTexture = content.load Texture2D, “mytexture”

Or, could you use method_missing?

myTexture = content.load_Texture2D “mytexture”

Tomas


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core


Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core