Raised This Month: $32 Target: $400
 8% 

New API and Syntax


Post New Thread Reply   
 
Thread Tools Display Modes
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 11-07-2014 , 15:41   Re: New API and Syntax
Reply With Quote #151

Quote:
Originally Posted by BAILOPAN View Post
Pawn's tag comparison assumes left -> right coercion, so some things are a bit wonky. I bet if you change the order of the compare it'll work. Anyway, sounds like a valid bug, but there is now a null keyword that replaces INVALID_HANDLE that is a much nicer choice.
Useful to know. I'll have to change INVALID_HANDLE to that when I go back to replace CloseHandle with delete ('cause I forgot to do that on my first pass through mapchooser).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 11-07-2014 , 17:41   Re: New API and Syntax
Reply With Quote #152

Quote:
Originally Posted by BAILOPAN View Post
// Before:
public OnReceivedString(const String:name[], Float:fval);

// After:
public void OnReceivedString(const char[] name, float fval);

// Before:
new HandlelayerHandles[MAXPLAYERS + 1];

// After:
Handle PlayerHandles[MAXPLAYERS + 1];
I see you changed "Float" to "float", will you change "Handle" to "handle" ? Cause I see Handle in this post and it would be nice to have everything the same way.
KissLick is offline
BAILOPAN
Join Date: Jan 2004
Old 11-08-2014 , 05:57   Re: New API and Syntax
Reply With Quote #153

Handles will probably stay uppercase... if anything, I'm sure there is code out there that declares `Handle handle;` and it would break once we merge the type and symbol namespaces together.

The lowercase stuff is intended for core builtin types.
__________________
egg
BAILOPAN is offline
BAILOPAN
Join Date: Jan 2004
Old 11-08-2014 , 17:35   Re: New API and Syntax
Reply With Quote #154

Hi All - I have some breaking changes to the transitional syntax. These should be the final breaking changes.

The position of brackets on a new-style declaration is now very important. When brackets occur after the name, they now indicate a fixed-length array, and require either an array initializer or constant sizes specified in every dimension.

If the brackets are before the name (between the name and type), they now specify an indeterminate/dynamic array - no fixed size may be specified, and an array initializer is not allowed (though that last restriction may change).

Finally, sizeof on an indeterminate array is now an error instead of a warning.

What does this mean? Here are some examples to show all the common transformations:
Code:
stock GetProperty(const String:name[], String:buffer[]) {   const String:PROP_PREFIX[] = "prop";   new new_name_size = sizeof(PROP_PREFIX) + strlen(name) + 1;   new String:new_name[new_buffer_size];   Format(new_name, new_name_size, "%s_%s", PROP_PREFIX, name);   ... }

In new-style syntax, this will now look like:
Code:
void GetProperty(const char[] name, char[] buffer) {   const char PROP_PREFIX[] = "prop";     int new_name_size = sizeof(PROP_PREFIX) + strlen(name) + 1;   char[] new_name = new char[new_name_size];   Format(new_name, new_name_size, "%s_%s", PROP_PREFIX, name); }

The major takeaway: brackets-after-name, must be fixed size; brackets-before-name, must be dynamic size. Code that specifies new-style arrays with trailing brackets, but no size, or a dynamic size, will no longer compile.

Full documentation and rationale here: https://wiki.alliedmods.net/SourcePa..._Syntax#Arrays
__________________
egg

Last edited by BAILOPAN; 11-08-2014 at 17:37.
BAILOPAN is offline
ElooKoN
        ^_^
Join Date: Apr 2011
Old 11-11-2014 , 02:01   Re: New API and Syntax
Reply With Quote #155

Quote:
Originally Posted by BAILOPAN View Post
It's verboten [...]
You speak german!

I like the syntax of SourcePawn because I primarily use C++, Python and PHP, so it is a way of variety for me. Nonetheless I think your changes are great.

So I want to say thank you to you and the team for this awesome work!
ElooKoN is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 11-11-2014 , 15:21   Re: New API and Syntax
Reply With Quote #156

I know it's kind of offtopic... But, will you add something like Socket or cURL & Hash to the new API?
KissLick is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 11-11-2014 , 15:38   Re: New API and Syntax
Reply With Quote #157

some one should make a wrapper for SMLib

on that note (might have missed this)
making stock functions to be used, but not pulled into the main file using #include, is it possible with a methodmap?
I do see https://wiki.alliedmods.net/SourcePa...ax#Inheritance

I'll start playing with this

Last edited by Mitchell; 11-11-2014 at 15:42.
Mitchell is offline
BAILOPAN
Join Date: Jan 2004
Old 11-11-2014 , 20:59   Re: New API and Syntax
Reply With Quote #158

@ElooKoN Glad you like it!

Quote:
Originally Posted by KissLick View Post
I know it's kind of offtopic... But, will you add something like Socket or cURL & Hash to the new API?
I've got a replacement for sockets in the works in my personal GitHub, but I'm a little nervous about ramming it into SM. Maybe it'll make it for 1.8 or 1.9. Here's a sketch of what the low-level API looks like: http://users.alliedmods.net/~dvander/amio.inc

@Mitchell Sorry, I don't fully understand the question. If you mean that methodmaps help with namespacing - yeah, that's definitely true. You can simulate namespaces and static classes with them.
__________________
egg
BAILOPAN is offline
Mathias.
Veteran Member
Join Date: Aug 2010
Location: Canada is my city
Old 11-12-2014 , 18:29   Re: New API and Syntax
Reply With Quote #159

Would be really really appreciated to have a stable socket official sourcemod support.
Mathias. is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 11-13-2014 , 09:34   Re: New API and Syntax
Reply With Quote #160

Quote:
Originally Posted by Black-Rabbit View Post
Would be really really appreciated to have a stable socket official sourcemod support.
Yeah, I second that motion.
KissLick 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 15:59.


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