INT16 CHelloworld_GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; #ifdef __cplusplus lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CHelloworld::CreateInstance; lpClassWord->ex.fct.lpfInstall = CHelloworld::InstallProc; #else /* #ifdef __DLP_CSCOPE */ lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CHelloworld_CreateInstance; lpClassWord->ex.fct.lpfInstall = CHelloworld_InstallProc; #endif /* #ifdef __DLP_CSCOPE */ lpClassWord->ex.fct.lpProject = "helloworld"; lpClassWord->ex.fct.lpBaseClass = "-"; lpClassWord->lpComment = "Simple example for a dLabPro class"; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CHelloworld"; lpClassWord->ex.fct.lpAuthor = "m.eichner"; dlp_strcpy(lpClassWord->lpName ,"Helloworld"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.00 SLC22"); return O_K; }
INT16 CDlpFile_GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOINSTANCE; #ifdef __cplusplus lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CDlpFile::CreateInstance; lpClassWord->ex.fct.lpfInstall = CDlpFile::InstallProc; #else /* #ifdef __DLP_CSCOPE */ lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CDlpFile_CreateInstance; lpClassWord->ex.fct.lpfInstall = CDlpFile_InstallProc; #endif /* #ifdef __DLP_CSCOPE */ lpClassWord->ex.fct.lpProject = "file"; lpClassWord->ex.fct.lpBaseClass = "-"; lpClassWord->lpComment = "File list processor and import/export filters"; lpClassWord->ex.fct.lpAutoname = "stdfile"; lpClassWord->ex.fct.lpCname = "CDlpFile"; lpClassWord->ex.fct.lpAuthor = "M. Wolff, M. Eichner and M. Cuevas"; dlp_strcpy(lpClassWord->lpName ,"file"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.1.2"); return O_K; }
INT16 CFsttools_GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; #ifdef __cplusplus lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CFsttools::CreateInstance; lpClassWord->ex.fct.lpfInstall = CFsttools::InstallProc; #else /* #ifdef __DLP_CSCOPE */ lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CFsttools_CreateInstance; lpClassWord->ex.fct.lpfInstall = CFsttools_InstallProc; #endif /* #ifdef __DLP_CSCOPE */ lpClassWord->ex.fct.lpProject = "fsttools"; lpClassWord->ex.fct.lpBaseClass = "-"; lpClassWord->lpComment = "Tools for FST modification"; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CFsttools"; lpClassWord->ex.fct.lpAuthor = "frank.duckhorn"; dlp_strcpy(lpClassWord->lpName ,"fsttools"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.00 DLC22"); return O_K; }
INT16 CFvrtools_GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_SINGLETON; #ifdef __cplusplus lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CFvrtools::CreateInstance; lpClassWord->ex.fct.lpfInstall = CFvrtools::InstallProc; #else /* #ifdef __DLP_CSCOPE */ lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CFvrtools_CreateInstance; lpClassWord->ex.fct.lpfInstall = CFvrtools_InstallProc; #endif /* #ifdef __DLP_CSCOPE */ lpClassWord->ex.fct.lpProject = "fvrtools"; lpClassWord->ex.fct.lpBaseClass = "-"; lpClassWord->lpComment = "FST-based feature-value relation processing tools"; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CFvrtools"; lpClassWord->ex.fct.lpAuthor = "Matthias Wolff, Werner Meyer"; dlp_strcpy(lpClassWord->lpName ,"fvrtools"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.0.0"); return O_K; }
/** * Base class implementation of the class information function. * The base class implementation does nothing. * * @param lpWord Pointer to a SWord structure which will receive the * information * @return O_K if successful, an error code otherwise */ INT16 CDlpObject_GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; #ifdef __cplusplus lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CDlpObject::CreateInstance; lpClassWord->ex.fct.lpfInstall = CDlpObject::InstallProc; #else /* #ifdef __cplusplus */ lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CDlpObject_CreateInstance; lpClassWord->ex.fct.lpfInstall = CDlpObject_InstallProc; #endif /* #ifdef __cplusplus */ lpClassWord->ex.fct.lpProject = "dlpobject"; lpClassWord->ex.fct.lpBaseClass = "-"; lpClassWord->lpComment = "Generic object"; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CDlpObject"; lpClassWord->ex.fct.lpAuthor = "Matthias Wolff"; dlp_strcpy(lpClassWord->lpName ,"object"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"2.5.1"); return O_K; }
char* CDlpObject_GetFQName(CDlpObject* _this, char* lpName, BOOL bForceArray) { char lpBuf1[255]; char lpBuf2[255]; SWord* lpWord; CDlpObject* lpInst = _this; if (!_this) { dlp_strcpy(lpName,"(null)"); return lpName; } lpBuf2[0]='\0'; if (!_this->m_lpContainer) dlp_strcpy(lpName,_this->m_lpInstanceName); else { lpWord = _this->m_lpContainer; while (TRUE) { /* Do no include interpreter instance name */ if (dlp_strcmp(lpWord->lpContainer->m_lpClassName,"itp")==0) break; if (lpWord->nWordType==WL_TYPE_FIELD && lpWord->ex.fld.nType==T_INSTANCE && (lpWord->ex.fld.nArrlen!=1 || bForceArray)) { /* Seek instance in array */ INT32 i = 0; for (i=0; i<lpWord->ex.fld.nArrlen; i++) if (((CDlpObject**)lpWord->lpData)[i] == lpInst) break; if (i<lpWord->ex.fld.nArrlen) sprintf(lpBuf1,".%s[%ld]%s",lpWord->lpName,(long)i,lpBuf2); else /* MWX 2002-01-16: This is an error actually, but what should be done here ???? --> */ sprintf(lpBuf1,".%s%s",lpWord->lpName,lpBuf2); /* <-- */ } else sprintf(lpBuf1,".%s%s",lpWord->lpName,lpBuf2); strcpy(lpBuf2,lpBuf1); lpInst = (CDlpObject*)lpWord->lpContainer; DLPASSERT(lpInst); /* Word must belong to an instance! */ if (!lpInst->m_lpContainer) break; /* No parent --> stop */ lpWord = lpInst->m_lpContainer; } if (lpBuf2[0] == '.') dlp_memmove(lpBuf2,&lpBuf2[1],dlp_strlen(lpBuf2)); if (strlen(lpBuf2)>0) sprintf(lpName,"%s.%s",lpInst->m_lpInstanceName,lpBuf2); else strcpy(lpName,lpInst->m_lpInstanceName); } return lpName; }
/* * Manual page at process.def */ INT16 CGEN_PUBLIC CProcess::Status() { CData* d; char s[L_INPUTLINE]; INT32 i; printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); // Protocol printf("\n Status of instance"); // Protocol printf("\n process %s",BASEINST(_this)->m_lpInstanceName); // Protocol printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); // Protocol printf("\n State : 0x%04X",m_nState); // Protocol if (m_nState!=0) // In any but the maiden state { // >> BOOL b = 0; // Comma flag printf(" ("); // Protocol if (m_nState&PRC_DATASENT ) { if(b) printf(", "); printf("data sent" ); b=1; }//... if (m_nState&PRC_RUNNING ) { if(b) printf(", "); printf("running" ); b=1; }//... if (m_nState&PRC_COMPLETE ) { if(b) printf(", "); printf("complete" ); b=1; }//... if (m_nState&PRC_KILLED ) { if(b) printf(", "); printf("killed" ); b=1; }//... if (m_nState&PRC_DATARECEIVED) { if(b) printf(", "); printf("data received"); b=1; }//... printf(")"); // Protocol } // << printf("\n Return value: %ld",(long)m_nRetVal ); // Protocol if (dlp_strlen(m_psTmpFile)) printf("\n Temp. files : %s*",m_psTmpFile); // Protocol dlp_strcpy(s,m_psCmdLine); dlp_strreplace(s,m_psTmpFile,"<tmpfile>"); // Abbreviate command line if (dlp_strlen(m_psCmdLine)) printf("\n Command line: %s" ,s); // Protocol // Show transferred data // ------------------------------------ if (m_iDto) // Have data transfer object { // >> printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); // Protocol printf("\n Transferred data"); // Protocol d = (CData*)CDlpObject_FindInstanceWord(m_iDto,PRC_S_IDSIGN,NULL); // Get signature table printf("\n - function : %s",(char*)CData_XAddr(d,0,0)); // Protocol (job function name) for (i=1; i<CData_GetNRecs(d); i++) // Loop over function arguemnts printf("\n %13s %s",i==1?"- arguments :":"",(char*)CData_XAddr(d,i,0)); // Protocol (job function arg.) d = (CData*)CDlpObject_FindInstanceWord(m_iDto,PRC_S_IDGLOB,NULL); // Get list of global instances if (d) // Have one for (i=0; i<CData_GetNRecs(d); i++) // Loop over entries printf("\n %13s %-8s %s",i==0?"- globals :":"", // Protocol (global instance) (char*)CData_XAddr(d,i,0),(char*)CData_XAddr(d,i,1)); // | printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); // Protocol printf("\n Transferred program"); // Protocol for (i=0; dlp_strlen(__sSlaveScript[i]); i++) // Loop over slave script lines { // >> dlp_strcpy(s,__sSlaveScript[i]); // Get a line if (strstr(s,"##"))*(strstr(s,"##"))='\0'; // Truncate at comment printf("\n (%02ld) %s",i,dlp_strtrimright(s)); // Protocol (script line) } // << } // << printf("\n"); dlp_fprint_x_line(stdout,'-',dlp_maxprintcols()); printf("\n"); // Protocol return O_K; // All done }
INT16 CGEN_PROTECTED CCgen::OnLpath() { char lpName[L_INPUTLINE+1]; GetNextDefToken(lpName); if (!dlp_strlen(lpName)) ERRORRET(ERR_EXPECTAFTER,"name","LPATH:",0,NOT_EXEC); switch(m_nCreating) { case CR_PROJECT: { if (m_nAncestor) return O_K; else dlp_convert_name(CN_XLATPATH,m_lpsLPath,lpName); break;} case CR_ERROR: return IERROR(this,ERR_INVALSUBKEY,"ERROR:","LPATH:",0); case CR_FIELD: return IERROR(this,ERR_INVALSUBKEY,"FIELD:","LPATH:",0); case CR_OPTION: return IERROR(this,ERR_INVALSUBKEY,"OPTION:","LPATH:",0); case CR_METHOD: return IERROR(this,ERR_INVALSUBKEY,"METHOD:","LPATH:",0); case CR_NOTE: return IERROR(this,ERR_INVALSUBKEY,"NOTE:","LPATH:",0); case CR_ICLS: { SCGIcl* s = m_lpCreatingIcl; DLPASSERT(s); dlp_strcpy(s->lpLPath,lpName); break; } default: return IERROR(this,ERR_EXPGLOBALKEY,"LPATH:",0,0); } return O_K; }
INT16 CGEN_PROTECTED CCgen::OnHfile() { char lpName[L_INPUTLINE+1]; GetNextDefToken(lpName); if (!dlp_strlen(lpName)) ERRORRET(ERR_EXPECTAFTER,"name","HFILE:",0,NOT_EXEC); switch(m_nCreating) { case CR_PROJECT: return IERROR(this,ERR_INVALSUBKEY,"PROJECT:","HFILE:",0); case CR_ERROR: return IERROR(this,ERR_INVALSUBKEY,"ERROR:","HFILE:",0); case CR_FIELD: return IERROR(this,ERR_INVALSUBKEY,"FIELD:","HFILE:",0); case CR_OPTION: return IERROR(this,ERR_INVALSUBKEY,"OPTION:","HFILE:",0); case CR_METHOD: return IERROR(this,ERR_INVALSUBKEY,"METHOD:","HFILE:",0); case CR_NOTE: return IERROR(this,ERR_INVALSUBKEY,"NOTE:","HFILE:",0); case CR_ICLS : { SCGIcl* s = m_lpCreatingIcl; DLPASSERT(s); dlp_strcpy(s->lpHFile,lpName); break; } default: return IERROR(this,ERR_EXPGLOBALKEY,"HFILE:",0,0); } return O_K; }
INT16 CGEN_PROTECTED CCgen::OnMain() { char lpsProjectname[L_INPUTLINE+1]; GetNextDefToken(lpsProjectname); if (m_nAncestor > 0) return O_K; if (!dlp_strlen(lpsProjectname)) return IERROR(this,ERR_EXPECTAFTER,"name","MAIN:",0); if (m_bAppend) { if (dlp_strncmp(m_lpsProject,lpsProjectname,dlp_strlen(lpsProjectname)) != 0 || !m_bMainProject) { IERROR(this,ERR_APPEND,"MAIN:",lpsProjectname,0); if (!dlp_strlen(m_lpsProject)) EXIT(ERR_EXPPROJECT,"/append MAIN:",0,0); return NOT_EXEC; } } // Set project code SetCreating(CR_PROJECT,NULL); m_bMainProject = TRUE; dlp_strcpy(m_lpsProject,lpsProjectname); return O_K; }
CFWTproc::CFWTproc(const char* lpInstanceName, BOOL bCallVirtual) : inherited(lpInstanceName,0) { DEBUGMSG(-1,"CFWTproc::CFWTproc; (bCallVirtual=%d)",(int)bCallVirtual,0,0); dlp_strcpy(m_lpClassName,"FWTproc"); dlp_strcpy(m_lpObsoleteName,""); dlp_strcpy(m_lpProjectName,"FWTproc"); dlp_strcpy(m_version.no,"1.0"); dlp_strcpy(m_version.date,""); m_nClStyle = CS_AUTOACTIVATE; if (bCallVirtual) { DLPASSERT(OK(AutoRegisterWords())); Init(TRUE); } }
void CFsttools_Constructor(CFsttools* _this, const char* lpInstanceName, BOOL bCallVirtual) { DEBUGMSG(-1,"CFsttools_Constructor; (bCallVirtual=%d)",(int)bCallVirtual,0,0); #ifndef __cplusplus /* Register instance */ dlp_xalloc_register_object('J',_this,1,sizeof(CFsttools), __FILE__,__LINE__,"fsttools",lpInstanceName); /* Create base instance */ _this->m_lpBaseInstance = calloc(1,sizeof(CDlpObject)); CDlpObject_Constructor(_this->m_lpBaseInstance,lpInstanceName,FALSE); /* Override virtual member functions */ _this->m_lpBaseInstance->AutoRegisterWords = CFsttools_AutoRegisterWords; _this->m_lpBaseInstance->Reset = CFsttools_Reset; _this->m_lpBaseInstance->Init = CFsttools_Init; _this->m_lpBaseInstance->Serialize = CFsttools_Serialize; _this->m_lpBaseInstance->SerializeXml = CFsttools_SerializeXml; _this->m_lpBaseInstance->Deserialize = CFsttools_Deserialize; _this->m_lpBaseInstance->DeserializeXml = CFsttools_DeserializeXml; _this->m_lpBaseInstance->Copy = CFsttools_Copy; _this->m_lpBaseInstance->ClassProc = CFsttools_ClassProc; _this->m_lpBaseInstance->GetInstanceInfo = CFsttools_GetInstanceInfo; _this->m_lpBaseInstance->IsKindOf = CFsttools_IsKindOf; _this->m_lpBaseInstance->Destructor = CFsttools_Destructor; _this->m_lpBaseInstance->ResetAllOptions = CFsttools_ResetAllOptions; /* Override pointer to derived instance */ _this->m_lpBaseInstance->m_lpDerivedInstance = _this; #endif /* #ifndef __cplusplus */ dlp_strcpy(BASEINST(_this)->m_lpClassName,"fsttools"); dlp_strcpy(BASEINST(_this)->m_lpObsoleteName,""); dlp_strcpy(BASEINST(_this)->m_lpProjectName,"fsttools"); dlp_strcpy(BASEINST(_this)->m_version.no,"1.00 DLC22"); dlp_strcpy(BASEINST(_this)->m_version.date,""); BASEINST(_this)->m_nClStyle = CS_AUTOACTIVATE; if (bCallVirtual) { DLPASSERT(OK(INVOKE_VIRTUAL_0(AutoRegisterWords))); INVOKE_VIRTUAL_1(Init,TRUE); } }
INT16 CGEN_PROTECTED CCgen::OnMsvcFlags() { const char* lpFlags = GetRestOfDefLine(); if (m_nAncestor) return O_K; if (!dlp_strlen(lpFlags)) ERRORRET(ERR_EXPECTAFTER,"compiler options","MSVCFLAGS:",0,NOT_EXEC); dlp_strcpy(m_lpsMsvcFlags,lpFlags); return O_K; }
INT16 CGEN_PROTECTED CCgen::OnClass() { char lpClassname[L_INPUTLINE+1]; GetNextDefToken(lpClassname); if (m_nAncestor > 1) return O_K; if (!dlp_strlen(lpClassname)) return IERROR(this,ERR_EXPECTAFTER,"name","CLASS:",0); char bad = 0; if (!m_bNoIdcheck) IF_NOK(dlp_is_valid_id(IDT_CLASS,lpClassname,&bad)) IERROR(this,ERR_BADIDCHAR,lpClassname,bad,0); if (m_nAncestor == 1) dlp_strcpy(m_lpsDlcParent,lpClassname); else dlp_strcpy(m_lpsClass,lpClassname); return O_K; }
INT16 CGEN_PROTECTED CCgen::OnAuthor() { const char* lpAuthor = GetRestOfDefLine(); if (m_nAncestor) return O_K; if (!dlp_strlen(lpAuthor)) ERRORRET(ERR_EXPECTAFTER,"author name","AUTHOR:",0,NOT_EXEC); dlp_strcpy(m_lpsAuthor,lpAuthor); return O_K; }
/* * Manual page at process.def */ INT32 CGEN_PUBLIC CProcess::Start() { const SMic* pMic = NULL; // Method invocation context of Start() CFunction* iCaller = NULL; // Function calling Start() CFunction* iFnc = NULL; // Process function StkItm* pStkItm = NULL; // Stack item INT32 nArgs = 0; // Number of process function arguments // Validate and initialize // ------------------------------------ if (m_nState!=0) // Not virginal return IERROR(this,PRC_CANTSTART,"multiple starts not allowed",0,0); // Forget it! if (!(pMic = CDlpObject_MicGet(_this))) return -1; // Get method invocation context iCaller = (CFunction*)CDlpObject_OfKind("function",pMic->iCaller); // Get calling CFunction if (!iCaller) return -1; // Must be a function! // Initialize process // ------------------------------------ sprintf(m_psTmpFile,"%s%ld",dlp_tempnam(NULL,"~dLabPro#process#"),(long)dlp_time());// Initialize temp. file name prefix // Marshal arguments // ------------------------------------ if (!(pStkItm=iCaller->StackGet(0))) return IERROR(this,PRC_TOOFEWARGS,0,0,0);// Get stack top if (pStkItm->nType==T_INSTANCE) // Stack top is an instance iFnc = (CFunction*)CDlpObject_OfKind("function",pStkItm->val.i); // Get function to be called if (iFnc) // This process is a function call { // >> IFIELD_RESET(CDlpObject,"dto"); // Create data transfer object nArgs = CData_GetNRecs(iFnc->m_idArg); // Get number of function arguments Marshal(m_iDto,iCaller,nArgs); // Marshal arguments for transfer } // << else // This process is a program call dlp_strcpy(m_psCmdLine,iCaller->PopString(0)); // Get program command line #ifdef USE_FORK if (iFnc) // This process is a function call { // >> m_hPid=fork(); // Fork the process if(m_hPid>0){ // Parent process >> m_nState |= PRC_DATASENT; // Remember data have been sent m_nState |= PRC_RUNNING; // Set running flag m_hThread = 0; // Clear thread handle return O_K; // Everything is fine } // << if(m_hPid==0) return DoJobFork(iCaller,iFnc); // The child process runs the function return IERROR(this,PRC_CANTSTART,"fork() failed",0,0); // On error (fid<0) we return } // << #endif // Start job in watcher thread // ------------------------------------ m_hPid = 0; // Reset process id SendData(); // Send transfer data m_hThread = dlp_create_thread(DoJob,this); // Do the job and watch it return O_K; // Yo! }
/** * Packs a stack item into the data transfer object <code>iDto</code>. If the * stack item is an instance, the function will create a copy in * <code>iDto</code>. If the stack item is a boolean, numeric or string value, * the function will create a variable holding that value in <code>iDto</code>. * * @param iDto * the data transfer object (must not be <code>NULL</code>) * @param idSign * the signature table (may be <code>NULL</code>, if not * <code>NULL</code> the item will be added to the signature) * @param pStkItm * the stack item to pack (see documentation of <code>CFunction</code>) * @param psName * the object name (if <code>NULL</code> or empty, a default name will * be used ) */ void CGEN_PROTECTED CProcess::Pack ( CDlpObject* iDto, CData* idSign, StkItm* pStkItm, const char* psName ) { CDlpObject* iDst = 0; // Packed instance INT32 nArg = -1; // Argument index in signature char sBuf[L_NAMES]; // Packed instance name buffer // Validate and initialize // ------------------------------------ if (!iDto ) return; // Need data transfer object! if (!pStkItm) return; // Need stack item! dlp_strcpy(sBuf,psName); // Copy custom instance name if (idSign) nArg = CData_AddRecs(idSign,1,10); // Add element to signature // Pack // ------------------------------------ if (pStkItm->nType==T_INSTANCE && pStkItm->val.i!=NULL) // Pack an instance { // >> CDlpObject* iSrc = pStkItm->val.i; // Get pointer to instance if (dlp_strlen(sBuf)==0) dlp_strcpy(sBuf,iSrc->m_lpInstanceName); // No custom name -> use inst. name iDst = CDlpObject_Instantiate(iDto,iSrc->m_lpClassName,sBuf,FALSE); // Created packed instance iDst->Copy(iSrc); // Copy content } // << else // Pack a boolean, number or string { // >> if (dlp_strlen(sBuf)==0) sprintf(sBuf,"arg%ld",(long)nArg); // No custom name -> make a name iDst = CDlpObject_Instantiate(iDto,"var",sBuf,FALSE); // Create a variable to pack into switch (pStkItm->nType) // Branch for variable type { // | case T_BOOL : ((CVar*)iDst)->Bset(pStkItm->val.b); break; // Pack a boolean case T_COMPLEX: ((CVar*)iDst)->Vset(pStkItm->val.n); break; // Pack a number case T_STRING : ((CVar*)iDst)->Sset(pStkItm->val.s); break; // Pack a string } // | } // << if (idSign) CData_Sstore(idSign,sBuf,nArg,0); // Write signature }
INT16 CFWTproc::GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CFWTproc::CreateInstance; lpClassWord->ex.fct.lpfInstall = CFWTproc::InstallProc; lpClassWord->ex.fct.lpProject = "FWTproc"; lpClassWord->ex.fct.lpBaseClass = "FBAproc"; lpClassWord->lpComment = "Base class for fast discrete wavelet transformation."; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CFWTproc"; lpClassWord->ex.fct.lpAuthor = "Soeren Wittenberg"; dlp_strcpy(lpClassWord->lpName ,"FWTproc"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.0"); return O_K; }
INT16 CPMproc::GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CPMproc::CreateInstance; lpClassWord->ex.fct.lpfInstall = CPMproc::InstallProc; lpClassWord->ex.fct.lpProject = "PMproc"; lpClassWord->ex.fct.lpBaseClass = "-"; lpClassWord->lpComment = "Base class for pitch calculation."; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CPMproc"; lpClassWord->ex.fct.lpAuthor = "Guntram Strecha"; dlp_strcpy(lpClassWord->lpName ,"PMproc"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.0 DLP"); return O_K; }
INT16 CFFTproc::GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CFFTproc::CreateInstance; lpClassWord->ex.fct.lpfInstall = CFFTproc::InstallProc; lpClassWord->ex.fct.lpProject = "FFTproc"; lpClassWord->ex.fct.lpBaseClass = "FBAproc"; lpClassWord->lpComment = "FFT class based on FBAproc"; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CFFTproc"; lpClassWord->ex.fct.lpAuthor = "Matthias Eichner"; dlp_strcpy(lpClassWord->lpName ,"FFTproc"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.0 DLP"); return O_K; }
INT16 CDgen::GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CDgen::CreateInstance; lpClassWord->ex.fct.lpfInstall = CDgen::InstallProc; lpClassWord->ex.fct.lpProject = "dgen"; lpClassWord->ex.fct.lpBaseClass = "-"; lpClassWord->lpComment = "Document parser and generator"; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CDgen"; lpClassWord->ex.fct.lpAuthor = "Matthias Wolff"; dlp_strcpy(lpClassWord->lpName ,"DGen"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.0.1"); return O_K; }
INT16 CLPCproc::GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CLPCproc::CreateInstance; lpClassWord->ex.fct.lpfInstall = CLPCproc::InstallProc; lpClassWord->ex.fct.lpProject = "LPCproc"; lpClassWord->ex.fct.lpBaseClass = "FBAproc"; lpClassWord->lpComment = "Linear prediction coding (LPC) analysis and synthesis"; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CLPCproc"; lpClassWord->ex.fct.lpAuthor = "Guntram Strecha"; dlp_strcpy(lpClassWord->lpName ,"LPCproc"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.0 DLP"); return O_K; }
INT16 CHFAproc::GetClassInfo(SWord* lpClassWord) { if (!lpClassWord) return NOT_EXEC; dlp_memset(lpClassWord,0,sizeof(SWord)); lpClassWord->nWordType = WL_TYPE_FACTORY; lpClassWord->nFlags = CS_AUTOACTIVATE; lpClassWord->ex.fct.lpfFactory = (LP_FACTORY_PROC)CHFAproc::CreateInstance; lpClassWord->ex.fct.lpfInstall = CHFAproc::InstallProc; lpClassWord->ex.fct.lpProject = "HFAproc"; lpClassWord->ex.fct.lpBaseClass = "FBAproc"; lpClassWord->lpComment = "Harmonicity based feature analysis"; lpClassWord->ex.fct.lpAutoname = ""; lpClassWord->ex.fct.lpCname = "CHFAproc"; lpClassWord->ex.fct.lpAuthor = "Rico Petrick, Mike Lorenz"; dlp_strcpy(lpClassWord->lpName ,"HFAproc"); dlp_strcpy(lpClassWord->lpObsname ,""); dlp_strcpy(lpClassWord->ex.fct.version.no ,"1.0"); return O_K; }
INT16 CGEN_PROTECTED CCgen::OnAutoinstance() { char lpAutoname[L_INPUTLINE+1]; GetNextDefToken(lpAutoname); if (m_bMainProject) return IERROR(this,ERR_INVALKEY,"AUTOINSTANCE:","MAIN:",0); if (m_nAncestor) return O_K; if (!dlp_strlen(lpAutoname)) return IERROR(this,ERR_EXPECTIDAFTER,"name","AUTOINSTANCE:",0); dlp_strcpy(m_lpsAutoname,lpAutoname); m_nCSXXX |= CS_AUTOINSTANCE; return O_K; }
/** * Get data initializer '{ ... }' from command line and store into token list * lpsInit. * <h3>Note</h3> * <p>You must setup the method invocation context <code>m_lpMic</code> (see * <a href="dlpinst.html"><code class="link">CDlpInstance</code></a>) before * calling this method. Otherwise it will do noting.</p> * * @param lpsInit Pointer to character buffer to store initializer in. The * tokens will be separated by nulls '\0', opening and closing * curly braces will not be included! The token list will be * terminated with a double null "\0\0". * @param nLen Maximal number of characters to place on lpsInit (including * the terminal double null) * @param bForce If TRUE the method does not seek for the opening curly brace * but starts reading initializers until it encounters a closing * curly brace '}'. A leading opening curly brace will, however, * be tolerated. If FALSE the method <i>expects</i> an opening * curly brace and does not read any initializers if no leading * opening brace is found. * @return The number of initializers read */ INT32 CGEN_PROTECTED CData_ReadInitializer ( CData* _this, char* lpsInit, INT32 nLen, BOOL bForce ) { const char* lpsToken; /* Current token */ INT32 nCnt; /* Token counter */ INT32 nPos; /* Position in output buffer */ BOOL bStor; /* Store next token */ /* Initialize */ /* --------------------------------- */ if (!CDlpObject_MicGet(BASEINST(_this))) return 0; /* Need invocation context */ if (!lpsInit) return 0; /* Need output buffer */ dlp_memset(lpsInit,0,nLen); /* Clear output buffer */ /* Do initializers follow? */ /* --------------------------------- */ lpsToken = MIC_NEXTTOKEN_FORCE; /* Ruthlessly get next token */ if (!lpsToken || dlp_strcmp(lpsToken,"{")!=0) /* No or not the "{" token */ { /* >> */ if (bForce) IERROR(_this,DATA_NOTFOUND,"Constant initializer ","'{'",0); /* If there should be some-> error */ if (lpsToken) MIC_REFUSETOKEN; /* Wrong token -> push it back */ return 0; /* Now get out'a here */ } /* << */ /* Get 'em tokens */ /* --------------------------------- */ for (nCnt=0,nPos=0,bStor=TRUE; ; nCnt++) /* Infinitely ... */ { /* >> */ lpsToken = MIC_NEXTTOKEN_FORCE; /* Ruthlessly get next token */ if (!lpsToken) return IERROR(_this,DATA_HERESCAN,"}",0,0); /* No more tokens -> forget it */ if (dlp_strcmp(lpsToken,"}")==0) break; /* End token -> get out'a here */ if (nLen<nPos+(INT32)dlp_strlen(lpsToken)+2) bStor = FALSE; /* Cannot store more tokens :( */ if (!bStor) continue; /* Ignore ALL following tokens */ dlp_strcpy(&lpsInit[nPos],lpsToken); /* Store token */ nPos+=(INT32)dlp_strlen(&lpsInit[nPos])+1; /* Set next token pointer */ } /* << */ return nCnt; /* Return number of tokens read */ }
/** * Changes the current working directory. If <code>bCreate</code> is * <code>TRUE</code> and the directory does not exists, <code>dlp_chdir</code> * will create the directory. <code>dlp_chdir</code> is capable of creating a * tree of non-existing directories at once. * * @param lpsDirname Destination directory * @param bCreate Create directory if not exists * @return 0 if successful, an error code (or -1) if not sucessful */ INT16 dlp_chdir(const char* lpsDirname, BOOL bCreate) { char lpsDir[L_PATH]; char* tx; INT16 nError; if (dlp_strlen(lpsDirname)==0) return 0; nError = (INT16)chdir(lpsDirname); if (nError == 0 || !bCreate) return nError; /* Try to create path */ dlp_memset(lpsDir,0,L_PATH); dlp_strcpy(lpsDir,lpsDirname); /* Change into the furthest existing directory */ tx = &lpsDir[dlp_strlen(lpsDir)-1]; while (tx != lpsDir) { while (tx!=lpsDir && *tx != '\\' && *tx != '/') tx--; if (tx!=lpsDir) *tx=0; if (chdir(lpsDir) == 0) break; } if (tx!=lpsDir) tx++; /* Create remaining sub directories */ while (tx[1]) { #if (defined __MSOS || defined __WIN32) nError = (INT16)mkdir(tx); #else nError = (INT16)mkdir(tx,0xFFFF); #endif if (nError) return nError; nError = (INT16)chdir(tx); if (nError) return nError; while (*tx++); } /* Should have worked... */ return 0; }
INT16 CDlpFile_Reset(CDlpObject* __this, BOOL bResetMembers) { GET_THIS_VIRTUAL_RV(CDlpFile,NOT_EXEC); DEBUGMSG(-1,"CDlpFile_Reset; (bResetMembers=%d)",(int)bResetMembers,0,0); { /*{{CGEN_RESETCODE */ CData* idFlistData; char lpsB1[255]; char lpsB2[255]; char lpsB3[ 32]; char lpsB4[255]; if (_this->m_idFlistData==NULL) IFIELD_RESET(CData,"flist_data"); IFIELD_RESET(CData,"recfile"); dlp_strcpy(lpsB1,_this->m_lpsFlist); dlp_strcpy(lpsB2,_this->m_lpsPath); dlp_strcpy(lpsB3,_this->m_lpsExt); dlp_strcpy(lpsB4,_this->m_lpsSep); idFlistData = AS(CData,_this->m_idFlistData); _this->m_idFlistData = NULL; RESET; _this->m_idFlistData = BASEINST(idFlistData); dlp_strcpy(_this->m_lpsFlist,lpsB1); dlp_strcpy(_this->m_lpsPath ,lpsB2); dlp_strcpy(_this->m_lpsExt ,lpsB3); dlp_strcpy(_this->m_lpsSep ,lpsB4); _this->m_nLen = CData_GetNRecs(AS(CData,_this->m_idFlistData)); /*}}CGEN_RESETCODE */ } return O_K; }
/** * Create an absolute or full path name for the specified relative path name. * * @param lpsAbsPath * Pointer to a buffer to be filled with the absolute path. * @param lpsRelPath * Pointer to a null-terminated string containing the relative path. * @param nMaxLen * Maximum length of the absolute path name buffer * (<code>lpsAbsPath</code>). * @return <code>lpsAbsPath</code> if successful, <code>NULL</code> in case of * errors. */ char* dlp_fullpath(char* lpsAbsPath, const char* lpsRelPath, INT32 nMaxLen) { char lpsCwd [L_PATH+1]; /* Saved current working directory */ char lpsDir [L_PATH+1]; /* Directory part of lpsRelPath */ char lpsFile[L_PATH+1]; /* Filename part of lpsRelPath */ struct stat filestat; /* File status struct */ if (!lpsAbsPath || nMaxLen<=0) return NULL; /* No buffer, no service! */ *lpsAbsPath='\0'; /* Initialize result to empty string */ dlp_splitpath(lpsRelPath,lpsDir,lpsFile); /* Split relative path */ if (!dlp_strlen(lpsDir)) dlp_strcpy(lpsDir,"."); /* No directory -> use current one */ if(getcwd(lpsCwd,L_PATH)==NULL) return NULL; /* Save current working directory */ if (dlp_chdir(lpsDir,FALSE)!=0) { dlp_chdir(lpsCwd,FALSE); return NULL; } /* Change to relative directory ... */ if(getcwd(lpsDir,L_PATH)==NULL) return NULL; /* ... and determine its full path */ dlp_chdir(lpsCwd,FALSE); /* Change back to saved working dir. */ if (nMaxLen<(INT32)(dlp_strlen(lpsDir)+dlp_strlen(lpsFile)+2)) return NULL; /* Check return buffer size */ sprintf(lpsAbsPath,"%s%c%s",lpsDir,C_DIR,lpsFile); /* Create absolute path */ #ifdef _WINDOWS /* -- WINDOZE --> */ dlp_strreplace(lpsAbsPath,"\\","/"); /* Replace backslashes by slashes */ /* dlp_strlwr(lpsAbsPath); */ /* Convert to lower case */ #endif /* <-- */ if (stat(lpsAbsPath,&filestat)!=0) return NULL; /* Check file status (must exist) */ return lpsAbsPath; /* Return pointer to buffer */ }
INT32 CGEN_PRIVATE CProcess::DoJobFork(CFunction *iCaller, CFunction *iFnc) { CData* idSign = NULL; // Signature table in iDto CDlpObject* iArg = NULL; // Argument Object INT32 nArg = -1; // Argument loop counter char sArg[L_NAMES]; // Current argument name char lpsCmd[256]; // String buffer // Initialize // ------------------------------------ idSign = (CData*)CDlpObject_OfKind("data", // Get signature table CDlpObject_FindInstance(m_iDto,PRC_S_IDSIGN)); // | // Push arguments on Stack // ------------------------------------ for (nArg=CData_GetNRecs(idSign)-1; nArg>0; nArg--) // Loop over signature table { // >> dlp_strcpy(sArg,CData_Sfetch(idSign,nArg,0)); // Get argument name iArg = CDlpObject_FindInstance(m_iDto,sArg); // Find argument in iDto if (CDlpObject_OfKind("var",iArg)) switch(AS(CVar,iArg)->m_nType){ // Primitve data types >> case T_BOOL : iCaller->PushLogic (AS(CVar,iArg)->m_bBVal); break; // Push bool case T_COMPLEX: iCaller->PushNumber(AS(CVar,iArg)->m_nNVal); break; // Push number case T_STRING : iCaller->PushString(AS(CVar,iArg)->m_lpsSVal); break; // Push string default: iCaller->PushNumber(CMPLX(0.)); break; // Default: push something }else iCaller->PushInstance(iArg); // Push instances } // << // Post commands in queue // ------------------------------------ iCaller->PostCommand(CData_Sfetch(idSign,0,0),NULL,-1,FALSE); // Put in queue: run the function snprintf(lpsCmd,255,"%s.dto %s -marshal_retval;", // Put in queue: save return value this->m_lpInstanceName,this->m_lpInstanceName); // | iCaller->PostCommand(lpsCmd,NULL,-1,FALSE); // | snprintf(lpsCmd,255,"\"%s.xml\" %s.dto /xml /zip -save;", // Put in queue: save data transfer object m_psTmpFile,this->m_lpInstanceName); // | iCaller->PostCommand(lpsCmd,NULL,-1,FALSE); // | iCaller->PostCommand("quit;",NULL,-1,FALSE); // Put in queue: Quit the client process return O_K; // Ok, run the queue }
/** * Unpacks the data transfer object <code>iDto</code> into <code>iCaller</code>. */ void CGEN_PROTECTED CProcess::Unmarshal(CDlpObject* iDto, CFunction* iCaller) { CData* idSign = NULL; // Signature table in iDto CDlpObject* iSrc = NULL; // Source object CDlpObject* iDst = NULL; // Destination object INT32 nArg = -1; // Argument loop counter char sArg[L_NAMES]; // Current argument name // Initialize // ------------------------------------ idSign = (CData*)CDlpObject_OfKind("data", // Get signature table CDlpObject_FindInstance(iDto,PRC_S_IDSIGN)); // | // Unmarshal arguments // ------------------------------------ for (nArg=1; nArg<CData_GetNRecs(idSign); nArg++) // Loop over signature table { // >> dlp_strcpy(sArg,CData_Sfetch(idSign,nArg,0)); // Get argument name iSrc = CDlpObject_FindInstance(iDto,sArg); // Find argument in iDto if (CDlpObject_OfKind("var",iSrc)) continue; // Ignore primitve data types iDst = CDlpObject_FindInstance(iCaller,sArg); // Find argument in iCaller if (!iDst) continue; // Not there -> nothing to do iDst->Copy(iSrc); // Copy unmarshaled arg. to caller } // << // Unmarshal return value // ------------------------------------ iSrc = CDlpObject_FindInstance(iDto,PRC_S_RETV); // Find return value in iDto if (CDlpObject_OfKind("var",iSrc)) // Return value is a primitive switch (((CVar*)iSrc)->m_nType) // Branch for type { // | case T_BOOL : iCaller->PushLogic (((CVar*)iSrc)->m_bBVal ); break; // Push a boolean case T_DOUBLE : // Push a number case T_COMPLEX: iCaller->PushNumber(((CVar*)iSrc)->m_nNVal ); break; // Push a complex number case T_STRING : iCaller->PushString(((CVar*)iSrc)->m_lpsSVal); break; // Push a string } // | else if (iSrc) // Return value is an instance iCaller->PushInstance(iSrc); // Push it }