VOID NEAR HOutEnum ( LPTYPE pType ) { XOut("\ntypedef enum "); if (pType->structenum.szTag) { XOutF(pType->structenum.szTag); if (pType->tentrykind & tFORWARD) { XOut(";\n"); return; } XOut(" "); } XOut("{\n"); HOutElems(pType->structenum.elemList, " ", ",\n", "\n", TRUE); XOut("} "); XOutF(pType->szName); XOut(";\n"); }
static const Cinfo* Sender::initCinfo() { static DestFinfo process( "process", "Handles process call", new ProcOpFunc< Sender >( &Sender::process ) ); static DestFinfo reinit( "reinit", "Handles reinit call", new ProcOpFunc< Sender >( &Sender::reinit ) ); static Finfo* processShared[] = { &process, &reinit }; static SharedFinfo proc( "proc", "Shared message to receive Process message from scheduler", processShared, sizeof( processShared ) / sizeof( Finfo* ) ); static ValueFinfo< Sender, double > X( "X", "Random value field for testing", &Sender::setX, &Sender::getX ); static Finfo* SenderFinfos[] = { &proc, // Shared &X, // Value XOut(), // Src }; static string doc[] = { "Name", "Sender", "Author", "Praveen Venkatesh, 2013, NCBS", "Description", "Sender: A class for trying out creation of a C++ class" "accessible in python", }; static Cinfo SenderCinfo( "Sender", Neutral::initCinfo(), SenderFinfos, sizeof( SenderFinfos )/sizeof(Finfo *), new Dinfo< Sender >() ); return &SenderCinfo; }
/** Creates the output workspace, its size, units, etc. * @param binParams the bin boundary specification using the same same syntax as * param the Rebin algorithm * @return A pointer to the newly-created workspace */ API::MatrixWorkspace_sptr Q1D2::setUpOutputWorkspace(const std::vector<double> &binParams) const { // Calculate the output binning HistogramData::BinEdges XOut(0); size_t sizeOut = static_cast<size_t>(VectorHelper::createAxisFromRebinParams( binParams, XOut.mutableRawData())); // Now create the output workspace MatrixWorkspace_sptr outputWS = WorkspaceFactory::Instance().create(m_dataWS, 1, sizeOut, sizeOut - 1); outputWS->getAxis(0)->unit() = UnitFactory::Instance().create("MomentumTransfer"); outputWS->setYUnitLabel("1/cm"); // Set the X vector for the output workspace outputWS->setBinEdges(0, XOut); outputWS->setDistribution(true); outputWS->getSpectrum(0).clearDetectorIDs(); outputWS->getSpectrum(0).setSpectrumNo(1); return outputWS; }
void Sender::reinit( const Eref& e, ProcPtr p ) { XOut()->send( e, p->threadIndexInGroup, X_ ); }
VOID NEAR HOutElems ( LPELEM pElemList, CHAR * szPrefix, CHAR * szSep, CHAR * szSepLast, BOOL fEnum ) { LPELEM pElem; WORD cDims; ARRAYDESC FAR* lpAD; BOOL fHex; LPOLESTR lpch; CHAR * pch; CHAR buf[2]; UINT cch; pElem = (LPELEM)ListFirst(pElemList); // point to first entry #pragma warning(disable:4127) while (TRUE) #pragma warning(default:4127) { HOut(szPrefix); if (!fEnum) { // output elem type, with the right number of "*'s" HOutType(pElem->elemType); HOut(" "); } XOutF(pElem->szElemName); #ifdef PROFILE cVarsTotal++; #endif //PROFILE if (!fEnum && pElem->elemType->tdesc.vt == VT_CARRAY) { // base type already outputted before name above lpAD = pElem->elemType->tdesc.lpadesc; for (cDims = 0; cDims < lpAD->cDims; cDims++) { HOut("["); #if 0 // arrays of the form "a[]" aren't supported if (lpAD->rgbounds[cDims].cElements) #endif //0 HOutLongNum((long)lpAD->rgbounds[cDims].cElements, FALSE); HOut("]"); } } if (pElem->attr.fAttr2 & f2GotConstVal) { HOut(" = "); fHex = FALSE; if (!fEnum) { // display all the unsigned constants in Hex form switch (pElem->elemType->tdesc.vt) { case VT_UI1: case VT_UI2: case VT_UI4: case VT_UINT: case VT_ERROR: fHex = TRUE; break; default: break; } } // output the constant element's value switch (pElem->lpElemVal->vt) { case VT_I2: case VT_BOOL: HOutShortNum(pElem->lpElemVal->iVal, fHex); break; case VT_I4: case VT_ERROR: HOutLongNum(pElem->lpElemVal->lVal, fHex); break; case VT_BSTR: HOut("\""); // output 1 char at a time, in order to handle // escape sequences in strings lpch = pElem->lpElemVal->bstrVal; cch = SysStringLen(lpch); while (cch) { switch(*lpch) { case 0x0: pch = "\\0"; break; case 0x7: pch = "\\a"; break; case 0x8: pch = "\\b"; break; case 0x9: pch = "\\t"; break; case 0xA: if (SysKind == SYS_MAC) pch = "\\r"; else pch = "\\n"; break; case 0xB: pch = "\\v"; break; case 0xC: pch = "\\f"; break; case 0xD: if (SysKind == SYS_MAC) pch = "\\n"; else pch = "\\r"; break; default: #ifdef WIN32 SideAssert (WideCharToMultiByte(CP_ACP, 0, lpch, 1, buf, 1, NULL, NULL) != 0); #else //WIN32 buf[0] = *lpch; #endif //WIN32 buf[1] = '\0'; pch = buf; break; } HOut(pch); // output the char lpch++; cch--; } HOut("\""); break; // CONSIDER: support more constant types. default: Assert(FALSE); } } // advance to next entry if not all done if (pElem == (LPELEM)ListLast(pElemList)) { XOut(szSepLast); break; // exit if all done } XOut(szSep); pElem = pElem->pNext; } }
VOID NEAR HOutFuncs ( LPFUNC pFuncList, TENTRYKIND tentryKind ) { LPFUNC pFunc; if (pFuncList == NULL) // nothing to output if no functions return; pFunc = (LPFUNC)ListFirst(pFuncList); // point to first entry #pragma warning(disable:4127) while (TRUE) #pragma warning(default:4127) { #ifndef PROFILE if (tentryKind == tINTERFACE) { if (fSpecifiedInterCC) { // set up STDMETHODCALLTYPE based on the calling // convention and SYSKIND if (pFunc->func.attr.fAttr2 & f2CCDEFAULTED) SetCallType(CALL_DEFAULT); else if (pFunc->func.attr.fAttr2 & f2PASCAL) SetCallType(CALL_PASCAL); else if (pFunc->func.attr.fAttr2 & f2STDCALL) SetCallType(CALL_STDCALL); else { Assert(pFunc->func.attr.fAttr2 & f2CDECL) SetCallType(CALL_CDECL); } } HOut(szHeadOleFuncPrefix1); // leading spaces HOut(szHeadOleFuncPrefix2); if (pFunc->func.elemType->tdesc.vt == VT_HRESULT) HOut("("); else { HOut("_("); // output function return type HOutType(pFunc->func.elemType); HOut(szHeadOleFuncPrefix3); } HOutPropPrefix(pFunc); XOutF(pFunc->func.szElemName); HOut(szHeadOleArgPrefix1); if (pFunc->cArgs) { HOut(szHeadOleArgPrefix2); // output list of variables, separating them by // commas, with nothing after last item HOutElems(pFunc->argList, "", ", ", "", FALSE); } XOut(szHeadOleArgSuffix); } else #endif //!PROFILE { HOut(szHeadOleFuncPrefix1); // leading spaces if (tentryKind == tMODULE) HOut ("extern "); // output function return type HOutType(pFunc->func.elemType); HOut(" "); // output calling convention if (!(pFunc->func.attr.fAttr2 & f2CCDEFAULTED)) { if (pFunc->func.attr.fAttr2 & f2PASCAL) HOut("__pascal "); else if (pFunc->func.attr.fAttr2 & f2CDECL) HOut("__cdecl "); else if (pFunc->func.attr.fAttr2 & f2STDCALL) HOut("__stdcall "); #ifdef DEBUG else Assert(FALSE); #endif //DEBUG } HOutPropPrefix(pFunc); XOutF(pFunc->func.szElemName); Assert(pFunc->func.elemType->tdesc.vt != VT_CARRAY); XOut("("); #ifdef PROFILE cArgsTotal += pFunc->cArgs; cFuncsTotal++; #endif //PROFILE if (pFunc->cArgs == 0) { HOut("void"); } else { // output list of variables, separating them by // commas, with nothing after last item HOutElems(pFunc->argList, "", ", ", "", FALSE); #ifdef PROFILE cVarsTotal-= pFunc->cArgs; // would be counted twice #endif //PROFILE } XOut(");\n"); } // advance to next entry if not all done if (pFunc == (LPFUNC)ListLast(pFuncList)) break; // exit if all done pFunc = (LPFUNC)pFunc->func.pNext; } if (fSpecifiedInterCC) { SetCallType(CALL_DEFAULT); // reset to default STDMETHODCALLTYPE } }
VOID NEAR HOutInterface ( LPENTRY pEntry ) { LPSTR lpszBaseName; TENTRYKIND tentrykind; LPINTER lpInterFirst; // first base interface, if any LPINTER lpInterLast; // second/last base interface, if any tentrykind = pEntry->type.tentrykind; if (tentrykind & tFORWARD) { // UNDONE: proper OLE format for forward declaration of interface? // UNDONE: I don't think this will work in C. I think it wants: // UNDONE: typedef interface <interfacename> <interfacename>; HOut("\ninterface "); HOutF(pEntry->type.szName); HOut(";\n"); return; } HOutGuid(&pEntry->attr, ((tentrykind == tDISPINTER) ? szHeadGuidDIID: szHeadGuidIID), pEntry->type.szName); lpszBaseName = NULL; lpInterFirst = NULL; if (pEntry->type.inter.interList) { lpInterFirst = (LPINTER)ListFirst(pEntry->type.inter.interList); lpInterLast = (LPINTER)ListLast(pEntry->type.inter.interList); // We assume there's only single inheritance at this point // But in the case of a dispinterface, we could have the first // base interface be IDispatch, and the 2nd base interface be // the interface that we're capable of dispatching on. In any // case, there can't be more than 2 interfaces in the list. Assert((LPINTER)lpInterFirst->pNext == lpInterLast); lpszBaseName = lpInterFirst->ptypeInter->szName; Assert(lpszBaseName); } // first output the header comment HOut((tentrykind == tDISPINTER) ? szHeadDispinter: szHeadInter); HOutF(pEntry->type.szName); HOut(szHeadOleSuffix3); // then output the OLE header HOut(szHeadOlePrefix0); HOutF(pEntry->type.szName); HOut("\n\n"); HOut(szHeadOlePrefix1); if (lpszBaseName) HOut("_"); HOut("("); HOutF(pEntry->type.szName); if (lpszBaseName) // if this inherits from somebody { // then add ", <baseinterface>" HOut(", "); HOutF(lpszBaseName); } HOut(szHeadOlePrefix2); if (tentrykind == tDISPINTER) { Assert (lpszBaseName); HOut(szHeadOlePrefix7); HOut(szHeadIUnknown); HOut(szHeadIDispatch); HOut(szHeadOleSuffix7); if (lpInterFirst != lpInterLast) { // specifies an interface that is dispatchable HOut(szHeadDispatchable); HOutF(lpInterLast->ptypeInter->szName); HOut(szHeadOleSuffix3); } // first output the properties (commented out) in "struct" format if (pEntry->dispinter.propList) { XOut(szHeadOlePrefix3); XOutF(pEntry->type.szName); XOut(szHeadOlePrefix5); HOutElems(pEntry->dispinter.propList, " ", ";\n", ";\n", FALSE); HOut(szHeadOleSuffix1); } // then output the methods (commented out) in "normal" format if (pEntry->dispinter.methList) { XOut(szHeadOlePrefix3); XOutF(pEntry->type.szName); XOut(szHeadOlePrefix6); HOutFuncs(pEntry->dispinter.methList, tDISPINTER); HOut(szHeadOleSuffix1); } } else { // an interface // output interface functions, and base interface functions (if any) HOutBaseInter(pEntry, FALSE); } // lastly, output the close curly HOut(szHeadOleSuffix2); }