Update of /cvsroot/quantlibaddin/QuantLibAddin/gensrc/stubs
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv13889/gensrc/stubs
Added Files:
stub.excel.addin
Removed Files:
stub.excel.register
Log Message:
subdivide function registration code into multiple source files
--- NEW FILE: stub.excel.addin ---
#include <ohxl/objhandlerxl.hpp>
#include <qlo/qladdindefines.hpp>
#include <qlxl/Register/register_all.hpp>
/* Use BOOST_MSVC instead of _MSC_VER since some other vendors
(Metrowerks, for example) also #define _MSC_VER
*/
#if defined BOOST_MSVC // Microsoft Visual C++
# define BOOST_LIB_DIAGNOSTIC
# include <qlo/auto_link.hpp>
# include <oh/auto_link.hpp>
# if defined(XLL_STATIC)
#include <ohxl/Register/register_all.hpp>
#include <ohxl/export.hpp>
#pragma message("XLL_STATIC is defined")
# elif defined(XLL_IMPORTS)
#include <xlsdk/auto_link.hpp>
#pragma message("XLL_IMPORTS is defined")
# endif
# undef BOOST_LIB_DIAGNOSTIC
#endif
#if defined COMPILING_XLL
# pragma message("COMPILING_XLL is defined")
#else
# pragma message("COMPILING_XLL is NOT defined")
#endif
#include <string>
#include <sstream>
#ifdef XLL_STATIC
// instantiate the objecthandler singleton
ObjHandler::ObjectHandlerXL oh;
#endif
DLLEXPORT void xlAutoFree(XLOPER *px) {
if (px->xltype & xltypeStr && px->val.str)
delete [] px->val.str;
else if (px->xltype & xltypeMulti && px->val.array.lparray) {
int size = px->val.array.rows * px->val.array.columns;
for (int i=0; i<size; i++)
if (px->val.array.lparray[i].xltype & xltypeStr
&& px->val.array.lparray[i].val.str)
delete [] px->val.array.lparray[i].val.str;
delete [] px->val.array.lparray;
}
}
DLLEXPORT XLOPER *xlAddInManagerInfo(XLOPER *xlAction) {
XLOPER xlReturn;
static XLOPER xlLongName;
// Coerce the argument XLOPER to an integer.
Excel(xlCoerce, &xlReturn, 2, xlAction, TempInt(xltypeInt));
// The only valid argument value is 1. In this case we return the
// long name for the XLL. Any other value should result in the
// return of a #VALUE! error.
if (1 == xlReturn.val.w) {
ObjHandler::scalarToXloper(xlLongName,
std::string("QuantLibAddin 0.3.14"));
} else {
xlLongName.xltype = xltypeErr;
xlLongName.val.err = xlerrValue;
}
return &xlLongName;
}
DLLEXPORT int xlAutoOpen() {
XLOPER xDll;
try {
Excel(xlGetName, &xDll, 0);
#ifdef XLL_STATIC
registerFunctions(xDll);
#endif
%(registerFunctions)s Excel(xlFree, 0, 1, &xDll);
return 1;
} catch (const std::exception &e) {
std::ostringstream err;
err << "Error loading QuantLibAddin: " << e.what();
Excel(xlcAlert, 0, 1, TempStrStl(err.str()));
Excel(xlFree, 0, 1, &xDll);
return 0;
} catch (...) {
Excel(xlFree, 0, 1, &xDll);
return 0;
}
}
DLLEXPORT int xlAutoClose() {
static XLOPER xDll;
try {
Excel(xlGetName, &xDll, 0);
#ifdef XLL_STATIC
unregisterFunctions(xDll);
#endif
%(unregisterFunctions)s Excel(xlFree, 0, 1, &xDll);
return 1;
} catch (...) {
Excel(xlFree, 0, 1, &xDll);
return 0;
}
}
--- stub.excel.register DELETED ---
|