Raised This Month: $51 Target: $400
 12% 

Methodmap: Default parameters switching with value of "this"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
humbugtheman
Member
Join Date: Jan 2012
Old 03-07-2016 , 17:26   Methodmap: Default parameters switching with value of "this"
Reply With Quote #1

Can anyone point out if I'm doing something wrong? I swear this shouldn't be happening.
Basically...

* I have a function that returns a 'type' that I have defined in a methodmap.
* I use one of its methods on it.
* That method has a default parameter in it.
* If I leave that parameter blank, the values of "this" and the default parameter seem to switch.

PHP Code:
methodmap Calculator {
    
    public 
Calculator(int id){
        return 
view_as<Calculator>(id);
    }
    
    public 
int Add(int aint b 666){
        
PrintToServer("B = %i"b);
        
PrintToServer("CALC ID = %i"this);
        return 
b;
    }
}

public 
void OnPluginStart(){
    
Calculator(42).Add(23);
    
Calculator(42).Add(2);

Result:
HTML Code:
B = 3         // expected 3
CALC ID = 42  // expected 42
B = 42        // expected 666
CALC ID = 666 // expected 42
Please let me know if I'm being stupid. Otherwise I can report a bug. Thank you!

Last edited by humbugtheman; 03-07-2016 at 17:34.
humbugtheman is offline
BAILOPAN
Join Date: Jan 2004
Old 03-07-2016 , 17:35   Re: Methodmap: Default parameters switching with value of "this"
Reply With Quote #2

Are you compiling with the latest spcomp? This sounds like a bug, but we fixed a few like this already.
__________________
egg
BAILOPAN is offline
humbugtheman
Member
Join Date: Jan 2012
Old 03-07-2016 , 17:46   Re: Methodmap: Default parameters switching with value of "this"
Reply With Quote #3

Ok I switched to the dev branch and it's fixed there. Thank you very much! Loving using the transitional API.
humbugtheman is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode