View Single Post
Thrawn2
Veteran Member
Join Date: Apr 2009
Old 07-17-2014 , 12:54   Re: New API and Syntax
Reply With Quote #28

Quote:
Originally Posted by BAILOPAN View Post
I forgot to mention it in the first post, but there's a new constant you can use, null, which is way easier to type. It should cast to any Handles or anything inheriting from Handle. INVALID_HANDLE should work too though if you still want to use it - if it doesn't, send me the code and I can take a look.
Neat.

Using INVALID_HANDLE does work if I cast the methodmap to a Handle first, null on the other hand does only work if i cast it to the corresponding object type.

E.g. this does not work unless the comparison is: f != StringMap:null
Code:
#include <sourcemod>

public OnPluginStart() {
	StringMap f = StringMap();

	LogMessage("StringMap is not null? %d", f != null);
}
Without the cast it results in:
sm17.test.sp(6) : error 132: cannot coerce non-object type StringMap to object type null_t

Is there a way to avoid tagging of null or the other value altogether?

Also more questions if you don't mind:
  • "any", while quite hacky was also quite useful. E.g. the old tests include used by smjansson had a method Tests_Is(any:a, any:b) which compared a to b. This worked with int, float, handle, i.e. you could throw anything at it. How would one specify an any: parameter in the new syntax?
  • Will there be the possibility to define multiple constructors with a different set of parameters?
  • When exactly is the destructor being called? When I delete the object and before the "old" CloseHandle is being performed?

And one bug report: it is possible to crash the compiler by using delete instead of CloseHandle.
It is easily reproducible by changing line 1013 of the previously linked smjansson include to use delete and trying to compile the test plugin that comes with it. Sorry for not having a smaller and more specific testcase for this.

Thanks!

Edit: The wiki says:
Quote:
Currently only "get" accessors are available.
Is this accurate? The menus include is using property setters.
__________________
einmal mit profis arbeiten. einmal.

Last edited by Thrawn2; 07-17-2014 at 13:04.
Thrawn2 is offline