/**************************************************************************\ * * This file is part of the Coin 3D visualization library. * Copyright (C) 1998-2007 by Systems in Motion. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * ("GPL") version 2 as published by the Free Software Foundation. * See the file LICENSE.GPL at the root directory of this source * distribution for additional information about the GNU GPL. * * For using Coin with software that can not be combined with the GNU * GPL, and for taking advantage of the additional benefits of our * support services, please contact Systems in Motion about acquiring * a Coin Professional Edition License. * * See http://www.coin3d.org/ for more information. * * Systems in Motion, Postboks 1283, Pirsenteret, 7462 Trondheim, NORWAY. * http://www.sim.no/ sales@sim.no coin-support@coin3d.org * \**************************************************************************/ typedef SbString mangleFunc(const char *); /* This function returns a string that corresponds to how gcc 2.95.4 mangles "static void ::initClass(void)". */ static SbString gcc2_initClassMangling(const char * classname) { assert(classname != NULL); const size_t len = strlen(classname); SbString mangling; mangling.sprintf("initClass__%d%s", len, classname); return mangling; } /* This function returns a string that corresponds to how gcc3 mangles "static void ::initClass(void)". */ static SbString gcc3_initClassMangling(const char * classname) { assert(classname != NULL); const size_t len = strlen(classname); SbString mangling; mangling.sprintf("_ZN%d%s9initClassEv", len, classname); return mangling; } /* This function returns a string that corresponds to how Microsoft Visual C++ v6 mangles "static void ::initClass(void)" in a __declspec(dllexport) context. */ static SbString msvc6_initClassMangling(const char * classname) { assert(classname != NULL); SbString mangling; mangling.sprintf("?initClass@%s@@SAXXZ", classname); return mangling; } /* This function returns a string that corresponds to how IRIX MIPSpro CC 7.30 mangles "static void ::initClass(void)". */ static SbString MIPSpro_CC_initClassMangling(const char * classname) { assert(classname != NULL); const size_t len = strlen(classname); SbString mangling; mangling.sprintf("initClass__%d%sSGv", len, classname); return mangling; } /* This function returns a string that corresponds to how HP-UX 11's aCC mangles "static void ::initClass(void)". The version information reported by the aCC used to check the name mangling: "HP ANSI C++ B3910B A.03.35". */ static SbString HPUX_aCC_initClassMangling(const char * classname) { assert(classname != NULL); const size_t len = strlen(classname); SbString mangling; mangling.sprintf("initClass__%d%sSFv", len, classname); return mangling; } /* ********************************************************************** */ static mangleFunc * manglefunctions[] = { HPUX_aCC_initClassMangling, gcc2_initClassMangling, gcc3_initClassMangling, msvc6_initClassMangling, MIPSpro_CC_initClassMangling, (mangleFunc *) NULL }; /* return the correct name mangling function, or NULL in case none seem appropriate */ static mangleFunc * getManglingFunction(void) { static SbBool initialized = FALSE; static mangleFunc * manglefunc = NULL; if ( !initialized ) { initialized = TRUE; int i; cc_libhandle handle = cc_dl_open(NULL); if ( handle == NULL ) goto failure; for ( i = 0; (manglefunctions[i] != NULL) && (manglefunc == NULL); i++ ) { mangleFunc * attempt = manglefunctions[i]; SbString symbol(attempt("SoBase")); if ( cc_dl_sym(handle, symbol.getString()) ) { manglefunc = manglefunctions[i]; } } cc_dl_close(handle); if ( manglefunc == NULL ) goto failure; } return manglefunc; failure: #ifdef _MSC_VER // LoadLibrary(NULL) doesn't work, so we fall-back on the MSVC++ mangling // scheme on MS Windows. manglefunc = msvc6_initClassMangling; #endif return manglefunc; } /* ********************************************************************** */