📄 cplususr.cpp
字号:
/* cplusUsr.cpp - C++ user interface library *//* Copyright 1993 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01i,11oct98,ms reworked 01h fix, since it caused bootrom build to fail01h,08oct98,sn moved defn of cplusXtorStrategy to cplusInit.cpp01g,14jul97,dgp doc: add windsh x-ref to cplusCtors(), cplusDtors(), & cplusXtorSet()01f,08oct96,bjl changed cplusXtorStrategy from MANUAL to AUTOMATIC01e,31oct93,srh fixed spr 227001d,18jun93,jdi more doc cleanup.01c,03jun93,srh doc cleanup01b,23apr93,srh implemented new force-link/initialization scheme01a,31jan93,srh written.*//*DESCRIPTIONThis module provides C++ support routines meant to be called from theVxWorks shell. It provides utilities for calling constructors anddestructors for static objects, and for setting modes used by the C++demangler and the static object support routines.NOMANUAL*//* includes */#include "vxWorks.h"#include "cplusLib.h"#include "moduleLib.h"/* defines *//* typedefs *//* globals */char __cplusUsr_o;CPLUS_DEMANGLER_MODES cplusDemanglerMode = COMPLETE;CPLUS_XTOR_STRATEGIES cplusXtorStrategy = AUTOMATIC;/* locals *//* forward declarations *//******************************************************************************** cplusDemanglerSet - change C++ demangling mode (C++)** This command sets the C++ demangling mode to <mode>.* The default mode is 2.** There are three demangling modes, <complete>, <terse>, and <off>.* These modes are represented by numeric codes:** .TS* center,tab(|);* lf3 lf3* l l.* Mode | Code* _* off | 0* terse | 1* complete | 2* .TE** In complete mode, when C++ function names are printed, the class* name (if any) is prefixed and the function's parameter type list* is appended.** In terse mode, only the function name is printed. The class name* and parameter type list are omitted.** In off mode, the function name is not demangled.** EXAMPLES* The following example shows how one function name would be printed* under each demangling mode:** .TS* center,tab(|);* lf3 lf3* l l.* Mode | Printed symbol* _* off | _member_\^_5classFPFl_PvPFPv_v* terse | _member* complete | foo::_member(void* (*)(long),void (*)(void*))* .TE** RETURNS: N/A*/extern "C" void cplusDemanglerSet ( int mode ) { cplusDemanglerMode = CPLUS_DEMANGLER_MODES (mode); }/******************************************************************************** cplusXtorSet - change C++ static constructor calling strategy (C++)** This command sets the C++ static constructor calling strategy* to <strategy>. The default strategy is 0.** There are two static constructor calling strategies: <automatic>* and <manual>. These modes are represented by numeric codes:** .TS* center,tab(|);* lf3 lf3* l l.* Strategy | Code* _* manual | 0* automatic | 1* .TE** Under the manual strategy, a module's static constructors and* destructors are called by cplusCtors() and cplusDtors(), which are* themselves invoked manually.* * Under the automatic strategy, a module's static constructors are* called as a side-effect of loading the module using the VxWorks module* loader. A module's static destructors are called as a side-effect of* unloading the module.** NOTE: The manual strategy is applicable only to modules that are* loaded by the VxWorks module loader. Static constructors and* destructors contained by modules linked with the VxWorks image* are called using cplusCtorsLink() and cplusDtorsLink().** RETURNS: N/A** SEE ALSO* windsh,* .tG "Shell"*/extern "C" void cplusXtorSet ( int strategy ) { cplusXtorStrategy = CPLUS_XTOR_STRATEGIES (strategy); }/******************************************************************************** callAllCtors - used by cplusCtors to call ctors for all loaded modules*** RETURNS: TRUE** NOMANUAL*/static BOOL callAllCtors ( MODULE_ID module, int ) { if (module->ctors != 0) { cplusCallCtors (module->ctors); } return TRUE; }/******************************************************************************** callAllDtors - used by cplusDtors to call dtors for all loaded modules** RETURNS: TRUE** NOMANUAL*/static BOOL callAllDtors ( MODULE_ID module, int ) { if (module->dtors != 0) { cplusCallDtors (module->dtors); } return TRUE; }/****************************************************************** cplusCtors - call static constructors (C++)** This function is used to call static constructors under the manual* strategy (see cplusXtorSet()). <moduleName> is the name of an* object module that was "munched" before loading. If <moduleName> is 0,* then all static constructors, in all modules loaded by the VxWorks* module loader, are called.** EXAMPLES* The following example shows how to initialize the static objects in* modules called "applx.out" and "apply.out".* * .CS* -> cplusCtors "applx.out"* value = 0 = 0x0* -> cplusCtors "apply.out"* value = 0 = 0x0* .CE* * The following example shows how to initialize all the static objects that are* currently loaded, with a single invocation of cplusCtors():* * .CS* -> cplusCtors* value = 0 = 0x0* .CE* * RETURNS: N/A** SEE ALSO: cplusXtorSet(), windsh,* .tG "Shell"*/extern "C" void cplusCtors ( const char * moduleName // name of loaded module ) { MODULE_ID module; if (moduleName == 0) { moduleEach (FUNCPTR (callAllCtors), 0); return; } else if ((module = moduleFindByName ((char *) moduleName)) == 0) { cplusLogMsg ("cplusCtors: can't find module \"%s\"\n", (int) moduleName, 0, 0, 0, 0, 0); return; } if (module->ctors != 0) { cplusCallCtors (module->ctors); } }/****************************************************************** cplusDtors - call static destructors (C++)** This function is used to call static destructors under the manual* strategy (see cplusXtorSet()). <moduleName> is the name of an* object module that was "munched" before loading. If <moduleName> is 0,* then all static destructors, in all modules loaded by the VxWorks* module loader, are called.** EXAMPLES* The following example shows how to destroy the static objects in* modules called "applx.out" and "apply.out":* * .CS* -> cplusDtors "applx.out"* value = 0 = 0x0* -> cplusDtors "apply.out"* value = 0 = 0x0* .CE* * The following example shows how to destroy all the static objects that are* currently loaded, with a single invocation of cplusDtors():* * .CS* -> cplusDtors* value = 0 = 0x0* .CE* * RETURNS: N/A* * SEE ALSO: cplusXtorSet(), windsh,* .tG "Shell"*/extern "C" void cplusDtors ( const char * moduleName ) { MODULE_ID module; if (moduleName == 0) { moduleEach (FUNCPTR (callAllDtors), 0); return; } else if ((module = moduleFindByName ((char *) moduleName)) == 0) { cplusLogMsg ("cplusDtors: can't find module \"%s\"\n", (int) moduleName, 0, 0, 0, 0, 0); return; } if (module->dtors != 0) { cplusCallDtors (module->dtors); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -