This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
nergal
Veteran Member
Join Date: Apr 2012
Old 10-31-2014 , 15:19   Re: New API and Syntax
Reply With Quote #131

Is there anything regarding Natives and Forwards with the new API and syntax?

What about the old native rule where you can't return a float? Do they still require the _: empty tag to return a float?
__________________
nergal is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-31-2014 , 17:16   Re: New API and Syntax
Reply With Quote #132

Should I assume it's not possible to have a char[] property at the moment, seeing as how they have a different syntax for get than other types?
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 10-31-2014 , 17:38   Re: New API and Syntax
Reply With Quote #133

Quote:
Originally Posted by nergal View Post
Is there anything regarding Natives and Forwards with the new API and syntax?

What about the old native rule where you can't return a float? Do they still require the _: empty tag to return a float?
Reposting it doesn't make either of your questions make any more sense.
__________________
asherkin is offline
BAILOPAN
Join Date: Jan 2004
Old 10-31-2014 , 18:23   Re: New API and Syntax
Reply With Quote #134

@nergal: I don't understand the first question, so the answer is probably "no". The second question is a non-sequitur, there has never been a rule that natives can't return floats. You might be referring to the fact that some natives (like GetArrayCell) have untyped returns, which is something we did mostly for own convenience (rather than have GetArrayInt, GetArrayFloat, etc). It's not great, certainly.

@Powerlord: I don't understand what you mean by "different syntax". The syntax for type-expression parsing is fairly well-formed, it's just that the types on the get/set methods are chosen for you, so you don't get to specify them again. In the getter case, it's the type-expr of the property, in the setter case, the return type is void. But, natives cannot return arrays yet, so it would be difficult to construct a useful property getter that returns an array. I think you could probably do a setter though.

Also note that even though setters return void, that doesn't affect assign-exprs. For example, (x = (a.b = c)), if |a.b| is a setter (therefore returning void), the result of the assignment expression is always |c|. So I actually have no idea what would happen if you did that with an array-setter the compiler's handling of arrays is fairly tricky.
__________________
egg

Last edited by BAILOPAN; 10-31-2014 at 18:26.
BAILOPAN is offline
nergal
Veteran Member
Join Date: Apr 2012
Old 10-31-2014 , 18:47   Re: New API and Syntax
Reply With Quote #135

Quote:
Originally Posted by asherkin View Post
Reposting it doesn't make either of your questions make any more sense.
Will the natives and/or forwards system get a make over in the transitional API?

Also, will natives, that are supposed to return floats, require the _: empty tag like with the old Syntax and API?

Like this
PHP Code:
new Float:DamageResistance[MAXPLAYERS+1];
public 
Native_GetArmorDamageResistance(Handle:pluginnumParams

    return 
_:DamageResistance[GetNativeCell(1)]; 

__________________

Last edited by nergal; 10-31-2014 at 18:50.
nergal is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 10-31-2014 , 19:14   Re: New API and Syntax
Reply With Quote #136

In addition to what nergal said, is there any chance that we'll be able to return Strings instead of modifying the arrays that were passed to the native/function?
eg `someString=ThisReturnsAString();` vs `ThisReturnsAString(someString, sizeof(someString));`
__________________
~Wliu
Wliu is offline
BAILOPAN
Join Date: Jan 2004
Old 10-31-2014 , 19:24   Re: New API and Syntax
Reply With Quote #137

No, nothing about that is changing. Everything in functions.inc is the result of fundamental design flaws in the Pawn VM, so it's unlikely anything syntactically significant will happen to it. With any luck Pawn will eventually be at a point where all of the gross native/fn invocation gunk can go away.

The fundamental reason is that Pawn plugins are sandboxed because the underlying VM has no way to identify memory bounds on arrays (and therefore you could go out-of-bounds and corrupt memory outside the plugin). When calling from one plugin into another, the memory has to be copied and translated into the destination plugin's address space for it to be readable. If we can put bounds on arrays and unify address spaces, we can remove that restriction, and functions.inc would be obsolete.

It's a long road to get there (we need a new binary format), but that's what I'm looking toward.
__________________
egg

Last edited by BAILOPAN; 10-31-2014 at 19:27.
BAILOPAN is offline
BAILOPAN
Join Date: Jan 2004
Old 10-31-2014 , 19:31   Re: New API and Syntax
Reply With Quote #138

@Wliu - I just realized I could actually get this working, but for natives only (edit). If that seems okay, file a bug.
__________________
egg

Last edited by BAILOPAN; 10-31-2014 at 19:35.
BAILOPAN is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 10-31-2014 , 20:09   Re: New API and Syntax
Reply With Quote #139

Quote:
Originally Posted by BAILOPAN View Post
@Powerlord: I don't understand what you mean by "different syntax". The syntax for type-expression parsing is fairly well-formed, it's just that the types on the get/set methods are chosen for you, so you don't get to specify them again. In the getter case, it's the type-expr of the property, in the setter case, the return type is void. But, natives cannot return arrays yet, so it would be difficult to construct a useful property getter that returns an array. I think you could probably do a setter though.
By different syntax, I mean this:
Quote:
Originally Posted by Wliu View Post
Code:
ThisReturnsAString(someString, sizeof(someString));
...which is different from normal getters, which would just return the value.

(Incidentally, Wilu, this is BBCode not Markdown)
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 10-31-2014 at 20:10.
Powerlord is offline
BAILOPAN
Join Date: Jan 2004
Old 10-31-2014 , 20:38   Re: New API and Syntax
Reply With Quote #140

@Powerlord: Not sure what you're asking then, but yes given that the prototype of a getter must be a function that takes a single "this" parameter and returns a non-void type, that would not qualify as a valid getter.
__________________
egg
BAILOPAN 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 22:20.


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