This reference page is linked to from the following overview topics: MAXScript Compiler and Interpreter, Local Variables in MAXScript Exposed Functions, MAXScript Functions with Optional Arguments, Local Value Arrays.
#include
"../kernel/MAXScript_TLS.h"
#include "../../assert1.h"
Defines |
|
#define | one_value_local(n1) |
#define | one_typed_value_local(n1) |
#define | two_value_locals(n1, n2) |
#define | two_typed_value_locals(n1, n2) |
#define | three_value_locals(n1, n2, n3) |
#define | three_typed_value_locals(n1, n2, n3) |
#define | four_value_locals(n1, n2, n3, n4) |
#define | four_typed_value_locals(n1, n2, n3, n4) |
#define | five_value_locals(n1, n2, n3, n4, n5) |
#define | five_typed_value_locals(n1, n2, n3, n4, n5) |
#define | six_value_locals(n1, n2, n3, n4, n5, n6) |
#define | six_typed_value_locals(n1, n2, n3, n4, n5, n6) |
#define | seven_value_locals(n1, n2, n3, n4, n5, n6, n7) |
#define | seven_typed_value_locals(n1, n2, n3, n4, n5, n6, n7) |
#define | eight_value_locals(n1, n2, n3, n4, n5, n6, n7, n8) |
#define | eight_typed_value_locals(n1, n2, n3, n4, n5, n6, n7, n8) |
#define | nine_value_locals(n1, n2, n3, n4, n5, n6, n7, n8, n9) |
#define | nine_typed_value_locals(n1, n2, n3, n4, n5, n6, n7, n8, n9) |
#define | ten_value_locals(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) |
#define | ten_typed_value_locals(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) |
#define | eleven_value_locals(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11) |
#define | eleven_typed_value_locals(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11) |
#define | value_local_array(var, count) |
#define | pop_value_local_array(var) thread_local(current_locals_frame) = (Value**)var[-1]; |
#define | value_temp_array(var, count) |
#define | value_temp_array0(var) |
#define | realloc_value_temp_array(var, count, old_count) |
#define | pop_value_temp_array(var) |
#define | return_value(r) { return templated_return_value_fn(r, vl.link); } |
#define | return_value_no_pop(r) { return templated_return_protected_fn(r); } |
#define | return_protected(r) { return templated_return_protected_fn(r); } |
#define | pop_value_locals() thread_local(current_locals_frame) = vl.link; |
#define | reset_locals_frame() thread_local(current_locals_frame) = (Value**)&vl; |
#define | reset_locals_array_frame(var) thread_local(current_locals_frame) = &var[-2]; |
#define | clear_current_frames() |
#define | save_current_frames() |
#define | restore_current_frames() |
#define | save_current_source() |
#define | restore_current_source() |
#define | save_current_source_no_pos() |
#define | restore_current_source_no_pos() |
#define | save_current_source_pos() |
#define | restore_current_source_pos() |
#define | save_current_source_to_frame() |
#define | save_current_source_to_frame_no_pos() |
#define | save_current_source_to_frame_pos() |
#define | save_current_source_to_frame_no_file() |
#define | push_control(_c) |
#define | pop_control() thread_local(current_controller) = _save_cc; |
#define | save_error_source_data() |
#define | clear_error_source_data() |
Functions |
|
template<typename Type > | |
Type | templated_return_value_fn (Type r, Value **link) |
template<typename Type > | |
Type | templated_return_protected_fn (Type r) |
#define one_value_local | ( | n1 | ) |
struct { int count; Value** link; Value* n1; } vl = \ { 1, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define one_typed_value_local | ( | n1 | ) |
struct { int count; Value** link; n1; } vl = \ { 1, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define two_value_locals | ( | n1, | |
n2 | |||
) |
struct { int count; Value** link; Value *n1, *n2; } vl = \ { 2, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define two_typed_value_locals | ( | n1, | |
n2 | |||
) |
struct { int count; Value** link; n1; n2; } vl = \ { 2, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define three_value_locals | ( | n1, | |
n2, | |||
n3 | |||
) |
struct { int count; Value** link; Value *n1, *n2, *n3; } vl = \ { 3, NULL, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define three_typed_value_locals | ( | n1, | |
n2, | |||
n3 | |||
) |
struct { int count; Value** link; n1; n2; n3; } vl = \ { 3, NULL, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define four_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4 | |||
) |
struct { int count; Value** link; Value *n1, *n2, *n3, *n4; } vl = \ { 4, NULL, NULL, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define four_typed_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4 | |||
) |
struct { int count; Value** link; n1; n2; n3; n4; } vl = \ { 4, NULL, NULL, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define five_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5 | |||
) |
struct { int count; Value** link; Value *n1, *n2, *n3, *n4, *n5; } vl = \ { 5, NULL, NULL, NULL, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define five_typed_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5 | |||
) |
struct { int count; Value** link; n1; n2; n3; n4; n5; } vl = \ { 5, NULL, NULL, NULL, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define six_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6 | |||
) |
#define six_typed_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6 | |||
) |
struct { int count; Value** link; n1; n2; n3; n4; n5; n6; } vl = \ { 6, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; \ vl.link = thread_local(current_locals_frame); \ thread_local(current_locals_frame) = (Value**)&vl;
#define seven_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7 | |||
) |
#define seven_typed_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7 | |||
) |
#define eight_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7, | |||
n8 | |||
) |
#define eight_typed_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7, | |||
n8 | |||
) |
#define nine_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7, | |||
n8, | |||
n9 | |||
) |
#define nine_typed_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7, | |||
n8, | |||
n9 | |||
) |
#define ten_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7, | |||
n8, | |||
n9, | |||
n10 | |||
) |
#define ten_typed_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7, | |||
n8, | |||
n9, | |||
n10 | |||
) |
#define eleven_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7, | |||
n8, | |||
n9, | |||
n10, | |||
n11 | |||
) |
#define eleven_typed_value_locals | ( | n1, | |
n2, | |||
n3, | |||
n4, | |||
n5, | |||
n6, | |||
n7, | |||
n8, | |||
n9, | |||
n10, | |||
n11 | |||
) |
#define value_local_array | ( | var, | |
count | |||
) |
{ \ var = &((Value**)_alloca(((count) + 2) * sizeof(Value*)))[2]; \ memset(var, 0, (count) * sizeof(Value*)); \ var[-2] = (Value*)(static_cast<INT_PTR>(count)); \ var[-1] = (Value*)thread_local(current_locals_frame); \ thread_local(current_locals_frame) = &var[-2]; }
#define pop_value_local_array | ( | var | ) | thread_local(current_locals_frame) = (Value**)var[-1]; |
#define value_temp_array | ( | var, | |
count | |||
) |
{ \ var = &((Value**)ms_malloc(((count) + 2) * sizeof(Value*)))[2]; \ memset(var, 0, (count) * sizeof(Value*)); \ var[-2] = (Value*)(static_cast<INT_PTR>(count)); \ var[-1] = (Value*)thread_local(current_locals_frame); \ thread_local(current_locals_frame) = &var[-2];}
#define value_temp_array0 | ( | var | ) |
{ \ var = &((Value**)ms_malloc(2 * sizeof(Value*)))[2]; \ var[-2] = 0; \ var[-1] = (Value*)thread_local(current_locals_frame); \ thread_local(current_locals_frame) = &var[-2];}
#define realloc_value_temp_array | ( | var, | |
count, | |||
old_count | |||
) |
{ \ Value **oldPointer = &var[-2]; \ Value **sframe = thread_local(current_locals_frame); \ var = &((Value**)ms_realloc(&var[-2], ((count) + 2) * sizeof(Value*)))[2]; \ if ((count) > (old_count)) \ memset(&var[(old_count)], 0, ((count) - (old_count)) * sizeof(Value*)); \ var[-2] = (Value*)(static_cast<INT_PTR>(count)); \ Value **newPointer = &var[-2]; \ if (sframe == oldPointer) \ { thread_local(current_locals_frame) = newPointer; \ DbgAssert( newPointer != (Value**)newPointer[1] ); \ } \ else \ { Value **frame; \ for (frame = sframe; frame && (Value**)frame[1] != oldPointer && frame != (Value**)frame[1]; frame = (Value**)frame[1]); \ if (frame) { \ DbgAssert( frame != (Value**)frame[1] ); \ frame[1] = (Value*)newPointer; \ } \ } \ }
#define pop_value_temp_array | ( | var | ) |
{ \ Value **oldPointer = &var[-2]; \ /* Value **sframe = thread_local(current_locals_frame); */ \ Value **head = (Value**)var[-1]; \ thread_local(current_locals_frame) = head; \ ms_free(oldPointer); \ }
#define return_value | ( | r | ) | { return templated_return_value_fn(r, vl.link); } |
#define return_value_no_pop | ( | r | ) | { return templated_return_protected_fn(r); } |
#define return_protected | ( | r | ) | { return templated_return_protected_fn(r); } |
#define pop_value_locals | ( | ) | thread_local(current_locals_frame) = vl.link; |
#define reset_locals_frame | ( | ) | thread_local(current_locals_frame) = (Value**)&vl; |
#define reset_locals_array_frame | ( | var | ) | thread_local(current_locals_frame) = &var[-2]; |
#define clear_current_frames | ( | ) |
{ \ thread_local(current_locals_frame) = NULL; \ thread_local(current_frame) = NULL;}
#define save_current_frames | ( | ) |
Value** _sclf = thread_local(current_locals_frame); \ Value** _scsf = thread_local(current_scan_frame); \ Value** _scf = thread_local(current_frame);
#define restore_current_frames | ( | ) |
{ \ thread_local(current_locals_frame) = _sclf; \ thread_local(current_scan_frame) = _scsf; \ thread_local(current_frame) = _scf;}
#define save_current_source | ( | ) |
Value* _save_source = thread_local(source_file); \ MSZipPackage* _save_pkg = thread_local(current_pkg); \ unsigned int _save_pos = thread_local(source_pos); \ unsigned int _save_line = thread_local(source_line); \ DWORD _save_flags = thread_local(source_flags);
#define restore_current_source | ( | ) |
{ \ thread_local(source_file) = _save_source; \ thread_local(current_pkg) = _save_pkg; \ thread_local(source_pos) = _save_pos; \ thread_local(source_line) = _save_line; \ thread_local(source_flags) = _save_flags;}
#define save_current_source_no_pos | ( | ) |
Value* _save_source = thread_local(source_file); \ MSZipPackage* _save_pkg = thread_local(current_pkg); \ DWORD _save_flags = thread_local(source_flags);
#define restore_current_source_no_pos | ( | ) |
{ \ thread_local(source_file) = _save_source; \ thread_local(current_pkg) = _save_pkg; \ thread_local(source_flags) = _save_flags;}
#define save_current_source_pos | ( | ) |
unsigned int _save_pos = thread_local(source_pos); \ unsigned int _save_line = thread_local(source_line); \ DWORD _save_flags = thread_local(source_flags);
#define restore_current_source_pos | ( | ) |
{ \ thread_local(source_pos) = _save_pos; \ thread_local(source_line) = _save_line; \ thread_local(source_flags) = _save_flags;}
#define save_current_source_to_frame | ( | ) |
{ \ Value** _frame = thread_local(current_scan_frame); \ if (_frame) _frame[3] = thread_local(source_file); \ if (_frame) _frame[4] = (Value*)thread_local(source_pos); \ if (_frame) _frame[8] = (Value*)thread_local(source_line); \ if (_frame) _frame[7] = (Value*)static_cast<DWORD_PTR>(thread_local(source_flags));}
#define save_current_source_to_frame_no_pos | ( | ) |
{ \ Value** _frame = thread_local(current_scan_frame); \ if (_frame) _frame[3] = thread_local(source_file); \ if (_frame) _frame[7] = (Value*)static_cast<DWORD_PTR>(thread_local(source_flags));}
#define save_current_source_to_frame_pos | ( | ) |
{ \ Value** _frame = thread_local(current_scan_frame); \ if (_frame) _frame[4] = (Value*)thread_local(source_pos); \ if (_frame) _frame[8] = (Value*)thread_local(source_line);}
#define save_current_source_to_frame_no_file | ( | ) |
{ \ Value** _frame = thread_local(current_scan_frame); \ if (_frame) _frame[4] = (Value*)thread_local(source_pos); \ if (_frame) _frame[8] = (Value*)thread_local(source_line);}
#define push_control | ( | _c | ) |
Control* _save_cc = thread_local(current_controller); \ thread_local(current_controller) = _c;
#define pop_control | ( | ) | thread_local(current_controller) = _save_cc; |
#define save_error_source_data | ( | ) |
{ \ thread_local(err_source_file) = thread_local(source_file); \ thread_local(err_source_pos) = thread_local(source_pos); \ thread_local(err_source_line)= thread_local(source_line); \ thread_local(err_source_flags) = thread_local(source_flags);\ thread_local(err_occurred) = TRUE;}
#define clear_error_source_data | ( | ) |
{ \ thread_local(err_source_file) = NULL; \ thread_local(err_source_pos) = 0; \ thread_local(err_source_flags) = 0; \ thread_local(err_source_line) = 0; \ thread_local(err_occurred) = FALSE;}
Type templated_return_value_fn | ( | Type | r, |
Value ** | link | ||
) |
{ thread_local(current_result) = r; thread_local(current_locals_frame) = link; return r; }
Type templated_return_protected_fn | ( | Type | r | ) |
{ thread_local(current_result) = r; return r; }