any suggestion for importing external generic method

About Monkey 2 Forums Monkey 2 Programming Help any suggestion for importing external generic method

This topic contains 4 replies, has 2 voices, and was last updated by  Mark Sibly 1 year, 9 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #9054

    abakobo
    Participant

    I’d like to finish the box2d modules and for that I only need to import some generic methods (from non generic struct).

    The only thing missing then would be operators. I’ve seen that operators are not possible for now but I saw that it was almost ok in the output cpp file (just to say it). And after all, operators are an mx2 feature too.. So it would be great if we could import them (in my test the +cpp just had some postfix member operator and brackets to be removed and it compiled ok).

    …But this topic is about external generic methods!

    This is a method (Query) that I’d like to be able to call from mx2:

    [/crayon]

    I made simplified test to see how it could be imported. The global function with generics could be imported without problem and the passing by ref if OK! but the method was not…

    test.monkey2

    [/crayon]

    v2.h

    [/crayon]

    if I uncomment the line with MSwap I get this error:

    [/crayon]

    any suggestion on how to deal with that T* method?

    It’s fun to see that it has 3 parameters instead of 2 and that the additional parameter is actualy the instance that has the scope. So everything seem to be there but not well placed?!

    #9060

    abakobo
    Participant

    I just saw in the docs commit of yesterday that extern generic functions can not be imported. Global extern generic functions I tested did work though..

    #9093

    Mark Sibly
    Keymaster

    I am VERY uncomfortable with attempting to support this (and ‘native’ operator overloading) for the simple reason I can’t guarantee it’ll work reliably all of the time without giving ‘weird’ results. In fact, I know it wont.

    The main reason for this is that monkey2 doesn’t actually use native c++ generics or operator overloading when translating monkey2 code so they actually don’t work identically to c++’s. There are things you can do with monkey2 operators/generics that you CAN’T do in c++ because of this – and of course vice versa.

    So sorry, but the current official line is ‘no native generics/operators’ (even if it’s not fully enforced yet) as I don’t want to have to support c++ generics/operators on top of having to support monkey2 generics/operators, if you see what I mean.

    As for box2d, I believe there are existing wrappers around that don’t use generics (objc? bmx? monkeyx?) so it should at least be possible (if not as easy).

    #9108

    abakobo
    Participant

    Ok thanks for the info. Just wanted it to be as identical as possible to original box2D. Will wrap it around then. Don’t know what to do with generics global function though, because they actualy work, so I think I’ll keep them like that until(if) a problem occurs..

    #9112

    Mark Sibly
    Keymaster

    Don’t know what to do with generics global function though

    What do other wrappers do? I would recommend NOT leaving them as is though as I may prohibit extern generics altogether soon to prevent any confusion.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.