Author Topic: Summary of nonstandard extensions supported by ASC/NWNTX  (Read 835 times)

Legacy_SkywingvL

  • Full Member
  • ***
  • Posts: 115
  • Karma: +0/-0
Summary of nonstandard extensions supported by ASC/NWNTX
« on: June 28, 2011, 02:47:03 am »


               In extensions mode, the following nonstandard features are supported.  These are not supported on old PRC compiler builds or in the BioWare compiler, so their usage is only recommended if you are sure that you're not ever going to need to build your scripts with those compilers.

Note that if you are building scripts for NWN2, GUI scripts and dialog conditional scripts, and the chat script, are parsed by the server in source text form in some circumstances.  These scripts cannot use nonstandard extensions or they won't work properly.

- The compiler has limited preprocessor support for preprocessor macros.  Only basic text replacement is supported (no functionlike macros yet).  The syntax is a subset of the typical C syntax:

#define macro
#define macro replacement text
#undef macro

A warning is issued if you try and redefine a macro or try and undefine a built-in macro.

These built-in macros are available:

__FILE__ : Base filename of the current source file (without extension), as a quoted string.
__LINE__ : Base 10 integer representing the current line number in the current source file.
__DATE__ : Quoted string indicating the compile date.
__TIME__ : Quoted string indicating the compile time.
__NSC_COMPILER_DATE__ : Quoted string indicating the build date of the script compiler itself.
__NSC_COMPILER_TIME__ : Quoted string indicating the build time of the script compiler itself.
__COUNTER__ : Base 10 integer that starts at 0; each expansion of the macro expands to one plus the previous expansion.
__FUNCTION__ : Quoted string indicating the current function name (an error is generated if the macro is referenced outside of a function body).

- The compiler has limited conditional compilation support via preprocessor #ifdef.  The syntax is a subset of the usual C syntax (nesting of conditionals is supported):

#if text
#if defined macro-name
#ifdef macro-name
#ifndef macro-name
#else
#elif text
#endif

"text" must expand to a simple base 10 integer in order to be accepted by the preprocessor parser; expressions are unsupported.  If "text" references a macro that is defined to nothing, #if text assumes that the macro satisfies the conditional.  If "text" references an undefined macro, #if text assumes that the macro doesn't satisfy the conditional.  If "text" is not a macro and isn't a base 10 integer, a compile-time error diagnostic is issued.

- The compiler exposes a preprocessor pragma to declare a function as a "default function".  If a function is a default function, then it is legal to invoke the function without providing a body; in such a case the compiler substitutes a default body that throws away all arguments and returns the default value for any return values.  If a defaulted function is found to have a user supplied body, the user supplied body is used:

int function (int arg);
#pragma default_function(function) // must be after 'function' is prototyped and before 'function' is defined (defining 'function' is optional and must occur after it has been tagged as a default function)

- The compiler provides some built-in intrinsic functions (predefined by the compiler in extensions mode):

int __readrelativesp (); // Returns an integer indicating the relative stack depth in the current call frame.
int __readpc (); // Returns an integer indicating the value of the current program counter (instruction pointer).

- The compiler recognizes the "const" keyword (also enabled if BioWare-compatible version 1.69 is selected (ASC compiler plugin and NWNTX compiler plugin select version 1.69 by default).

Numerous improved error and warning diagnostics are available regardless of extensions mode.  The compiler documentation in the ASC distribution has a detailed list of these.
               
               

               


                     Modifié par SkywingvL, 28 juin 2011 - 01:57 .