You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some specifiers like writeonly and others are described in ScriptKeywords, but attribute, builtin and static are missing there. I added some notes below
attribute
The attribute keyword can be used like
struct A {
import attribute int value;
import int get_value(); // $AUTOCOMPLETEIGNORE$
import void set_value(int value); // $AUTOCOMPLETEIGNORE$
};
builtin
We use builtin to prevent a managed struct to be created without a factory method or other method, that is usually in the Engine or in a Plugin.
IDEA I noticed it would be nice to be able to restrict to only factory method when it's outside the script unit (not in the asc/ash pair that contains the struct), because them we could also use this in script modules.
static
used together with things that can be imported in a struct, to specify you can call it without requiring an instance of the object. You can restrict it to appear only in the static variant of the auto-complete with a special comment.
managed struct B {
import static B* Create(); // $AUTOCOMPLETESTATICONLY$
int magic;
}
The text was updated successfully, but these errors were encountered:
IDEA I noticed it would be nice to be able to restrict to only factory method when it's outside the script unit (not in the asc/ash pair that contains the struct), because them we could also use this in script modules.
AGS currently does not have a strict concept of "script unit", in theory any header (and even other src) may be included into any script. This is especially going to be a problem with standalone compiler, which does not know anything about the project structure and ash/asc pairing.
Restricting to factory methods could be done using private constructors, if AGS supported constructors.
Ah, ok. I noticed this when testing the PR on pointers in managed structs, that I wanted a factory Create() static method in my managed struct, as the only way to create them, to make sure the fields that were pointers to other structs to also be initialized. This saves me from checking for null when using it's members.
This saves me from checking for null when using it's members.
Perhaps you could mark them as writeprotected, and assume they are always set? This may cause module user to get errors if they use new, but they will remember eventually, and there will be less checks in code.
Some specifiers like writeonly and others are described in ScriptKeywords, but
attribute
,builtin
andstatic
are missing there. I added some notes belowattribute
The
attribute
keyword can be used likebuiltin
We use
builtin
to prevent a managed struct to be created without a factory method or other method, that is usually in the Engine or in a Plugin.IDEA I noticed it would be nice to be able to restrict to only factory method when it's outside the script unit (not in the asc/ash pair that contains the struct), because them we could also use this in script modules.
static
used together with things that can be imported in a struct, to specify you can call it without requiring an instance of the object. You can restrict it to appear only in the static variant of the auto-complete with a special comment.
The text was updated successfully, but these errors were encountered: