thread_locals.inl

Go to the documentation of this file.
00001 /*  
00002  *      thread_locals.h - thread locals for each interpreter thread in MAXScript
00003  *
00004  *          Copyright � John Wainwright 1996
00005  *
00006  */
00007 
00008 /* thread locals and initial values */
00009 #pragma warning(push)
00010 #pragma warning(disable:4100)
00011 
00012 // This file describes the thread local variables. This file is included in various contexts where the definition of 'def_thread_local'
00013 // is context specific. For example, in one place type, 'def_thread_local' is used to declare the thread local variable, in another it
00014 // is used to initialize the thread local variable, in another it is used during garbage collection to mark Value* derived values
00015 // as being in use.
00016 
00017 // Column 1 is the type of the thread local variable
00018 // Column 2 is the thread local variable's name
00019 // Column 3 is whether the type derives from Value*, and the contents of the thread local variable should be protected against garbage collection
00020 // Column 4 is the value used to initialize the thread local variable
00021 
00022     def_thread_local( CharStream*,          current_stdout,         TRUE,   new (GC_IN_HEAP) WindowStream(_M("Script Output")));
00023     def_thread_local( BOOL,                 force_listener_open,    FALSE,  TRUE);          // whether to force listener open on output to it
00024 
00025     def_thread_local( Value**,              current_frame,          FALSE,  NULL);          // current interpreter frame (for thunk evals)
00026     def_thread_local( Value**,              current_scan_frame,     FALSE,  NULL);          // current interpreter frame (for gc scanner) 
00027     def_thread_local( Value**,              current_locals_frame,   FALSE,  NULL);          // C++ local frame
00028     def_thread_local( Value*,               current_result,         TRUE,   NULL);          // C++ current Value* function result
00029     def_thread_local( long,                 stack_limit,            FALSE,  ALLOCATOR_STACK_SIZE);  // max stack size to catch recurse loops, 1Mb to start, 
00030                                                                                                     // minus buffer to handle calls made during error handling
00031     def_thread_local( LONG_PTR,             stack_base,             FALSE,  (LONG_PTR)_alloca(sizeof(int)));    // current stack base
00032     def_thread_local( MSPlugin*,            current_plugin,         TRUE,   NULL);          // current scripted plugin (for plugin thunk evals)
00033     def_thread_local( Struct*,              current_struct,         TRUE,   NULL);          // current struct (for struct member thunk evals)
00034     def_thread_local( Value*,               current_container,      TRUE,   NULL);          // current container for nested property access
00035     def_thread_local( int,                  container_index,        FALSE,  0);             // current container index (if any)
00036     def_thread_local( Value*,               container_prop,         TRUE,   NULL);          // current container prop (if any)
00037     def_thread_local( Value*,               current_prop,           TRUE,   NULL);          // most recent prop access (if any)
00038 
00039     def_thread_local( Value*,               source_file,            TRUE,   NULL);          // current source file
00040     def_thread_local( UINT_PTR,             source_pos,             FALSE,  0);             // current pos in source file
00041     def_thread_local( UINT_PTR,             source_line,            FALSE,  0);             // current pos in source file, instead of INT_PTR, will have an int to simplify things
00042 
00043     def_thread_local( int,                  needs_redraw,           FALSE,  0);             // 0- no redraw needed, 1 - redraw needed, 2 - complete redraw needed
00044     def_thread_local( BOOL,                 redraw_mode,            FALSE,  1);             // redraw on
00045     def_thread_local( BOOL,                 pivot_mode,             FALSE,  0);             // pivot off
00046     def_thread_local( BOOL,                 undo_mode,              FALSE,  1);             // undo on
00047     def_thread_local( Value*,               current_level,          TRUE,   &all_objects);  // $objects
00048     def_thread_local( BOOL,                 use_time_context,       FALSE,  0);             // use MAX time slider
00049     def_thread_local( TimeValue,            current_time,           FALSE,  0);
00050     def_thread_local( Value*,               current_coordsys,       TRUE,   n_default);
00051     def_thread_local( Value*,               center_mode,            TRUE,   n_default);
00052 
00053     def_thread_local( int,                  rand_accum,             FALSE,  0);             // for our own rand()
00054     def_thread_local( HANDLE,               message_event,          FALSE,  NULL);          // listener_message synch event
00055     def_thread_local( int,                  stream_rand_accum,      FALSE,  0);             // for stream_rand()
00056 
00057     def_thread_local( MSZipPackage*,        current_pkg,            TRUE,   NULL);          // currently open zip module, if any
00058 
00059     def_thread_local( void*,                alloc_frame,            FALSE,  NULL);          // top frame of allocator stack
00060     def_thread_local( void*,                alloc_tos,              FALSE,  NULL);          // top of allocator stack
00061     def_thread_local( void*,                alloc_stack_lim,        FALSE,  NULL);          // limit of allocator stack
00062 
00063     def_thread_local( Control*,             current_controller,     FALSE,  NULL);          // currently evaluating scripted controller
00064 
00065     def_thread_local( String*,              undo_label,             TRUE,   new (GC_PERMANENT) String(_M("MAXScript"))); // current undo label
00066     def_thread_local( BOOL,                 try_mode,               FALSE,  0);             // try(...)
00067     def_thread_local( MAXScriptException*,  current_exception,      FALSE,  NULL);          // current exception that was thrown, if any. Non-null only in catch expression
00068 
00069     def_thread_local( BOOL,                 thread_not_active,      FALSE,  FALSE);         // set to TRUE when thread found not to be active any more
00070 
00071     def_thread_local( BOOL,                 err_occurred,           FALSE,  FALSE);         // set to TRUE when error thrown
00072     def_thread_local( Value*,               err_source_file,        TRUE,   NULL);          // source file where error thrown
00073     def_thread_local( UINT_PTR,             err_source_pos,         FALSE,  0);             // pos in source file where error thrown
00074     def_thread_local( UINT_PTR,             err_source_line,        FALSE,  0);             // line in source file where error thrown
00075 
00076     def_thread_local( Value*,               current_frame_owner,    TRUE,   NULL);          // owner of current stack frame while compiling
00077     
00078     def_thread_local( BOOL,                 is_dubugger_thread,     FALSE,  FALSE);         // owner of current stack frame while compiling
00079 
00080     def_thread_local( DWORD,                source_flags,           FALSE,  0);             // current source file flags
00081     def_thread_local( DWORD,                err_source_flags,       FALSE,  0);             // source file flags for source file where error thrown
00082 
00083     def_thread_local( BOOL,                 trace_back_active,      FALSE,  FALSE);         // true if have started tracing up the stack due to an error
00084     def_thread_local( BOOL,                 disable_trace_back,     FALSE,  FALSE);         // true if no stack traceback is to occur if an error occurs
00085     def_thread_local( int,                  trace_back_levels,      FALSE,  0);             // when tracing up the stack due to an error, how many stack frames we have traced so far
00086 
00087     def_thread_local( StringStream*,        resource_value_reader,  TRUE,   NULL);          // Stringstream used to prevalidate resource Values read from resource files
00088 
00089 #pragma warning(pop)