📄 jsp_parser.cpp
字号:
cout << endl << Message( "Kernel configuration file generator\n" " -id, --kernel_id=filename : Specify the name of ID assignment file\n" " -cfg,--kernel_cfg=filename : Specify the name of kernel configuration file\n" " -z, --nonzero : Do not output ZERO macro and related definitions\n", "カ〖ネル菇喇ファイルの栏喇\n" " -id, --kernel_id=ファイル叹 : ID充碰ファイルの叹涟を回年します\n" " -cfg,--kernel_cfg=ファイル叹 : カ〖ネル菇喇ファイルの叹涟を回年します\n" " -z, --nonzero : ZEROマクロの蝗脱を扩嘎します\n"); return; } if(!findOption(parameter,"cfg","kernel_cfg",&work)) work.assign("kernel_cfg.c"); stream = new mpstrstream(work); stream->createpart("header","include",TASK,SEMAPHORE,EVENTFLAG,DATAQUEUE,MAILBOX,FIXEDSIZEMEMORYPOOL,CYCLICHANDLER,INTERRUPTHANDLER,EXCEPTIONHANDLER,INITIALIZER,OBJECT_INITIALIZER,"others",NULL); parameter["/file/kernel_cfg"] = stream; if(!findOption(parameter,"id","kernel_id",&work)) work.assign("kernel_id.h"); stream = new mpstrstream(work); stream->createpart("header","body","footer",NULL); (*stream)["header"] << "#ifndef __KERNEL_ID_H\n#define __KERNEL_ID_H\n\n"; (*stream)["footer"] << "\n#endif /* __KERNEL_ID_H */\n"; parameter["/file/kernel_id"] = stream; restrict_zero = findOption(parameter,"z","zero"); activateComponent();}void ConfigurationFileGenerator::createObjectDefinition(mpstrstream * out, Directory & container, int flag, ...){ Directory * scope; Directory * id; const char * buffer; string work; map<int, Directory *> sorter; map<int, Directory *>::iterator psorter; va_list vl; int i; va_start(vl, flag); id = container.openChild("/", "prefix", container.getKey().c_str(), NULL); work = string(va_arg(vl, const char *)); (*id)["id"] = work; for(i=0; i<(signed)work.size(); i++) work[i] = work[i] - 'a' + 'A'; (*id)["ID"] = work; if((flag & SHORT_ID) != 0) { work = string(va_arg(vl, const char *)); (*id)["sid"] = work; for(i=0; i<(signed)work.size(); i++) work[i] = work[i] - 'a' + 'A'; (*id)["SID"] = work; }else { (*id)["sid"] = (*id)["id"].toString(); (*id)["SID"] = (*id)["ID"].toString(); } work = container.getKey(); out->moveto(work); if((flag & INIT) != 0 && container.size() != 0) container["/" OBJECT_INITIALIZER].addChild(new Directory(work)); (*out) << "\t/* " << Message("Object initializer [%s]","オブジェクト介袋步ブロック [%s]").format(work.c_str()) << " */\n\n"; if((flag & HEADER) != 0) (*out) << "#include \"" << work << ".h\"\n\n"; if((flag & TNUM) != 0) { (*out) << id->format("#define TNUM_$(ID)ID ") << container.size() << "\n\n"; (*out) << id->format("const ID tmax_$(id)id = (TMIN_$(ID)ID + TNUM_$(ID)ID - 1);\n\n"); } if((flag & TNUMNO) != 0) { (*out) << id->format("#define TNUM_$(ID)NO ") << container.size() << "\n\n"; (*out) << id->format("const UINT tnum_$(id)no = TNUM_$(ID)NO;\n\n"); } /* ID界にソ〖ト (この箕爬で息戎が澄年しているはずなので·チェックはしない) */ if((flag & (BUFFER|DEFINITION)) != 0) { i = 0; scope = container.getFirstChild(); while(scope != 0) { sorter[scope->toInteger(i++)] = scope; scope = scope->getNext(); } } if((flag & BUFFER) != 0 && container.size() != 0) { buffer = va_arg(vl, const char *); psorter = sorter.begin(); while(psorter != sorter.end()) { (*out) << (*psorter).second->format(buffer) << '\n'; psorter ++; } (*out) << '\n'; } if((flag & DEFINITION) != 0) { buffer = va_arg(vl, const char *); if(container.size() != 0) { (*out) << id->format("const $(SID)INIB $(sid)inib_table[TNUM_$(ID)") << ( (flag & TNUMNO) != 0 ? "NO" : "ID") << "] = {\n"; psorter = sorter.begin(); while(psorter != sorter.end()) { (*out) << "\t{" << (*psorter).second->format(buffer) << '}'; psorter ++; if(psorter != sorter.end()) (*out) << ','; (*out) << '\n'; } (*out) << "};\n\n"; }else if( !restrict_zero ) (*out) << id->format("__ZERO(const $(SID)INIB,$(sid)inib_table);\n"); } if((flag & CONTROLBLOCK) != 0) { if(container.size() != 0) (*out) << id->format("$(SID)CB $(sid)cb_table[TNUM_$(ID)ID];\n\n"); else if( !restrict_zero ) (*out) << id->format("__ZERO($(SID)CB, $(sid)cb_table);\n\n"); }}void ConfigurationFileGenerator::body(Directory & container){ Directory * scope; mpstrstream * out; string work; /* kernel_id.hの叫蜗 */ out = reinterpret_cast<mpstrstream *>(container("/file/kernel_id")->toPointer()); out->moveto("body"); scope = container("/identifier")->getFirstChild(); while(scope != 0) { (*out) << "#define " << scope->getKey() << " " << scope->toInteger() << endl; scope = scope->getNext(); } /* kernel_cfg.cの叫蜗 */ out = reinterpret_cast<mpstrstream *>(container("/file/kernel_cfg")->toPointer()); out->moveto("header"); (*out) << "/* Configured by [" << container["/Parameter/#cmdline"].toString() << "] */\n\n"; (*out) << "#include \"jsp_kernel.h\"\n#include \"kernel_id.h\"\n\n#if TKERNEL_PRVER >= 0x1011\n #define CFG_INTHDR_ENTRY(inthdr) INTHDR_ENTRY(inthdr)\n #define CFG_EXCHDR_ENTRY(exchdr) EXCHDR_ENTRY(exchdr)\n#else\n #define CFG_INTHDR_ENTRY(inthdr) INTHDR_ENTRY(ENTRY(inthdr), inthdr)\n #define CFG_EXCHDR_ENTRY(exchdr) EXCHDR_ENTRY(ENTRY(exchdr), exchdr)\n #define INT_ENTRY(inthdr) ENTRY(inthdr)\n #define EXC_ENTRY(exchdr) ENTRY(exchdr)\n#endif\n\n"; if( !restrict_zero ) { if(!findOption(container, "ZERO","ZERO",&work)) work.assign("x y[0]"); (*out) << "#ifdef _MSC_VER\n #define __ZERO(x,y) _declspec(naked) void y(void){}\n#else\n #define __ZERO(x,y) " << work << "\n#endif\n\n"; } /* INCLUDE */ out->moveto(INCLUDEFILE); scope = container(OBJECTTREE "/" INCLUDEFILE)->getFirstChild(); (*out) << "\t/* " << Message("User specified include files","ユ〖ザ年盗のインクル〖ドファイル") << "*/\n"; while(scope != 0) { (*out) << "#include " << scope->toString() << endl; scope = scope->getNext(); } (*out) << '\n'; /* TASK */ createObjectDefinition(out, container[OBJECTTREE "/" TASK], HEADER|TNUM|SHORT_ID|BUFFER|DEFINITION|CONTROLBLOCK|INIT,"tsk", "t", "static VP __stack_$@[TCOUNT_VP($(stksz))];","$(tskatr), (VP_INT)($(exinf)), $(task), INT_PRIORITY($(itskpri)), TROUND_VP($(stksz)), __stack_$@, $(texatr), $(texrtn)"); /* SEMAPHORE */ createObjectDefinition(out, container[OBJECTTREE "/" SEMAPHORE], HEADER|TNUM|DEFINITION|CONTROLBLOCK|INIT,"sem", "$(sematr), $(isemcnt), $(maxsem)"); /* EVENTFLAG */ createObjectDefinition(out, container[OBJECTTREE "/" EVENTFLAG], HEADER|TNUM|DEFINITION|CONTROLBLOCK|INIT,"flg", "$(flgatr), $(iflgptn)"); /* DATAQUEUE */ createObjectDefinition(out, container[OBJECTTREE "/" DATAQUEUE], HEADER|TNUM|BUFFER|DEFINITION|CONTROLBLOCK|INIT,"dtq", "#if ($(dtqcnt)) > 0\n static VP_INT __dataqueue_$@[$(dtqcnt)];\n#else\n #define __dataqueue_$@ NULL\n#endif","$(dtqatr), $(dtqcnt), __dataqueue_$@"); /* MAILBOX */ createObjectDefinition(out, container[OBJECTTREE "/" MAILBOX], HEADER|TNUM|DEFINITION|CONTROLBLOCK|INIT,"mbx","$(mbxatr), $(mbxpri)"); /* FIXEDSIZEMEMORYPOOL */ createObjectDefinition(out, container[OBJECTTREE "/" FIXEDSIZEMEMORYPOOL], HEADER|TNUM|BUFFER|DEFINITION|CONTROLBLOCK|INIT,"mpf","static VP __fixedsize_memorypool_$@[TCOUNT_VP($(blksz)) * (($(blkcnt)))];","$(mpfatr), TROUND_VP($(blksz)), __fixedsize_memorypool_$@, (VP)(((VB *)__fixedsize_memorypool_$@ + sizeof(__fixedsize_memorypool_$@))"); /* CYCLICHANDLER */ createObjectDefinition(out, container[OBJECTTREE "/" CYCLICHANDLER], HEADER|TNUM|DEFINITION|CONTROLBLOCK|INIT,"cyc","$(cycatr),$(exinf),$(cychdr),$(cyctim),$(cycphs)"); /* INTERRUPTHANDLER */ createObjectDefinition(out, container[OBJECTTREE "/" INTERRUPTHANDLER], HEADER|BUFFER|TNUMNO|DEFINITION|INIT,"inh","CFG_INTHDR_ENTRY($(inthdr));","$@,$(inhatr),INT_ENTRY($(inthdr))"); /* EXCEPTIONHANDLER */ createObjectDefinition(out, container[OBJECTTREE "/" EXCEPTIONHANDLER], HEADER|BUFFER|TNUMNO|DEFINITION|INIT,"exc","CFG_EXCHDR_ENTRY($(exchdr));","$@,$(excatr),EXC_ENTRY($(exchdr))"); /* オブジェクト介袋步ル〖チン */ out->moveto(OBJECT_INITIALIZER); (*out) << "\t/* " << Message("Object initialization routine","オブジェクト介袋步ル〖チン") << " */\n\n"; (*out) << "void\nobject_initialize(void)\n{\n"; scope = container["/" OBJECT_INITIALIZER].getFirstChild(); while(scope != 0) { (*out) << '\t' << scope->toString() << "_initialize();\n"; scope = scope->getNext(); } (*out) << "}\n\n"; /* 介袋步ハンドラ */ out->moveto(INITIALIZER); (*out) << "\t/* " << Message("Initialization handler","介袋步ハンドラ弹瓢ル〖チン") << " */\n\n"; (*out) << "void\ncall_inirtn(void)\n{\n"; scope = container[OBJECTTREE "/" INITIALIZER].getFirstChild(); while(scope != 0) { (*out) << scope->format("\t$(inirtn)( (VP_INT)($(exinf)) );\n"); scope = scope->getNext(); } (*out) << "}\n\n"; (*out) << "void\ncall_finrtn(void)\n{\n"; scope = container[OBJECTTREE "/" FINALIZER].getLastChild(); while(scope != 0) { (*out) << scope->format("\t$(finrtn)( (VP_INT)($(exinf)) );\n"); scope = scope->getPrev(); } (*out) << "}\n\n"; out->moveto("others"); (*out) << "#include \"time_event.h\"\n\nTMEVTN tmevt_heap[TNUM_TSKID + TNUM_CYCID];\n\n"; if(findOption(container,"obj","dump-object",&work)) { if(work.empty()) work.assign("kernel_obj.dat"); fstream f(work.c_str(),ios::out|ios::binary); if(f.is_open()) { container[OBJECTTREE].Store(&f); f.close(); }else Exception(" Failed to open the file %s for storing object definitions"," オブジェクト攫鼠を呈羌するためのファイル(%s)が倡けません").format(work.c_str()); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -