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

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
BAILOPAN
Join Date: Jan 2004
Old 08-24-2016 , 16:20   Re: New API and Syntax
Reply With Quote #761

Emp's solution is good.
__________________
egg
BAILOPAN is offline
R1KO
Member
Join Date: Sep 2013
Old 09-01-2016 , 15:16   Re: New API and Syntax
Reply With Quote #762

PHP Code:
enum Types:
{
    
INVALID_TYPE 0,
}

methodmap Types
{
    public 
Types()
    {
        return 
view_as<Types>(5);

    
//        return INVALID_TYPE;
    
}

    public 
void Remove()
    {
        
// * how to assign a value INVALID_TYPE  to this?
    
}
}

public 
void OnPluginStart()
{
    
Types Type = new Types();    // why ? error 171: cannot use 'new' with non-object-like methodmap 'Types'
    
Types Type Types();
    
    
Type.Remove();    // * how to assign a value INVALID_TYPE to a Type in the method Remove


and when the value of the index variable "this"?
And then he writes
PHP Code:
LogMessage("this.Index: %i"this.Index); 
Quote:
error 105: cannot find method or property Types.Index

Last edited by R1KO; 09-01-2016 at 15:37.
R1KO is offline
Send a message via Skype™ to R1KO
nergal
Veteran Member
Join Date: Apr 2012
Old 09-01-2016 , 17:24   Re: New API and Syntax
Reply With Quote #763

Quote:
Originally Posted by BAILOPAN View Post
Emp's solution is good.
it works but I'm lazy and #define SPNULL view_as< any >(0)
works as "one size fits all"
__________________
nergal is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-01-2016 , 17:55   Re: New API and Syntax
Reply With Quote #764

Not every type's invalid state is represented by 0 for sure, so it may not work in some cases.
klippy is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 09-01-2016 , 19:45   Re: New API and Syntax
Reply With Quote #765

Quote:
Originally Posted by KliPPy View Post
Not every type's invalid state is represented by 0 for sure, so it may not work in some cases.
well I know a float's invalid state is NaN but that's not what this is for, same with strings.

the purpose of it is for client-based methodmaps.
__________________
nergal is offline
BAILOPAN
Join Date: Jan 2004
Old 09-02-2016 , 15:54   Re: New API and Syntax
Reply With Quote #766

"any" should not be a valid input to "view_as".
__________________
egg
BAILOPAN is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 09-02-2016 , 18:21   Re: New API and Syntax
Reply With Quote #767

Just make an IsValid property do the work.
__________________
Neuro Toxin is offline
R1KO
Member
Join Date: Sep 2013
Old 09-03-2016 , 13:47   Re: New API and Syntax
Reply With Quote #768

up https://forums.alliedmods.net/showpo...&postcount=762
R1KO is offline
Send a message via Skype™ to R1KO
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 09-03-2016 , 14:14   Re: New API and Syntax
Reply With Quote #769

Quote:
Originally Posted by R1KO View Post
and when the value of the index variable "this"?
And then he writes
PHP Code:
LogMessage("this.Index: %i"this.Index); 
PHP Code:
    property int Int { public get() { return view_as int > ( this ); }
    } 
or
PHP Code:
    property int Index { public get() { return view_as int > ( this ); }
    } 
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 09-05-2016 , 12:31   Re: New API and Syntax
Reply With Quote #770

Can we get inline stock support one of these days? Declare a stock function as inline and then have the compiler paste its contents right into the body of the code. I am usually hesitant to use stocks unless it really gives a code readability boost because having stocks willy nilly everywhere will amount to considerable stack creation overhead. The JIT C++ file uses inline functions almost everywhere, for example.

A prototype like:

PHP Code:
stock inline int MyFunction(int params
Or make it its own thing (separate from stock functions) like:

PHP Code:
inline int MyFunction(int params
Spoiler

Last edited by Potato Uno; 09-05-2016 at 12:33.
Potato Uno is offline
Reply


Thread Tools
Display Modes

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 09:45.


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