IronRuby and XNA. Super and Generics


#1

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!


#2

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


#3

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


#4

Hi Curt!

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

2008/11/26 Curt H. removed_email_address@domain.invalid:


#5

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) removed_email_address@domain.invalid:


#6

On Wed, Nov 26, 2008 at 12:04 PM, Tomas M. <
removed_email_address@domain.invalid> 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


#7

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


#8

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: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Mike M.
Sent: Wednesday, November 26, 2008 12:02 PM
To: removed_email_address@domain.invalid
Subject: Re: [Ironruby-core] IronRuby and XNA. Super and Generics

On Wed, Nov 26, 2008 at 12:04 PM, Tomas M.
<removed_email_address@domain.invalidmailto:removed_email_address@domain.invalid>
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


#9

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#10

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#11

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#12

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#13

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#14

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#15

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#16

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#17

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#18

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#19

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core


#20

Ironruby-core mailing list
removed_email_address@domain.invalid
http://rubyforge.org/mailman/listinfo/ironruby-core