smipl-devel Mailing List for SMIPL (Page 3)
Brought to you by:
the_student
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(18) |
Aug
(27) |
Sep
(9) |
Oct
(5) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(7) |
Feb
(4) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <the...@us...> - 2009-08-03 15:39:57
|
Revision: 24 http://smipl.svn.sourceforge.net/smipl/?rev=24&view=rev Author: the_student Date: 2009-08-03 15:39:47 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Disabled some debugging output Added safety for push and pop Modified Paths: -------------- smipl-devel/MDS.h smipl-devel/SVM.h smipl-devel/String.h Modified: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h 2009-08-02 20:13:28 UTC (rev 23) +++ smipl-devel/MDS.h 2009-08-03 15:39:47 UTC (rev 24) @@ -56,19 +56,17 @@ do { if(!strcmp(Current->Name,Name)) { Current->Value=value; - clog<<"\""<<Name<<"\" found"<<endl; + //clog<<"\""<<Name<<"\" found"<<endl; isfound=true; break; } - else {clog<<"\""<<Current->Name<<"\" != "<<Name<<endl; + else {//clog<<"\""<<Current->Name<<"\" != "<<Name<<endl; Current=Current->Next;} }while(Current->Next!=NULL); } pthread_mutex_unlock(&MDS); - if((!isfound)==0) { - value_t value; - Atof(Name,&value); - if(value!=0) { + if((!isfound)) { + if(!isdigit(Name[0])) { //clog<<"\""<<Name<<"\" not found, creating"<<endl; MDS_Create(Name, value); } Modified: smipl-devel/SVM.h =================================================================== --- smipl-devel/SVM.h 2009-08-02 20:13:28 UTC (rev 23) +++ smipl-devel/SVM.h 2009-08-03 15:39:47 UTC (rev 24) @@ -27,19 +27,20 @@ pthread_mutex_lock(&Admin); if(JailAddress==NULL) {str1=new char[strlen(Name)+1];strcpy(str1,"/");} else {str1=new char[strlen(Name)+strlen(JailAddress)];strcpy(str1,JailAddress);} - pthread_mutex_unlock(&Admin); strcat(str1,Name); ::MDS_Get(str1, value); delete[]str1; + end:pthread_mutex_unlock(&Admin); } void MDS_Set(char* Name, value_t value) { pthread_mutex_lock(&Admin); if(JailAddress==NULL) {str1=new char[strlen(Name)+1];strcpy(str1,"/");} else {str1=new char[strlen(Name)+strlen(JailAddress)];strcpy(str1,JailAddress);} - pthread_mutex_unlock(&Admin); strcat(str1,Name); ::MDS_Set(str1, value); delete[]str1; + end: + pthread_mutex_unlock(&Admin); } void Push(value_t data) { value_t stack_p; @@ -55,6 +56,7 @@ void Pop(value_t* data) { value_t stack_p; MDS_Get("Stack/P", &stack_p); + if(stack_p>0) { char* StackPName=new char[255]; pthread_mutex_lock(&Admin); sprintf(StackPName, "%sStack/%d",JailAddress,(int)stack_p); @@ -62,6 +64,7 @@ MDS_Set("Stack/P", stack_p-1); pthread_mutex_unlock(&Admin); delete[]StackPName; + } } void Atof(char *a, value_t* b) { pthread_mutex_lock(&doatof); @@ -92,7 +95,7 @@ Address=this->StartAddress; ID=pthread_self(); pthread_mutex_unlock(&Admin); - MDS_Set("Stack/P", -1); + MDS_Set("Stack/P", 0); while(1) { strcpy(cmd.str,Program[Address]); cmd.Split(); @@ -127,4 +130,5 @@ if(Address>100000) break; if(Address<0) break; } + } Modified: smipl-devel/String.h =================================================================== --- smipl-devel/String.h 2009-08-02 20:13:28 UTC (rev 23) +++ smipl-devel/String.h 2009-08-03 15:39:47 UTC (rev 24) @@ -32,31 +32,9 @@ char argv[10][80],str[80],Op; void Split(bool force_disallow_spaces_in_names=false) { pthread_mutex_lock(&do_split); - c1=0; - c2=0; argc=0; bool disallow_spaces_in_names=true; - NextArg: - while(str[c1]!='\0') { - c2=0; - while(!isgraph(str[c1])) {if(str[c1++]=='\0') break;} - while(!isDelim(str[c1],disallow_spaces_in_names)) { - if(argc!=0) argv[argc][c2]=str[c1]; - else argv[argc][c2]=toupper(str[c1]); - if((argv[argc][c2]=='"')&&(!force_disallow_spaces_in_names)) disallow_spaces_in_names=!disallow_spaces_in_names; - c1++; - c2++; - } - if(str[c1]=='<') {Op='<';} - if(str[c1]=='>') {Op='>';} - if(str[c1]=='=') {Op='=';} - argv[argc][c2]='\0'; - if(Op!=0) c1++; - if(strlen(argv[argc])>0) argc++; - } - end:pthread_mutex_unlock(&do_split); - -<<<<<<< .mine c1=0; + c1=0; Op=0; while(str[c1]!=0) { c2=0; @@ -80,25 +58,5 @@ } Parse:pthread_mutex_unlock(&do_split); -======= NextArg: - while(str[c1]!='\0') { - c2=0; - while(!isgraph(str[c1])) {if(str[c1++]=='\0') break;} - while(!isDelim(str[c1],disallow_spaces_in_names)) { - argv[argc][c2]=str[c1]; - if((argv[argc][c2]=='"')&&(!force_disallow_spaces_in_names)) disallow_spaces_in_names=!disallow_spaces_in_names; - c1++; - c2++; - } - if(str[c1]=='<') {Op='<';} - if(str[c1]=='>') {Op='>';} - if(str[c1]=='=') {Op='=';} - argv[argc][c2]='\0'; - if(Op!=0) c1++; - if(strlen(argv[argc])>0) argc++; - if(str[c1]==0) break; - cout<<"."; - } - end:pthread_mutex_unlock(&do_split); ->>>>>>> .theirs } +} }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-08-02 20:13:37
|
Revision: 23 http://smipl.svn.sourceforge.net/smipl/?rev=23&view=rev Author: the_student Date: 2009-08-02 20:13:28 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Numerous fixes Modified Paths: -------------- smipl-devel/Console.h smipl-devel/MDS.h smipl-devel/SVM.h smipl-devel/String.h Modified: smipl-devel/Console.h =================================================================== --- smipl-devel/Console.h 2009-08-02 16:26:51 UTC (rev 22) +++ smipl-devel/Console.h 2009-08-02 20:13:28 UTC (rev 23) @@ -25,9 +25,9 @@ cin.getline(command.str, 256); if(!EnterProgram) cout<<endl; command.Split(); - cout<<"str="<<command.str<<": "; - cout<<"argc="<<command.argc<<": "; - for(int a=1;a<=command.argc;a++) cout<<"\""<<command.argv[a-1]<<"\""<<endl; + //cout<<"str="<<command.str<<": "; + //cout<<"argc="<<command.argc<<": "; + //for(int a=1;a<=command.argc;a++) cout<<"\""<<command.argv[a-1]<<"\""<<endl; if(EnterProgram) { strcpy(Program[(int)number],command.str); if(!stricmp(command.str,"PROGRAM END")) {EnterProgram=false;cout<<endl;} @@ -35,7 +35,8 @@ if(number>100000) {EnterProgram=false;cout<<endl;} continue; } - else { + else { + if(strlen(command.argv[0])==0) continue; if(!stricmp(command.argv[0], "QUIT")) break; if(!stricmp(command.argv[0], "EXIT")) break; if(!stricmp(command.str, "PROGRAM START")) {EnterProgram=true;number=0;continue;} Modified: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h 2009-08-02 16:26:51 UTC (rev 22) +++ smipl-devel/MDS.h 2009-08-02 20:13:28 UTC (rev 23) @@ -40,9 +40,16 @@ //if((isnan(*value))||(isinf(*value))) *value=0; pthread_mutex_unlock(&MDS); } +pthread_mutex_t doatof=PTHREAD_MUTEX_INITIALIZER; +void Atof(char *a, value_t* b) { + pthread_mutex_lock(&doatof); + MDS_Get(a,b); + if(*b==0) *b=atof(a); + pthread_mutex_unlock(&doatof); +} void MDS_Set(char* Name, value_t value) { + pthread_mutex_lock(&doSet); pthread_mutex_lock(&MDS); - pthread_mutex_lock(&doSet); MDS_Piece* Current=&MDS_0; bool isfound=false; if(MDS_0.Next!=NULL) { @@ -56,8 +63,15 @@ else {clog<<"\""<<Current->Name<<"\" != "<<Name<<endl; Current=Current->Next;} }while(Current->Next!=NULL); + } pthread_mutex_unlock(&MDS); - if(!isfound) {clog<<"\""<<Name<<"\" not found, creating"<<endl; MDS_Create(Name, value);} + if((!isfound)==0) { + value_t value; + Atof(Name,&value); + if(value!=0) { + //clog<<"\""<<Name<<"\" not found, creating"<<endl; + MDS_Create(Name, value); + } } else pthread_mutex_unlock(&MDS); pthread_mutex_unlock(&doSet); @@ -89,10 +103,3 @@ } pthread_mutex_unlock(&MDS); } -pthread_mutex_t doatof=PTHREAD_MUTEX_INITIALIZER; -void Atof(char *a, value_t* b) { - pthread_mutex_lock(&doatof); - MDS_Get(a,b); - if(*b==0) *b=atof(a); - pthread_mutex_unlock(&doatof); -} Modified: smipl-devel/SVM.h =================================================================== --- smipl-devel/SVM.h 2009-08-02 16:26:51 UTC (rev 22) +++ smipl-devel/SVM.h 2009-08-02 20:13:28 UTC (rev 23) @@ -52,6 +52,17 @@ pthread_mutex_unlock(&Admin); delete[]StackPName; } + void Pop(value_t* data) { + value_t stack_p; + MDS_Get("Stack/P", &stack_p); + char* StackPName=new char[255]; + pthread_mutex_lock(&Admin); + sprintf(StackPName, "%sStack/%d",JailAddress,(int)stack_p); + MDS_Get(StackPName, data); + MDS_Set("Stack/P", stack_p-1); + pthread_mutex_unlock(&Admin); + delete[]StackPName; + } void Atof(char *a, value_t* b) { pthread_mutex_lock(&doatof); MDS_Get(a,b); @@ -87,14 +98,31 @@ cmd.Split(); if(!stricmp(cmd.argv[0],"STOP")) break; if(!stricmp(cmd.str,"PROGRAM END")) break; - if(!stricmp(cmd.argv[0],"GOTO")) if(cmd.argc>=2) {Atof(cmd.argv[1],&number);Address=number-1;} - if(!stricmp(cmd.argv[0],"SET")) for(int a=1;a<cmd.argc;a+=2) {Atof(cmd.argv[a+1],&number);MDS_Set(cmd.argv[a], number);} - if(!stricmp(cmd.argv[0],"ADD")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number+=number2;}MDS_Set(cmd.argv[1], number);} - if(!stricmp(cmd.argv[0],"SUBRACT")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number-=number2;}MDS_Set(cmd.argv[1], number);} - if(!stricmp(cmd.argv[0],"MULTIPLY")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number*=number2;}MDS_Set(cmd.argv[1], number);} - if(!stricmp(cmd.argv[0],"DIVIDE")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number/=number2;}MDS_Set(cmd.argv[1], number);} + if(!stricmp(cmd.argv[0],"SET")) for(int a=1;a<cmd.argc;a+=2) {Atof(cmd.argv[a+1],&number);MDS_Set(cmd.argv[a], number);} + //Arithmetic + if(!stricmp(cmd.argv[0],"ADD")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number+=number2;}MDS_Set(cmd.argv[1], number);} + if(!stricmp(cmd.argv[0],"SUBRACT")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number-=number2;}MDS_Set(cmd.argv[1], number);} + if(!stricmp(cmd.argv[0],"MULTIPLY")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number*=number2;}MDS_Set(cmd.argv[1], number);} + if(!stricmp(cmd.argv[0],"DIVIDE")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number/=number2;}MDS_Set(cmd.argv[1], number);} + + //Stack + if(!stricmp(cmd.argv[0],"PUSH")) {for(int a=1;a<cmd.argc;a++) {Atof(cmd.argv[a],&number);Push(number);}} + if(!stricmp(cmd.argv[0],"POP")) {for(int a=1;a<cmd.argc;a++) {Pop(&number);MDS_Set(cmd.argv[a], number);}} + + //Flow control + if(!stricmp(cmd.argv[0],"GOTO")) if(cmd.argc>=2) {Atof(cmd.argv[1],&number);Address=number-1;} + if(!stricmp(cmd.argv[0],"GOSUB")) if(cmd.argc>=2) {Push((value_t)Address);Atof(cmd.argv[1],(value_t*)&Address);Address-=1;} + if(!stricmp(cmd.argv[0],"RETURN")) { + Pop((value_t*)&Address); + for(int a=1;a<cmd.argc;a++) { + Atof(cmd.argv[1], &number); + MDS_Set("RETURN", number); + Push(number); + } + } + Address++; if(Address>100000) break; if(Address<0) break; Modified: smipl-devel/String.h =================================================================== --- smipl-devel/String.h 2009-08-02 16:26:51 UTC (rev 22) +++ smipl-devel/String.h 2009-08-02 20:13:28 UTC (rev 23) @@ -41,6 +41,50 @@ c2=0; while(!isgraph(str[c1])) {if(str[c1++]=='\0') break;} while(!isDelim(str[c1],disallow_spaces_in_names)) { + if(argc!=0) argv[argc][c2]=str[c1]; + else argv[argc][c2]=toupper(str[c1]); + if((argv[argc][c2]=='"')&&(!force_disallow_spaces_in_names)) disallow_spaces_in_names=!disallow_spaces_in_names; + c1++; + c2++; + } + if(str[c1]=='<') {Op='<';} + if(str[c1]=='>') {Op='>';} + if(str[c1]=='=') {Op='=';} + argv[argc][c2]='\0'; + if(Op!=0) c1++; + if(strlen(argv[argc])>0) argc++; + } + end:pthread_mutex_unlock(&do_split); + +<<<<<<< .mine c1=0; + Op=0; + while(str[c1]!=0) { + c2=0; + while(!isDelim(str[c1],disallow_spaces_in_names)) { + if(argc!=0) argv[argc][c2]=str[c1]; + else argv[argc][c2]=toupper(str[c1]); + if(argv[argc][c2]=='"') disallow_spaces_in_names=!disallow_spaces_in_names; + c1++; + c2++; + } + if(str[c1]=='<') {Op='<';} + if(str[c1]=='>') {Op='>';} + if(str[c1]=='=') {Op='=';} + argv[argc][c2]='\0'; + if(Op!=0) c1++; + if(strlen(argv[argc])>0) argc++; + NextArg: + //cout<<"."; + if(str[c1]=='\0') goto Parse; + while(!isgraph(str[c1])) {if(str[c1++]=='\0') break;} + } + + Parse:pthread_mutex_unlock(&do_split); +======= NextArg: + while(str[c1]!='\0') { + c2=0; + while(!isgraph(str[c1])) {if(str[c1++]=='\0') break;} + while(!isDelim(str[c1],disallow_spaces_in_names)) { argv[argc][c2]=str[c1]; if((argv[argc][c2]=='"')&&(!force_disallow_spaces_in_names)) disallow_spaces_in_names=!disallow_spaces_in_names; c1++; @@ -56,5 +100,5 @@ cout<<"."; } end:pthread_mutex_unlock(&do_split); - } +>>>>>>> .theirs } }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-08-02 16:27:09
|
Revision: 22 http://smipl.svn.sourceforge.net/smipl/?rev=22&view=rev Author: the_student Date: 2009-08-02 16:26:51 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Fixed LICENSING Fixed bunch Modified Paths: -------------- smipl-devel/Console.h smipl-devel/Error.h smipl-devel/FS.h smipl-devel/FS.zip smipl-devel/Init.h smipl-devel/SMIPL-header.h smipl-devel/SMIPL.cpp smipl-devel/SVM.h smipl-devel/String.h Modified: smipl-devel/Console.h =================================================================== --- smipl-devel/Console.h 2009-08-01 23:02:14 UTC (rev 21) +++ smipl-devel/Console.h 2009-08-02 16:26:51 UTC (rev 22) @@ -1,3 +1,18 @@ +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ bool Console(int argc, char** argv) { char **rc, **i, *str; bool EnterProgram=false; @@ -10,8 +25,9 @@ cin.getline(command.str, 256); if(!EnterProgram) cout<<endl; command.Split(); - //cout<<"argc="<<command.argc<<": "; - //for(int a=1;a<=command.argc;a++) cout<<"\""<<command.argv[a-1]<<"\""<<endl; + cout<<"str="<<command.str<<": "; + cout<<"argc="<<command.argc<<": "; + for(int a=1;a<=command.argc;a++) cout<<"\""<<command.argv[a-1]<<"\""<<endl; if(EnterProgram) { strcpy(Program[(int)number],command.str); if(!stricmp(command.str,"PROGRAM END")) {EnterProgram=false;cout<<endl;} Modified: smipl-devel/Error.h =================================================================== --- smipl-devel/Error.h 2009-08-01 23:02:14 UTC (rev 21) +++ smipl-devel/Error.h 2009-08-02 16:26:51 UTC (rev 22) @@ -1,3 +1,18 @@ +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ char* LastSysError; char* GetLastSysError() { return LastSysError; Modified: smipl-devel/FS.h =================================================================== --- smipl-devel/FS.h 2009-08-01 23:02:14 UTC (rev 21) +++ smipl-devel/FS.h 2009-08-02 16:26:51 UTC (rev 22) @@ -1,3 +1,18 @@ +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ pthread_mutex_t FS=PTHREAD_MUTEX_INITIALIZER; void Catalog(char *Directory) { Modified: smipl-devel/FS.zip =================================================================== (Binary files differ) Modified: smipl-devel/Init.h =================================================================== --- smipl-devel/Init.h 2009-08-01 23:02:14 UTC (rev 21) +++ smipl-devel/Init.h 2009-08-02 16:26:51 UTC (rev 22) @@ -1,3 +1,18 @@ +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ bool Init(int argc, char **argv) { try{ SetLastSysError(""); Modified: smipl-devel/SMIPL-header.h =================================================================== --- smipl-devel/SMIPL-header.h 2009-08-01 23:02:14 UTC (rev 21) +++ smipl-devel/SMIPL-header.h 2009-08-02 16:26:51 UTC (rev 22) @@ -1,3 +1,18 @@ +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ //C libraries #include <cstdio> #include <cstdlib> Modified: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-08-01 23:02:14 UTC (rev 21) +++ smipl-devel/SMIPL.cpp 2009-08-02 16:26:51 UTC (rev 22) @@ -1,3 +1,18 @@ +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ #include "SMIPL-header.h" int main(int argc, char **argv) { cout<<"Setting up version globals"<<endl; Modified: smipl-devel/SVM.h =================================================================== --- smipl-devel/SVM.h 2009-08-01 23:02:14 UTC (rev 21) +++ smipl-devel/SVM.h 2009-08-02 16:26:51 UTC (rev 22) @@ -1,3 +1,18 @@ +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ char Program[100000][80]; struct SVM_Thread{ pthread_t ID; Modified: smipl-devel/String.h =================================================================== --- smipl-devel/String.h 2009-08-01 23:02:14 UTC (rev 21) +++ smipl-devel/String.h 2009-08-02 16:26:51 UTC (rev 22) @@ -41,8 +41,7 @@ c2=0; while(!isgraph(str[c1])) {if(str[c1++]=='\0') break;} while(!isDelim(str[c1],disallow_spaces_in_names)) { - if(argc!=0) argv[argc][c2]=str[c1]; - else argv[argc][c2]=toupper(str[c1]); + argv[argc][c2]=str[c1]; if((argv[argc][c2]=='"')&&(!force_disallow_spaces_in_names)) disallow_spaces_in_names=!disallow_spaces_in_names; c1++; c2++; @@ -53,6 +52,8 @@ argv[argc][c2]='\0'; if(Op!=0) c1++; if(strlen(argv[argc])>0) argc++; + if(str[c1]==0) break; + cout<<"."; } end:pthread_mutex_unlock(&do_split); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-08-02 00:16:01
|
Revision: 21 http://smipl.svn.sourceforge.net/smipl/?rev=21&view=rev Author: the_student Date: 2009-08-01 23:02:14 +0000 (Sat, 01 Aug 2009) Log Message: ----------- Fixed crash Modified Paths: -------------- smipl-devel/Console.h Modified: smipl-devel/Console.h =================================================================== --- smipl-devel/Console.h 2009-08-01 12:49:19 UTC (rev 20) +++ smipl-devel/Console.h 2009-08-01 23:02:14 UTC (rev 21) @@ -52,8 +52,7 @@ else cout<<"Help not found!"<<endl; } else { - str=new char[strlen(command.argv[1])+strlen("/Help/")]; - strtoupper(command.argv[1]); + //strtoupper(command.argv[1]); str=strdup("/Help/",command.argv[1]); if(PHYSFS_exists(str))PrintFile(str); else cout<<"Help for "<<command.argv[1]<<" not found!"<<endl; @@ -62,20 +61,19 @@ continue; } if(!stricmp(command.argv[0], "ABOUT")) { - if(command.argc==1) { - if(PHYSFS_exists("/About/About"))PrintFile("/About/About"); + if(command.argc==1){ + if(PHYSFS_exists("/About/About")) PrintFile("About"); else cout<<"About not found!"<<endl; - } - else { - str=new char[strlen(command.argv[1])+strlen("/About/")]; - strtoupper(command.argv[1]); + } + else { + //strtoupper(command.argv[1]); str=strdup("/About/",command.argv[1]); - if(PHYSFS_exists(command.argv[1]))PrintFile(str); + if(PHYSFS_exists(str))PrintFile(str); else cout<<"About "<<command.argv[1]<<" not found!"<<endl; delete[]str; - } + } continue; - } + } if(!stricmp(command.argv[0], "REINIT")) { DeInit(); Init(argc,argv); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-08-01 12:49:29
|
Revision: 20 http://smipl.svn.sourceforge.net/smipl/?rev=20&view=rev Author: the_student Date: 2009-08-01 12:49:19 +0000 (Sat, 01 Aug 2009) Log Message: ----------- Fixed missing strcpy in About, and Help. Added strtoupper(char*) Made Help/About file access upper-case only Modified Paths: -------------- smipl-devel/Console.h smipl-devel/String.h Modified: smipl-devel/Console.h =================================================================== --- smipl-devel/Console.h 2009-08-01 10:42:16 UTC (rev 19) +++ smipl-devel/Console.h 2009-08-01 12:49:19 UTC (rev 20) @@ -53,6 +53,8 @@ } else { str=new char[strlen(command.argv[1])+strlen("/Help/")]; + strtoupper(command.argv[1]); + str=strdup("/Help/",command.argv[1]); if(PHYSFS_exists(str))PrintFile(str); else cout<<"Help for "<<command.argv[1]<<" not found!"<<endl; delete[]str; @@ -66,6 +68,8 @@ } else { str=new char[strlen(command.argv[1])+strlen("/About/")]; + strtoupper(command.argv[1]); + str=strdup("/About/",command.argv[1]); if(PHYSFS_exists(command.argv[1]))PrintFile(str); else cout<<"About "<<command.argv[1]<<" not found!"<<endl; delete[]str; Modified: smipl-devel/String.h =================================================================== --- smipl-devel/String.h 2009-08-01 10:42:16 UTC (rev 19) +++ smipl-devel/String.h 2009-08-01 12:49:19 UTC (rev 20) @@ -1,11 +1,19 @@ pthread_mutex_t do_split=PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t do_strdup=PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t do_strtoupper=PTHREAD_MUTEX_INITIALIZER; + char *strdup(char *a, char* b) { char* str=new char[strlen(a)+strlen(b)]; strcpy(str,a); strcat(str,a); return str; } +void strtoupper(char*a) { + pthread_mutex_lock(&do_strtoupper); + for(unsigned int i=0;a[i]!=0;i++) a[i]=toupper(a[i]); + pthread_mutex_unlock(&do_strtoupper); +} + bool isDelim(char a, bool disallow_spaces=true, bool disallow_comparison=true) { if(disallow_spaces)if(a==' ') return true; if(a=='\n') return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-08-01 10:42:25
|
Revision: 19 http://smipl.svn.sourceforge.net/smipl/?rev=19&view=rev Author: the_student Date: 2009-08-01 10:42:16 +0000 (Sat, 01 Aug 2009) Log Message: ----------- Added Design document.rtf - Partially complete Added borrowed code from SuperTux physfs_stream.cpp/hpp, removed unnecessary lines Fixed MDS_Set bug where MDS data would not be found on second run, so the line SET A, would first give 'A=0', then 'A=0,A=0', but first A would always be referred to. Modified Paths: -------------- smipl-devel/MDS.h smipl-devel/SMIPL-header.h Added Paths: ----------- smipl-devel/Design document.rtf smipl-devel/FS.zip smipl-devel/physfs_stream.cpp smipl-devel/physfs_stream.hpp Added: smipl-devel/Design document.rtf =================================================================== --- smipl-devel/Design document.rtf (rev 0) +++ smipl-devel/Design document.rtf 2009-08-01 10:42:16 UTC (rev 19) @@ -0,0 +1,173 @@ +{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1044\deflangfe1044\themelang1044\themelangfe0\themelangcs0{\fonttbl{\f0\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f34\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria Math;} +{\f37\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;}{\flomajor\f31500\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} +{\fdbmajor\f31501\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhimajor\f31502\fbidi \froman\fcharset0\fprq2{\*\panose 02040503050406030204}Cambria;} +{\fbimajor\f31503\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\flominor\f31504\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;} +{\fdbminor\f31505\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\fhiminor\f31506\fbidi \fswiss\fcharset0\fprq2{\*\panose 020f0502020204030204}Calibri;} +{\fbiminor\f31507\fbidi \froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f39\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\f40\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} +{\f42\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\f43\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\f44\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f45\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} +{\f46\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\f47\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f379\fbidi \froman\fcharset238\fprq2 Cambria Math CE;}{\f380\fbidi \froman\fcharset204\fprq2 Cambria Math Cyr;} +{\f382\fbidi \froman\fcharset161\fprq2 Cambria Math Greek;}{\f383\fbidi \froman\fcharset162\fprq2 Cambria Math Tur;}{\f386\fbidi \froman\fcharset186\fprq2 Cambria Math Baltic;}{\f409\fbidi \fswiss\fcharset238\fprq2 Calibri CE;} +{\f410\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\f412\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\f413\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;}{\f416\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;} +{\flomajor\f31508\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\flomajor\f31509\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flomajor\f31511\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;} +{\flomajor\f31512\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\flomajor\f31513\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flomajor\f31514\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} +{\flomajor\f31515\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\flomajor\f31516\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbmajor\f31518\fbidi \froman\fcharset238\fprq2 Times New Roman CE;} +{\fdbmajor\f31519\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fdbmajor\f31521\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbmajor\f31522\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;} +{\fdbmajor\f31523\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fdbmajor\f31524\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbmajor\f31525\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;} +{\fdbmajor\f31526\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fhimajor\f31528\fbidi \froman\fcharset238\fprq2 Cambria CE;}{\fhimajor\f31529\fbidi \froman\fcharset204\fprq2 Cambria Cyr;} +{\fhimajor\f31531\fbidi \froman\fcharset161\fprq2 Cambria Greek;}{\fhimajor\f31532\fbidi \froman\fcharset162\fprq2 Cambria Tur;}{\fhimajor\f31535\fbidi \froman\fcharset186\fprq2 Cambria Baltic;} +{\fbimajor\f31538\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fbimajor\f31539\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\fbimajor\f31541\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;} +{\fbimajor\f31542\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fbimajor\f31543\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\fbimajor\f31544\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);} +{\fbimajor\f31545\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fbimajor\f31546\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\flominor\f31548\fbidi \froman\fcharset238\fprq2 Times New Roman CE;} +{\flominor\f31549\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;}{\flominor\f31551\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\flominor\f31552\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;} +{\flominor\f31553\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\flominor\f31554\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\flominor\f31555\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;} +{\flominor\f31556\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\fdbminor\f31558\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fdbminor\f31559\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} +{\fdbminor\f31561\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fdbminor\f31562\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fdbminor\f31563\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);} +{\fdbminor\f31564\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fdbminor\f31565\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fdbminor\f31566\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);} +{\fhiminor\f31568\fbidi \fswiss\fcharset238\fprq2 Calibri CE;}{\fhiminor\f31569\fbidi \fswiss\fcharset204\fprq2 Calibri Cyr;}{\fhiminor\f31571\fbidi \fswiss\fcharset161\fprq2 Calibri Greek;}{\fhiminor\f31572\fbidi \fswiss\fcharset162\fprq2 Calibri Tur;} +{\fhiminor\f31575\fbidi \fswiss\fcharset186\fprq2 Calibri Baltic;}{\fbiminor\f31578\fbidi \froman\fcharset238\fprq2 Times New Roman CE;}{\fbiminor\f31579\fbidi \froman\fcharset204\fprq2 Times New Roman Cyr;} +{\fbiminor\f31581\fbidi \froman\fcharset161\fprq2 Times New Roman Greek;}{\fbiminor\f31582\fbidi \froman\fcharset162\fprq2 Times New Roman Tur;}{\fbiminor\f31583\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);} +{\fbiminor\f31584\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\fbiminor\f31585\fbidi \froman\fcharset186\fprq2 Times New Roman Baltic;}{\fbiminor\f31586\fbidi \froman\fcharset163\fprq2 Times New Roman (Vietnamese);}} +{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0; +\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\*\defchp \f31506\fs22\lang1044\langfe1033\langfenp1033 }{\*\defpap \ql \li0\ri0\sa200\sl276\slmult1 +\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }\noqfpromote {\stylesheet{\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 +\ltrch\fcs0 \f31506\fs22\lang1044\langfe1033\cgrid\langnp1044\langfenp1033 \snext0 \sqformat \spriority0 \styrsid16326907 Normal;}{\*\cs10 \additive \ssemihidden \sunhideused \spriority1 Default Paragraph Font;}{\* +\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\sa200\sl276\slmult1 +\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1044\langfe1033\cgrid\langnp1044\langfenp1033 \snext11 \ssemihidden \sunhideused \sqformat Normal Table;}{ +\s15\ql \li0\ri0\sa200\sl360\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs22\alang1025 \ltrch\fcs0 \fs24\lang1044\langfe1033\cgrid\langnp1044\langfenp1033 +\sbasedon0 \snext15 \slink16 \sqformat \spriority0 \styrsid8734358 Skole oppgaver;}{\*\cs16 \additive \rtlch\fcs1 \af0 \ltrch\fcs0 \f0\fs24 \sbasedon10 \slink15 \slocked \spriority0 \styrsid8734358 Skole oppgaver Tegn;}}{\*\rsidtbl \rsid1459910 +\rsid3355339\rsid6102557\rsid6818599\rsid7751057\rsid8734358\rsid9511180\rsid12322588\rsid13581978\rsid14248534\rsid16326907\rsid16461033\rsid16719760}{\mmathPr\mmathFont34\mbrkBin0\mbrkBinSub0\msmallFrac0\mdispDef1\mlMargin0\mrMargin0\mdefJc1 +\mwrapIndent1440\mintLim0\mnaryLim1}{\info{\author Martin Sundhaug}{\operator Martin Sundhaug}{\creatim\yr2009\mo7\dy31\hr12\min32}{\revtim\yr2009\mo7\dy31\hr12\min44}{\version1}{\edmins12}{\nofpages1}{\nofwords61}{\nofchars326}{\nofcharsws386} +{\vern32771}{\*\saveprevpict}}{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}}\paperw11906\paperh16838\margl1417\margr1417\margt1417\margb1417\gutter0\ltrsect +\deftab708\widowctrl\ftnbj\aenddoc\hyphhotz425\trackmoves1\trackformatting1\donotembedsysfont1\relyonvml0\donotembedlingdata0\grfdocevents0\validatexml1\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0 +\showxmlerrors1\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1417\dgvorigin1417\dghshow1\dgvshow1 +\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct +\asianbrkrule\rsidroot16461033\newtblstyruls\nogrowautofit\usenormstyforlist\noindnmbrts\felnbrelev\nocxsptable\indrlsweleven\noafcnsttbl\afelev\utinl\hwelev\spltpgpar\notcvasp\notbrkcnstfrctbl\notvatxbx\krnprsnet\cachedcolbal \nouicompat \fet0 +{\*\wgrffmtfilter 2450}\nofeaturethrottle1\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sectrsid16326907\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}} +{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}} +{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9 +\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ltrpar\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 +\f31506\fs22\lang1044\langfe1033\cgrid\langnp1044\langfenp1033 {\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\lang1033\langfe1033\langnp1033\insrsid16461033\charrsid14248534 Init}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\b\lang1033\langfe1033\langnp1033\insrsid14248534\charrsid14248534 ():}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid7751057\charrsid7751057 \tab \tab Sets up the programming e}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\lang1033\langfe1033\langnp1033\insrsid7751057 nvironment, clears errors, }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid3355339 and sets up physfs, and file system structure.}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\lang1033\langfe1033\langnp1033\insrsid9511180 Outputs comments on functions executed, and checks return value. If any errors }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid1459910 are }{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\lang1033\langfe1033\langnp1033\insrsid9511180 detect}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid1459910 ed, }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\lang1033\langfe1033\langnp1033\insrsid1459910\charrsid1459910 SetLastSysError} +{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid1459910 is called with an }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid12322588 suitable error message.}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\lang1033\langfe1033\langnp1033\insrsid16461033\charrsid7751057 +\par }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\lang1033\langfe1033\langnp1033\insrsid16461033\charrsid14248534 MDS_Create}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\lang1033\langfe1033\langnp1033\insrsid14248534\charrsid14248534 ():}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\lang1033\langfe1033\langnp1033\insrsid13581978 \tab }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid13581978\charrsid13581978 creates a new }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid6102557 o}{ +\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid6102557\charrsid13581978 bject }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid6102557 of}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\lang1033\langfe1033\langnp1033\insrsid13581978 type }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\lang1033\langfe1033\langnp1033\insrsid13581978\charrsid14248534 MDS_Piece}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid16719760 +with specified name and }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid6102557 value, and adds it, using }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \b\lang1033\langfe1033\langnp1033\insrsid6102557\charrsid14248534 MDS_Add}{\rtlch\fcs1 +\af31507 \ltrch\fcs0 \b\lang1033\langfe1033\langnp1033\insrsid14248534\charrsid14248534 ()}{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid6102557 , to the MDS.}{\rtlch\fcs1 \af31507 \ltrch\fcs0 +\lang1033\langfe1033\langnp1033\insrsid16326907 +\par }{\rtlch\fcs1 \af31507 \ltrch\fcs0 \lang1033\langfe1033\langnp1033\insrsid6102557\charrsid13581978 +\par }{\*\themedata 504b030414000600080000002100828abc13fa0000001c020000130000005b436f6e74656e745f54797065735d2e786d6cac91cb6ac3301045f785fe83d0b6d8 +72ba28a5d8cea249777d2cd20f18e4b12d6a8f843409c9df77ecb850ba082d74231062ce997b55ae8fe3a00e1893f354e9555e6885647de3a8abf4fbee29bbd7 +2a3150038327acf409935ed7d757e5ee14302999a654e99e393c18936c8f23a4dc072479697d1c81e51a3b13c07e4087e6b628ee8cf5c4489cf1c4d075f92a0b +44d7a07a83c82f308ac7b0a0f0fbf90c2480980b58abc733615aa2d210c2e02cb04430076a7ee833dfb6ce62e3ed7e14693e8317d8cd0433bf5c60f53fea2fe7 +065bd80facb647e9e25c7fc421fd2ddb526b2e9373fed4bb902e182e97b7b461e6bfad3f010000ffff0300504b030414000600080000002100a5d6a7e7c00000 +00360100000b0000005f72656c732f2e72656c73848fcf6ac3300c87ef85bd83d17d51d2c31825762fa590432fa37d00e1287f68221bdb1bebdb4fc7060abb08 +84a4eff7a93dfeae8bf9e194e720169aaa06c3e2433fcb68e1763dbf7f82c985a4a725085b787086a37bdbb55fbc50d1a33ccd311ba548b63095120f88d94fbc +52ae4264d1c910d24a45db3462247fa791715fd71f989e19e0364cd3f51652d73760ae8fa8c9ffb3c330cc9e4fc17faf2ce545046e37944c69e462a1a82fe353 +bd90a865aad41ed0b5b8f9d6fd010000ffff0300504b0304140006000800000021006b799616830000008a0000001c0000007468656d652f7468656d652f7468 +656d654d616e616765722e786d6c0ccc4d0ac3201040e17da17790d93763bb284562b2cbaebbf600439c1a41c7a0d29fdbd7e5e38337cedf14d59b4b0d592c9c +070d8a65cd2e88b7f07c2ca71ba8da481cc52c6ce1c715e6e97818c9b48d13df49c873517d23d59085adb5dd20d6b52bd521ef2cdd5eb9246a3d8b4757e8d3f7 +29e245eb2b260a0238fd010000ffff0300504b030414000600080000002100dcaae620950600004f1b0000160000007468656d652f7468656d652f7468656d65 +312e786d6cec594d6f1b4518be23f11f467b6f6327761a4775aad8b11b48d346b15bd4e37877bc3bcdecce6a669cd437d41e9190100571a012370e08a8d44a5c +caaf09144191fa1778676677bd13af49d24650417d48bcb3cffbfd31ef8caf5ebb1f33744884a43c697bf5cb350f91c4e7014dc2b6777bd8bfb4e621a9701260 +c613d2f6a6447ad736de7fef2a5e5711890902fa44aee3b6172995ae2f2d491f96b1bccc5392c0bb31173156f028c2a540e023e01bb3a5e55a6d7529c634f150 +8263607b6b3ca63eb9a480d4dbc879f718084894d40b3e1303cd993804061b1cd435424e659709748859db0331013f1a92fbca430c4b052fda5ecd7cbca58dab +4b783d23626a016d89ae6f3e195d46101c2c1b99221c1542ebfd46ebca56c1df00989ac7f57abd6eaf5ef03300ecfb60a9d5a5ccb3d15fab77729e2590fd3acf +bb5b6bd61a2ebec47f654ee756a7d369b6325d2c5303b25f1b73f8b5da6a6373d9c11b90c537e7f08dce66b7bbeae00dc8e257e7f0fd2badd5868b37a088d1e4 +600ead03daef67dc0bc898b3ed4af81ac0d76a197c86826c28b24b8b18f3442dcab518dfe3a20f000d6458d104a9694ac6d88724eee2782428d602f03ac1a537 +76c997734b5a1692bea0a96a7b1fa6180a62c6efd5f3ef5f3d7f8a8e1f3c3b7ef0d3f1c387c70f7eb48c1caa6d9c8465aa97df7ef6e7e38fd11f4fbf79f9e88b +6abc2ce37ffde1935f7efebc1a08e53353e7c5974f7e7bf6e4c5579ffefedda30af8a6c0a3327c486322d14d7284f6790c8619afb89a9391381fc530c2b44cb1 +99841227584ba9e0df539183be39c52c8b8ea34787b81ebc23a07d5401af4fee390a0f223151b442f24e143bc05dce59878b4a2fec685925370f2749582d5c4c +cab87d8c0fab647771e2c4b73749a16fe669e918de8d88a3e61ec389c221498842fa1d3f20a4c2babb943a7edda5bee0928f15ba4b5107d34a970ce9c8c9a619 +d1368d212ed32a9b21de8e6f76efa00e6755566f9143170955815985f243c21c375ec71385e32a96431cb3b2c36f6015552939980abf8ceb4905910e09e3a817 +1029ab686e09b0b714f41d0c1dab32ecbb6c1abb48a1e84115cf1b98f332728b1f74231ca755d8014da232f6037900298ad11e5755f05dee56887e8638e06461 +b8ef50e284fbf46e709b868e4ab304d16f2642c7125ab5d381639afc5d3b6614fab1cd818b6bc7d0005f7cfdb822b3ded646bc097b5255256c9f68bf8b70279b +6e978b80befd3d770b4f923d02693ebff1bc6bb9ef5aaef79f6fb98beaf9ac8d76d65ba1edeab9c10ec566448e174ec863cad8404d19b921cd902c619f08fab0 +a8e9cce1901427a63482af595f7770a1c0860609ae3ea22a1a44388501bbee6926a1cc588712a55cc2c1ce2c57f2d67818d2953d1636f581c1f60389d52e0fec +f28a5ececf05051bb3db84e6f0990b5ad10cce2a6ce54ac614cc7e1d6175add499a5d58d6aa6d539d20a932186f3a6c162e14d1840108c2de0e555389e6bd170 +30c18c04daef76efcdc362a270912192110e4816236df77c8cea264879ae989b00c89d8a18e943de295e2b496b69b66f20ed2c412a8b6b2c109747ef4da29467 +f02c4aba6e4f94234bcac5c91274d4f65acde5a6877c9cb6bd319c69e16b9c42d4a59ef9300be15ec857c2a6fda9c56caa7c16cd566e985b0475b8a6b07e9f33 +d8e903a9906a0bcbc8a6867995a5004bb424abff7213dc7a5106d84c7f0d2d56d62019fe352dc08f6e68c9784c7c550e766945fbce3e66ad944f141183283842 +233611fb18c2af5315ec09a884ab09d311f403dca3696f9b576e73ce8aae7c7b6570761db334c259bbd5259a57b2859b3a2e74304f25f5c0b64add8d71e737c5 +94fc0599524ee3ff99297a3f819b82954047c0875b5c8191aed7b6c7858a3874a134a27e5fc0e0607a07640bdcc5c26b482ab84b36ff0539d4ff6dcd591ea6ac +e1c0a7f669880485fd484582903d684b26fb4e6156cff62ecb92658c4c4695d495a9557b440e091bea1eb8aaf7760f4590eaa69b646dc0e04ee69ffb9c55d028 +d4434eb9de9c1e52ecbdb606fee9c9c7163318e5f66133d0e4fe2f54acd8552dbd21cff7deb221fac56ccc6ae45501c24a5b412b2bfbd754e19c5baded587316 +2f3773e5208af316c3623110a570df83f41fd8ffa8f0193169ac37d421df87de8ae08706cd0cd206b2fa921d3c906e9076710483935db4c9a45959d766a393f6 +5abe595ff0a45bc83de16cadd959e27d4e6717c3992bcea9c58b7476e661c7d7766da1ab21b2274b1496c6f941c604c6fca255fed5898fee41a0b7e07e7fc294 +34c904bf29090ca3e7c0d40114bf95684837fe020000ffff0300504b0304140006000800000021000dd1909fb60000001b010000270000007468656d652f7468 +656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c73848f4d0ac2301484f78277086f6fd3ba109126dd88d0add40384e4350d363f2451 +eced0dae2c082e8761be9969bb979dc9136332de3168aa1a083ae995719ac16db8ec8e4052164e89d93b64b060828e6f37ed1567914b284d262452282e319872 +0e274a939cd08a54f980ae38a38f56e422a3a641c8bbd048f7757da0f19b017cc524bd62107bd5001996509affb3fd381a89672f1f165dfe514173d9850528a2 +c6cce0239baa4c04ca5bbabac4df000000ffff0300504b01022d0014000600080000002100828abc13fa0000001c020000130000000000000000000000000000 +0000005b436f6e74656e745f54797065735d2e786d6c504b01022d0014000600080000002100a5d6a7e7c0000000360100000b00000000000000000000000000 +2b0100005f72656c732f2e72656c73504b01022d00140006000800000021006b799616830000008a0000001c0000000000000000000000000014020000746865 +6d652f7468656d652f7468656d654d616e616765722e786d6c504b01022d0014000600080000002100dcaae620950600004f1b00001600000000000000000000 +000000d10200007468656d652f7468656d652f7468656d65312e786d6c504b01022d00140006000800000021000dd1909fb60000001b01000027000000000000 +000000000000009a0900007468656d652f7468656d652f5f72656c732f7468656d654d616e616765722e786d6c2e72656c73504b050600000000050005005d010000950a00000000} +{\*\colorschememapping 3c3f786d6c2076657273696f6e3d22312e302220656e636f64696e673d225554462d3822207374616e64616c6f6e653d22796573223f3e0d0a3c613a636c724d +617020786d6c6e733a613d22687474703a2f2f736368656d61732e6f70656e786d6c666f726d6174732e6f72672f64726177696e676d6c2f323030362f6d6169 +6e22206267313d226c743122207478313d22646b3122206267323d226c743222207478323d22646b322220616363656e74313d22616363656e74312220616363 +656e74323d22616363656e74322220616363656e74333d22616363656e74332220616363656e74343d22616363656e74342220616363656e74353d22616363656e74352220616363656e74363d22616363656e74362220686c696e6b3d22686c696e6b2220666f6c486c696e6b3d22666f6c486c696e6b222f3e} +{\*\latentstyles\lsdstimax267\lsdlockeddef0\lsdsemihiddendef1\lsdunhideuseddef1\lsdqformatdef0\lsdprioritydef99{\lsdlockedexcept \lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority0 \lsdlocked0 Normal; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority9 \lsdlocked0 heading 1;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 2;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 3;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 4; +\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 5;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 6;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 7;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 8;\lsdqformat1 \lsdpriority9 \lsdlocked0 heading 9; +\lsdpriority39 \lsdlocked0 toc 1;\lsdpriority39 \lsdlocked0 toc 2;\lsdpriority39 \lsdlocked0 toc 3;\lsdpriority39 \lsdlocked0 toc 4;\lsdpriority39 \lsdlocked0 toc 5;\lsdpriority39 \lsdlocked0 toc 6;\lsdpriority39 \lsdlocked0 toc 7; +\lsdpriority39 \lsdlocked0 toc 8;\lsdpriority39 \lsdlocked0 toc 9;\lsdqformat1 \lsdpriority35 \lsdlocked0 caption;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority10 \lsdlocked0 Title;\lsdpriority1 \lsdlocked0 Default Paragraph Font; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority11 \lsdlocked0 Subtitle;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority22 \lsdlocked0 Strong;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority20 \lsdlocked0 Emphasis; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority59 \lsdlocked0 Table Grid;\lsdunhideused0 \lsdlocked0 Placeholder Text;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority1 \lsdlocked0 No Spacing; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 1;\lsdunhideused0 \lsdlocked0 Revision; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority34 \lsdlocked0 List Paragraph;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority29 \lsdlocked0 Quote;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority30 \lsdlocked0 Intense Quote; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 1; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 1;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 2; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 2;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 3;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 3; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 4; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 4; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 4; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 4; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 4;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 5; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 5;\lsdsemihidden0 \lsdunhideused0 \lsdpriority60 \lsdlocked0 Light Shading Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority61 \lsdlocked0 Light List Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority62 \lsdlocked0 Light Grid Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority63 \lsdlocked0 Medium Shading 1 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority64 \lsdlocked0 Medium Shading 2 Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority65 \lsdlocked0 Medium List 1 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority66 \lsdlocked0 Medium List 2 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority67 \lsdlocked0 Medium Grid 1 Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority68 \lsdlocked0 Medium Grid 2 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority69 \lsdlocked0 Medium Grid 3 Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority70 \lsdlocked0 Dark List Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdpriority71 \lsdlocked0 Colorful Shading Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority72 \lsdlocked0 Colorful List Accent 6;\lsdsemihidden0 \lsdunhideused0 \lsdpriority73 \lsdlocked0 Colorful Grid Accent 6; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority19 \lsdlocked0 Subtle Emphasis;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority21 \lsdlocked0 Intense Emphasis; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority31 \lsdlocked0 Subtle Reference;\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority32 \lsdlocked0 Intense Reference; +\lsdsemihidden0 \lsdunhideused0 \lsdqformat1 \lsdpriority33 \lsdlocked0 Book Title;\lsdpriority37 \lsdlocked0 Bibliography;\lsdqformat1 \lsdpriority39 \lsdlocked0 TOC Heading;}}{\*\datastore 010500000200000018000000 +4d73786d6c322e534158584d4c5265616465722e352e3000000000000000000000060000 +d0cf11e0a1b11ae1000000000000000000000000000000003e000300feff090006000000000000000000000001000000010000000000000000100000feffffff00000000feffffff0000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +fffffffffffffffffdfffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +ffffffffffffffffffffffffffffffff52006f006f007400200045006e00740072007900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016000500ffffffffffffffffffffffffec69d9888b8b3d4c859eaf6cd158be0f0000000000000000000000006061 +3fd3cb11ca01feffffff00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff00000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000 +000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffff000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000105000000000000}} \ No newline at end of file Added: smipl-devel/FS.zip =================================================================== (Binary files differ) Property changes on: smipl-devel/FS.zip ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h 2009-07-28 20:25:52 UTC (rev 18) +++ smipl-devel/MDS.h 2009-08-01 10:42:16 UTC (rev 19) @@ -36,7 +36,7 @@ pthread_mutex_lock(&MDS); *value=0; MDS_Piece* Current=&MDS_0; - while(Current->Next!=NULL) {if(!strcmp(Current->Name,Name)) *value=Current->Value;Current=Current->Next;} + while(Current->Next!=NULL) {if(!strcmp(Current->Name,Name)) {*value=Current->Value;break;}Current=Current->Next;} //if((isnan(*value))||(isinf(*value))) *value=0; pthread_mutex_unlock(&MDS); } @@ -45,9 +45,21 @@ pthread_mutex_lock(&doSet); MDS_Piece* Current=&MDS_0; bool isfound=false; - while(Current->Next!=NULL) {if(!strcmp(Current->Name,Name)) {Current->Value=value;isfound=true;}Current=Current->Next;} + if(MDS_0.Next!=NULL) { + do { + if(!strcmp(Current->Name,Name)) { + Current->Value=value; + clog<<"\""<<Name<<"\" found"<<endl; + isfound=true; + break; + } + else {clog<<"\""<<Current->Name<<"\" != "<<Name<<endl; + Current=Current->Next;} + }while(Current->Next!=NULL); pthread_mutex_unlock(&MDS); - if(!isfound) MDS_Create(Name, value); + if(!isfound) {clog<<"\""<<Name<<"\" not found, creating"<<endl; MDS_Create(Name, value);} + } + else pthread_mutex_unlock(&MDS); pthread_mutex_unlock(&doSet); } Modified: smipl-devel/SMIPL-header.h =================================================================== --- smipl-devel/SMIPL-header.h 2009-07-28 20:25:52 UTC (rev 18) +++ smipl-devel/SMIPL-header.h 2009-08-01 10:42:16 UTC (rev 19) @@ -10,6 +10,8 @@ //Div #include <pthread.h> #include <physfs.h> + +#include "physfs_stream.cpp" //SMIPL Core systems bool Init(int,char**); bool DeInit(); Added: smipl-devel/physfs_stream.cpp =================================================================== --- smipl-devel/physfs_stream.cpp (rev 0) +++ smipl-devel/physfs_stream.cpp 2009-08-01 10:42:16 UTC (rev 19) @@ -0,0 +1,176 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2006 Matthias Braun <ma...@br...> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#include "physfs_stream.hpp" + +#include <assert.h> +#include <stdexcept> +#include <sstream> + +IFileStreambuf::IFileStreambuf(const std::string& filename) +{ + // check this as PHYSFS seems to be buggy and still returns a + // valid pointer in this case + if(filename == "") { + throw std::runtime_error("Couldn't open file: empty filename"); + } + file = PHYSFS_openRead(filename.c_str()); + if(file == 0) { + std::stringstream msg; + msg << "Couldn't open file '" << filename << "': " + << PHYSFS_getLastError(); + throw std::runtime_error(msg.str()); + } +} + +IFileStreambuf::~IFileStreambuf() +{ + PHYSFS_close(file); +} + +int +IFileStreambuf::underflow() +{ + if(PHYSFS_eof(file)) { + return traits_type::eof(); + } + + PHYSFS_sint64 bytesread = PHYSFS_read(file, buf, 1, sizeof(buf)); + if(bytesread <= 0) { + return traits_type::eof(); + } + setg(buf, buf, buf + bytesread); + + return buf[0]; +} + +IFileStreambuf::pos_type +IFileStreambuf::seekpos(pos_type pos, std::ios_base::openmode) +{ + if(PHYSFS_seek(file, static_cast<PHYSFS_uint64> (pos)) == 0) { + return pos_type(off_type(-1)); + } + + // the seek invalidated the buffer + setg(buf, buf, buf); + return pos; +} + +IFileStreambuf::pos_type +IFileStreambuf::seekoff(off_type off, std::ios_base::seekdir dir, + std::ios_base::openmode mode) +{ + off_type pos = off; + PHYSFS_sint64 ptell = PHYSFS_tell(file); + + switch(dir) { + case std::ios_base::beg: + break; + case std::ios_base::cur: + if(off == 0) + return static_cast<pos_type> (ptell) - static_cast<pos_type> (egptr() - gptr()); + pos += static_cast<off_type> (ptell) - static_cast<off_type> (egptr() - gptr()); + break; + case std::ios_base::end: + pos += static_cast<off_type> (PHYSFS_fileLength(file)); + break; + default: +#ifdef DEBUG + assert(false); +#else + return pos_type(off_type(-1)); +#endif + } + + return seekpos(static_cast<pos_type> (pos), mode); +} + +//--------------------------------------------------------------------------- + +OFileStreambuf::OFileStreambuf(const std::string& filename) +{ + file = PHYSFS_openWrite(filename.c_str()); + if(file == 0) { + std::stringstream msg; + msg << "Couldn't open file '" << filename << "': " + << PHYSFS_getLastError(); + throw std::runtime_error(msg.str()); + } + + setp(buf, buf+sizeof(buf)); +} + +OFileStreambuf::~OFileStreambuf() +{ + sync(); + PHYSFS_close(file); +} + +int +OFileStreambuf::overflow(int c) +{ + char c2 = (char)c; + + if(pbase() == pptr()) + return 0; + + size_t size = pptr() - pbase(); + PHYSFS_sint64 res = PHYSFS_write(file, pbase(), 1, size); + if(res <= 0) + return traits_type::eof(); + + if(c != traits_type::eof()) { + PHYSFS_sint64 res = PHYSFS_write(file, &c2, 1, 1); + if(res <= 0) + return traits_type::eof(); + } + + setp(buf, buf + res); + return 0; +} + +int +OFileStreambuf::sync() +{ + return overflow(traits_type::eof()); +} + +//--------------------------------------------------------------------------- + +IFileStream::IFileStream(const std::string& filename) + : std::istream(new IFileStreambuf(filename)) +{ +} + +IFileStream::~IFileStream() +{ + delete rdbuf(); +} + +//--------------------------------------------------------------------------- + +OFileStream::OFileStream(const std::string& filename) + : std::ostream(new OFileStreambuf(filename)) +{ +} + +OFileStream::~OFileStream() +{ + delete rdbuf(); +} Added: smipl-devel/physfs_stream.hpp =================================================================== --- smipl-devel/physfs_stream.hpp (rev 0) +++ smipl-devel/physfs_stream.hpp 2009-08-01 10:42:16 UTC (rev 19) @@ -0,0 +1,75 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2006 Matthias Braun <ma...@br...> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +#ifndef __PHYSFSSTREAM_HPP__ +#define __PHYSFSSTREAM_HPP__ + +#include <stddef.h> +#include <streambuf> + +/** This class implements a C++ streambuf object for physfs files. + * So that you can use normal istream operations on them + */ +class IFileStreambuf : public std::streambuf +{ +public: + IFileStreambuf(const std::string& filename); + ~IFileStreambuf(); + +protected: + virtual int underflow(); + virtual pos_type seekoff(off_type pos, std::ios_base::seekdir, + std::ios_base::openmode); + virtual pos_type seekpos(pos_type pos, std::ios_base::openmode); + +private: + PHYSFS_file* file; + char buf[1024]; +}; + +class OFileStreambuf : public std::streambuf +{ +public: + OFileStreambuf(const std::string& filename); + ~OFileStreambuf(); + +protected: + virtual int overflow(int c); + virtual int sync(); + +private: + PHYSFS_file* file; + char buf[1024]; +}; + +class IFileStream : public std::istream +{ +public: + IFileStream(const std::string& filename); + ~IFileStream(); +}; + +class OFileStream : public std::ostream +{ +public: + OFileStream(const std::string& filename); + ~OFileStream(); +}; + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-28 20:26:05
|
Revision: 18 http://smipl.svn.sourceforge.net/smipl/?rev=18&view=rev Author: the_student Date: 2009-07-28 20:25:52 +0000 (Tue, 28 Jul 2009) Log Message: ----------- SMIPL3 Almost total rewrite Added PhysicsFS plus some code from the PhysicsFS project Added Paths: ----------- smipl-devel/Console.h smipl-devel/Error.h smipl-devel/FS.h smipl-devel/Init.h smipl-devel/MDS.h smipl-devel/PartList.lst smipl-devel/SMIPL-header.h smipl-devel/SMIPL.cpp smipl-devel/SVM.h smipl-devel/String.h Added: smipl-devel/Console.h =================================================================== --- smipl-devel/Console.h (rev 0) +++ smipl-devel/Console.h 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,91 @@ +bool Console(int argc, char** argv) { + char **rc, **i, *str; + bool EnterProgram=false; + SMIPL_String command; + value_t number=0; + if(PHYSFS_exists("/Console/Splash")){PrintFile("/Console/Splash");cin.get();} + for(;;) { + if(!EnterProgram) cout<<"? "; + else cout<<number<<" "; + cin.getline(command.str, 256); + if(!EnterProgram) cout<<endl; + command.Split(); + //cout<<"argc="<<command.argc<<": "; + //for(int a=1;a<=command.argc;a++) cout<<"\""<<command.argv[a-1]<<"\""<<endl; + if(EnterProgram) { + strcpy(Program[(int)number],command.str); + if(!stricmp(command.str,"PROGRAM END")) {EnterProgram=false;cout<<endl;} + number++; + if(number>100000) {EnterProgram=false;cout<<endl;} + continue; + } + else { + if(!stricmp(command.argv[0], "QUIT")) break; + if(!stricmp(command.argv[0], "EXIT")) break; + if(!stricmp(command.str, "PROGRAM START")) {EnterProgram=true;number=0;continue;} + + if(!stricmp(command.argv[0], "RUN")) { + VM0.Run(NULL); + continue; + } + if(!stricmp(command.argv[0], "BACKGROUND-RUN")) { + pthread_create(&VM0.ID,NULL,StartThread,&VM0); + continue; + } + if(!stricmp(command.argv[0], "LIST")) { + int a=0; + do{ + cout<<a<<":"<<Program[a]<<endl; + }while(stricmp(Program[a++],"PROGRAM END")); + cout<<endl; + continue; + } + + if(!stricmp(command.argv[0], "CATALOG")) { + if(command.argc==1) Catalog("/"); + else for(int a=1;a<command.argc;a++) {Catalog(command.argv[a]);cout<<endl<<endl;} + continue; + } + if(!stricmp(command.argv[0], "HELP")) { + if(command.argc==1){ + if(PHYSFS_exists("/Help/Help")) PrintFile("/Help/Help"); + else cout<<"Help not found!"<<endl; + } + else { + str=new char[strlen(command.argv[1])+strlen("/Help/")]; + if(PHYSFS_exists(str))PrintFile(str); + else cout<<"Help for "<<command.argv[1]<<" not found!"<<endl; + delete[]str; + } + continue; + } + if(!stricmp(command.argv[0], "ABOUT")) { + if(command.argc==1) { + if(PHYSFS_exists("/About/About"))PrintFile("/About/About"); + else cout<<"About not found!"<<endl; + } + else { + str=new char[strlen(command.argv[1])+strlen("/About/")]; + if(PHYSFS_exists(command.argv[1]))PrintFile(str); + else cout<<"About "<<command.argv[1]<<" not found!"<<endl; + delete[]str; + } + continue; + } + if(!stricmp(command.argv[0], "REINIT")) { + DeInit(); + Init(argc,argv); + continue; + } + if(!stricmp(command.argv[0], "DUMP")) { + DumpStack(); + DumpMDS(); + DumpSearchPath(); + DumpRoot(); + continue; + } + cout<<"Unknown command:\""<<command.argv[0]<<"\"!"<<endl; + } + } + return true; +} Added: smipl-devel/Error.h =================================================================== --- smipl-devel/Error.h (rev 0) +++ smipl-devel/Error.h 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,7 @@ +char* LastSysError; +char* GetLastSysError() { + return LastSysError; +} +void SetLastSysError(char* err) { + LastSysError=err; +} Added: smipl-devel/FS.h =================================================================== --- smipl-devel/FS.h (rev 0) +++ smipl-devel/FS.h 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,92 @@ +pthread_mutex_t FS=PTHREAD_MUTEX_INITIALIZER; + +void Catalog(char *Directory) { + pthread_mutex_lock(&FS); + char** rc; + rc = PHYSFS_enumerateFiles(Directory); + if (rc == NULL) + printf("Failure. reason: %s.\n", PHYSFS_getLastError()); + else + { + int file_count, folder_count; + char **i; + char* a=new char[255]; + char* b=new char[255]; + + strcpy(a,Directory); + if(a[strlen(a)-1]!='/') strcat(a,"/"); + i = rc; + file_count=folder_count=0; + while(*i != NULL){ + strcpy(b,a); + strcat(b,*i); + if(!PHYSFS_isDirectory(b)) {printf("F %s\n", b);file_count++;} + else {printf("D %s/\n",b);folder_count++;} + i++; + } + delete[]a; + delete[]b; + printf("\n"); + printf("TOTAL (%d) FILE(S).\n", file_count); + printf("TOTAL (%d) FOLDER(S).\n", folder_count); + PHYSFS_freeList(rc); + } /* else */ + pthread_mutex_unlock(&FS); +} + +void PrintFile(char *FileName) { + pthread_mutex_lock(&FS); + char* str; + if(PHYSFS_exists(FileName)) { + if(!PHYSFS_isDirectory(FileName)) { + PHYSFS_File *File=PHYSFS_openRead(FileName); + str=new char[PHYSFS_fileLength(File)]; + PHYSFS_read(File,str,sizeof(char),PHYSFS_fileLength(File)); + cout<<endl<<str<<endl<<endl; + delete[] str; + PHYSFS_close(File); + } + } + else cout<<"\""<<FileName<<"\": not found"<<endl; + pthread_mutex_unlock(&FS); +} + + +bool FS_init() { + char Name[255]; + fstream PartList("partlist.lst"); + if(PartList.is_open()) { + while(!PartList.eof()){ + PartList.getline(Name,255); + if(strlen(Name)==0) continue; + cout<<"Loading "<<Name<<" - "; + if(!PHYSFS_addToSearchPath(Name,0)) {SetLastSysError((char*)PHYSFS_getLastError());return false;} + else cout<<"OK"<<endl; + } + PartList.close(); + return true; + } + else {SetLastSysError("partlist not found");return false;} +} + +void DumpSearchPath() { + cout<<"DUMPING SEARCHPATH..."<<endl; + char **rc = PHYSFS_getSearchPath(); + + if (rc == NULL) + printf("Failure. reason: %s.\n", PHYSFS_getLastError()); + else + { + int dir_count; + char **i; + for (i = rc, dir_count = 0; *i != NULL; i++, dir_count++) + printf("%s\n", *i); + + printf("\nTOTAL (%d) FOLDER(S).\n", dir_count); + PHYSFS_freeList(rc); + } /* else */ +} +void DumpRoot() { + cout<<"DUMPING ROOT..."<<endl; + Catalog("/"); +} Added: smipl-devel/Init.h =================================================================== --- smipl-devel/Init.h (rev 0) +++ smipl-devel/Init.h 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,19 @@ +bool Init(int argc, char **argv) { + try{ + SetLastSysError(""); + strcpy(Program[0],"PROGRAM END"); + VM0.isVM0=true; + VM0.JailAddress=strdup("/VM0/"); + cout<<"Initializing PhysicsFS"<<endl; + if(!PHYSFS_init(argv[0])) {SetLastSysError((char*)PHYSFS_getLastError());return false;} + cout<<"Initializing FileSystem Structure"<<endl; + if(!FS_init())return false; + } + catch(...) {SetLastSysError("EXCEPTION");return false;} + + return true; +} +bool DeInit() { + if(!PHYSFS_deinit()){SetLastSysError((char*)PHYSFS_getLastError());return false;} + return true; +} Added: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h (rev 0) +++ smipl-devel/MDS.h 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,86 @@ +pthread_mutex_t MDS=PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t doSet=PTHREAD_MUTEX_INITIALIZER; +typedef double value_t; +struct MDS_Piece{ + char *Name; + value_t Value; + MDS_Piece *Next; + MDS_Piece() { + Name=strdup(""); + Value=0; + Next=NULL; + } + MDS_Piece(char *a, value_t b) { + Name=strdup(a); + Value=b; + Next=NULL; + } +}MDS_0; + +MDS_Piece* MDS_Last() { + MDS_Piece* Last=&MDS_0; + while(Last->Next!=NULL) Last=Last->Next; + return Last; +} +void MDS_Add(MDS_Piece* addthispiece) { + MDS_Last()->Next=addthispiece; +} +void MDS_Create(char *Name, value_t value) { + pthread_mutex_lock(&MDS); + MDS_Piece *created=new MDS_Piece(Name, value); + MDS_Add(created); + pthread_mutex_unlock(&MDS); +} + +void MDS_Get(char* Name, value_t* value) { + pthread_mutex_lock(&MDS); + *value=0; + MDS_Piece* Current=&MDS_0; + while(Current->Next!=NULL) {if(!strcmp(Current->Name,Name)) *value=Current->Value;Current=Current->Next;} + //if((isnan(*value))||(isinf(*value))) *value=0; + pthread_mutex_unlock(&MDS); +} +void MDS_Set(char* Name, value_t value) { + pthread_mutex_lock(&MDS); + pthread_mutex_lock(&doSet); + MDS_Piece* Current=&MDS_0; + bool isfound=false; + while(Current->Next!=NULL) {if(!strcmp(Current->Name,Name)) {Current->Value=value;isfound=true;}Current=Current->Next;} + pthread_mutex_unlock(&MDS); + if(!isfound) MDS_Create(Name, value); + pthread_mutex_unlock(&doSet); + +} + +void DumpMDS() { + pthread_mutex_lock(&MDS); + cout<<"DUMPING MDS..."<<endl; + MDS_Piece *current=MDS_0.Next; + while(current!=NULL) { + cout<<"\""<<current->Name<<"\":"<<current->Value<<endl; + current=current->Next; + } + pthread_mutex_unlock(&MDS); +} +void DumpStack() { + char* name=new char[255]; + value_t Level=0, MaxLevel=0, value=0; + cout<<"DUMPING STACK"; + MDS_Get("/VM0/Stack/P", &MaxLevel); + cout<<"..."<<endl; + pthread_mutex_lock(&MDS); + while(Level<MaxLevel) { + sprintf(name, "/VM0/Stack/%d",Level); + MDS_Get(name, &value); + cout<<"\""<<value<<"\""<<endl; + Level++; + } + pthread_mutex_unlock(&MDS); +} +pthread_mutex_t doatof=PTHREAD_MUTEX_INITIALIZER; +void Atof(char *a, value_t* b) { + pthread_mutex_lock(&doatof); + MDS_Get(a,b); + if(*b==0) *b=atof(a); + pthread_mutex_unlock(&doatof); +} Added: smipl-devel/PartList.lst =================================================================== --- smipl-devel/PartList.lst (rev 0) +++ smipl-devel/PartList.lst 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1 @@ +FS.zip \ No newline at end of file Added: smipl-devel/SMIPL-header.h =================================================================== --- smipl-devel/SMIPL-header.h (rev 0) +++ smipl-devel/SMIPL-header.h 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,24 @@ +//C libraries +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <cmath> +//IO streams +#include <iostream> +#include <fstream> +using namespace std; +//Div +#include <pthread.h> +#include <physfs.h> +//SMIPL Core systems +bool Init(int,char**); +bool DeInit(); +#include "String.h" +#include "Error.h" +#include "MDS.h" +#include "fs.h" +//SMIPL UI +#include "SVM.h" +#include "Console.h" +//SMIPL Init +#include "Init.h" Added: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp (rev 0) +++ smipl-devel/SMIPL.cpp 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,11 @@ +#include "SMIPL-header.h" +int main(int argc, char **argv) { + cout<<"Setting up version globals"<<endl; + MDS_Create("/Global/SMIPL/Version/Major",3); + MDS_Create("/Global/SMIPL/Version/Minor",0); + MDS_Create("/Global/SMIPL/Version/Patch",0); + cout<<"Running init"<<endl; + if(!Init(argc, argv)) {cerr<<"Init error:"<<GetLastSysError()<<endl;for(;;);} + else if(!Console(argc, argv)) {cerr<<"Console error"<<GetLastSysError()<<endl;for(;;);} + if(!DeInit()) {cerr<<"DeInit error:"<<GetLastSysError()<<endl;for(;;);} +} Added: smipl-devel/SVM.h =================================================================== --- smipl-devel/SVM.h (rev 0) +++ smipl-devel/SVM.h 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,87 @@ +char Program[100000][80]; +struct SVM_Thread{ + pthread_t ID; + bool AllowGetGlobal,isVM0; + char *JailAddress,*str1,*str2; + int StartAddress,Address; + pthread_mutex_t Admin; + SMIPL_String cmd; + value_t number,number2; + + void MDS_Get(char* Name, value_t* value) { + pthread_mutex_lock(&Admin); + if(JailAddress==NULL) {str1=new char[strlen(Name)+1];strcpy(str1,"/");} + else {str1=new char[strlen(Name)+strlen(JailAddress)];strcpy(str1,JailAddress);} + pthread_mutex_unlock(&Admin); + strcat(str1,Name); + ::MDS_Get(str1, value); + delete[]str1; + } + void MDS_Set(char* Name, value_t value) { + pthread_mutex_lock(&Admin); + if(JailAddress==NULL) {str1=new char[strlen(Name)+1];strcpy(str1,"/");} + else {str1=new char[strlen(Name)+strlen(JailAddress)];strcpy(str1,JailAddress);} + pthread_mutex_unlock(&Admin); + strcat(str1,Name); + ::MDS_Set(str1, value); + delete[]str1; + } + void Push(value_t data) { + value_t stack_p; + MDS_Get("Stack/P", &stack_p); + char* StackPName=new char[255]; + pthread_mutex_lock(&Admin); + sprintf(StackPName, "%sStack/%d",JailAddress,(int)stack_p); + MDS_Set(StackPName, data); + MDS_Set("Stack/P", stack_p+1); + pthread_mutex_unlock(&Admin); + delete[]StackPName; + } + void Atof(char *a, value_t* b) { + pthread_mutex_lock(&doatof); + MDS_Get(a,b); + if(*b==0) *b=atof(a); + pthread_mutex_unlock(&doatof); + } + + void*Run(void*); + SVM_Thread* Next; + SVM_Thread() { + Admin=PTHREAD_MUTEX_INITIALIZER; + AllowGetGlobal=isVM0=false; + JailAddress=NULL; + StartAddress=0; + Next=NULL; + } +}VM0; +pthread_mutex_t doStartThread=PTHREAD_MUTEX_INITIALIZER; +void *StartThread(void* thread) { + pthread_mutex_lock(&doStartThread); + if(thread!=NULL) {SVM_Thread *thread_a=(SVM_Thread*)thread;thread_a->Run(NULL);} + pthread_mutex_unlock(&doStartThread); +} +void* SVM_Thread::Run(void* StartAddress) { + pthread_mutex_lock(&Admin); + if(StartAddress!=NULL) this->StartAddress=(int)StartAddress; + Address=this->StartAddress; + ID=pthread_self(); + pthread_mutex_unlock(&Admin); + MDS_Set("Stack/P", -1); + while(1) { + strcpy(cmd.str,Program[Address]); + cmd.Split(); + if(!stricmp(cmd.argv[0],"STOP")) break; + if(!stricmp(cmd.str,"PROGRAM END")) break; + if(!stricmp(cmd.argv[0],"GOTO")) if(cmd.argc>=2) {Atof(cmd.argv[1],&number);Address=number-1;} + if(!stricmp(cmd.argv[0],"SET")) for(int a=1;a<cmd.argc;a+=2) {Atof(cmd.argv[a+1],&number);MDS_Set(cmd.argv[a], number);} + if(!stricmp(cmd.argv[0],"ADD")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number+=number2;}MDS_Set(cmd.argv[1], number);} + if(!stricmp(cmd.argv[0],"SUBRACT")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number-=number2;}MDS_Set(cmd.argv[1], number);} + if(!stricmp(cmd.argv[0],"MULTIPLY")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number*=number2;}MDS_Set(cmd.argv[1], number);} + if(!stricmp(cmd.argv[0],"DIVIDE")) {Atof(cmd.argv[1],&number);for(int a=2;a<cmd.argc;a++){Atof(cmd.argv[a], &number2);number/=number2;}MDS_Set(cmd.argv[1], number);} + + + Address++; + if(Address>100000) break; + if(Address<0) break; + } +} Added: smipl-devel/String.h =================================================================== --- smipl-devel/String.h (rev 0) +++ smipl-devel/String.h 2009-07-28 20:25:52 UTC (rev 18) @@ -0,0 +1,51 @@ +pthread_mutex_t do_split=PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t do_strdup=PTHREAD_MUTEX_INITIALIZER; +char *strdup(char *a, char* b) { + char* str=new char[strlen(a)+strlen(b)]; + strcpy(str,a); + strcat(str,a); + return str; +} +bool isDelim(char a, bool disallow_spaces=true, bool disallow_comparison=true) { + if(disallow_spaces)if(a==' ') return true; + if(a=='\n') return true; + if(a=='\0') return true; + + if(disallow_comparison) { + if(a=='<') return true; + if(a=='>') return true; + if(a=='=') return true; + } + return false; +} + +struct SMIPL_String{ + int c1,c2,argc; + char argv[10][80],str[80],Op; + void Split(bool force_disallow_spaces_in_names=false) { + pthread_mutex_lock(&do_split); + c1=0; + c2=0; + argc=0; + bool disallow_spaces_in_names=true; + NextArg: + while(str[c1]!='\0') { + c2=0; + while(!isgraph(str[c1])) {if(str[c1++]=='\0') break;} + while(!isDelim(str[c1],disallow_spaces_in_names)) { + if(argc!=0) argv[argc][c2]=str[c1]; + else argv[argc][c2]=toupper(str[c1]); + if((argv[argc][c2]=='"')&&(!force_disallow_spaces_in_names)) disallow_spaces_in_names=!disallow_spaces_in_names; + c1++; + c2++; + } + if(str[c1]=='<') {Op='<';} + if(str[c1]=='>') {Op='>';} + if(str[c1]=='=') {Op='=';} + argv[argc][c2]='\0'; + if(Op!=0) c1++; + if(strlen(argv[argc])>0) argc++; + } + end:pthread_mutex_unlock(&do_split); + } +}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-28 20:22:06
|
Revision: 17 http://smipl.svn.sourceforge.net/smipl/?rev=17&view=rev Author: the_student Date: 2009-07-28 20:21:55 +0000 (Tue, 28 Jul 2009) Log Message: ----------- Removed all files Removed Paths: ------------- smipl-devel/Error.h smipl-devel/Legacy/ smipl-devel/MDS.h smipl-devel/SIA.h smipl-devel/SIASOUND.h smipl-devel/SMIPL.cpp smipl-devel/SVM.h smipl-devel/TestSuite.h Deleted: smipl-devel/Error.h =================================================================== --- smipl-devel/Error.h 2009-07-24 11:32:53 UTC (rev 16) +++ smipl-devel/Error.h 2009-07-28 20:21:55 UTC (rev 17) @@ -1,2 +0,0 @@ -#define StackUnderflow 1 -#define StackOverflow 2 Deleted: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h 2009-07-24 11:32:53 UTC (rev 16) +++ smipl-devel/MDS.h 2009-07-28 20:21:55 UTC (rev 17) @@ -1,70 +0,0 @@ -#define MDS_NAME_LENGTH 25 - -#define MDS_READ 0x01 -#define MDS_WRITE 0x02 -#define MDS_DELETE 0x04 - -struct MDS_Piece{ - char *Name; - double Value; - char Attribute; - - MDS_Piece *Next; - MDS_Piece() { - Name=new char[MDS_NAME_LENGTH]; - strcpy(Name,""); - Value=0; - Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; - Next=NULL; - } - MDS_Piece(char *Name, double Value) { - this->Name=new char[MDS_NAME_LENGTH]; - this->Value=Value; - this->Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; - this->Next=NULL; - } - MDS_Piece(char *Name, double Value, char attribute) { - this->Name=new char[MDS_NAME_LENGTH]; - this->Value=Value; - this->Attribute=attribute; - this->Next=NULL; - } -}MDS_0; - -MDS_Piece *MDS_Read(char *Name, char *Password=NULL) { - MDS_Piece *DataPiece; - DataPiece=&MDS_0; - pthread_mutex_lock(&MDS); - while(1) { - if(!strcmp(DataPiece->Name,Name)) break; - if(DataPiece->Next==NULL) {pthread_mutex_unlock(&MDS);return NULL;} - DataPiece=DataPiece->Next; - } - pthread_mutex_unlock(&MDS); - return DataPiece; return DataPiece; - return NULL; -} -MDS_Piece *MDS_Last_Piece() { - MDS_Piece *DataPiece=&MDS_0; - pthread_mutex_lock(&MDS); - while(DataPiece->Next!=NULL) DataPiece=DataPiece->Next; - pthread_mutex_unlock(&MDS); - return DataPiece; -} -bool MDS_Create(MDS_Piece Data) { - pthread_mutex_lock(&MDS); - MDS_Piece *DataPiece=MDS_Last_Piece(); - DataPiece->Next=new MDS_Piece(Data); - pthread_mutex_unlock(&MDS); -} -bool MDS_Delete(MDS_Piece *Data){ - pthread_mutex_lock(&MDS); - MDS_Piece *PreviousD=&MDS_0, *NextD=Data->Next; - for(;PreviousD->Next!=Data;) {if(PreviousD->Next!=NULL)PreviousD=PreviousD->Next;else {pthread_mutex_unlock(&MDS);return false;}} - if(Data->Attribute&MDS_DELETE)delete Data; - PreviousD->Next=NextD; - pthread_mutex_unlock(&MDS); -} -MDS_Piece *MDS_First() { - return MDS_0.Next; -} Deleted: smipl-devel/SIA.h =================================================================== --- smipl-devel/SIA.h 2009-07-24 11:32:53 UTC (rev 16) +++ smipl-devel/SIA.h 2009-07-28 20:21:55 UTC (rev 17) @@ -1,9 +0,0 @@ -#ifdef __linux__ -#include <unistd.h> -#include <fcntl.h> -void sys_sleep(int time) {usleep(time);} -#endif -#ifdef WIN32 -#include <windows.h> -void sys_sleep(int time) {Sleep(time);} -#endif Deleted: smipl-devel/SIASOUND.h =================================================================== --- smipl-devel/SIASOUND.h 2009-07-24 11:32:53 UTC (rev 16) +++ smipl-devel/SIASOUND.h 2009-07-28 20:21:55 UTC (rev 17) @@ -1,34 +0,0 @@ -bool MIDI_OUT_INITED=false; -typedef union { unsigned long word; unsigned char data[4]; }MIDI_Message; -#ifdef __linux__ -#include <linux/soundcard.h> -int MIDI_Out; -void MIDI_Init() { - if(MIDI_Out=open("/dev/midi",O_WRONLY,0)<0) goto End; - - - MIDI_OUT_INITED=true; - End: - ; -} -void MIDI_Write(MIDI_Message Melding) { - if(MIDI_OUT_INITED) { - write(MIDI_Out, Melding.data, sizeof(Melding.data)); - } -} -#endif - -#ifdef WIN32 -HMIDIOUT MIDI_Out; -void MIDI_Init() { - if (midiOutOpen(&MIDI_Out, 0, 0, 0, CALLBACK_NULL) != MMSYSERR_NOERROR) { - printf("Error opening MIDI Output.\n"); - goto end; - } - MIDI_OUT_INITED=true; - end: - ; -} -void MIDI_Write(MIDI_Message Melding) { - if(MIDI_OUT_INITED) {if(midiOutShortMsg(MIDI_Out, Melding.word) != MMSYSERR_NOERROR) {throw "MIDI ERROR";}}} -#endif Deleted: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-07-24 11:32:53 UTC (rev 16) +++ smipl-devel/SMIPL.cpp 2009-07-28 20:21:55 UTC (rev 17) @@ -1,207 +0,0 @@ -/*This file is part of SMIPL. - - SMIPL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - SMIPL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with SMIPL. If not, see <http://www.gnu.org/licenses/>. -*/ -#include <pthread.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> -#include <physfs.h> - -#include <iostream> -#include <fstream> - -#include <string.h> - -using namespace std; - -pthread_mutex_t MDS=PTHREAD_MUTEX_INITIALIZER; -pthread_mutex_t SIA=PTHREAD_MUTEX_INITIALIZER; -pthread_mutex_t Level0=PTHREAD_MUTEX_INITIALIZER; -pthread_mutex_t SVM=PTHREAD_MUTEX_INITIALIZER; -pthread_t MainThread; - -#include "Error.h" -#include "MDS.h" -#include "SIA.h" -#include "SIASOUND.h" -#include "Legacy/Level0.h" -#define MAX_STEPS 100000 -int Steps; -char Data[10000][80],Cmd[80]; -#include "SVM.h" -#define CON 0 -#define SCR 1 - -#include "TestSuite.h" -int main() { - MainThread=pthread_self(); - fstream the_file; - char Licence[15][80]={ - "SMIPL is free software: you can redistribute it and/or modify", - "it under the terms of the GNU General Public License as published by", - "the Free Software Foundation, either version 3 of the License, or", - "(at your option) any later version.", - " ", - "SMIPL is distributed in the hope that it will be useful,", - "but WITHOUT ANY WARRANTY; without even the implied warranty of", - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the", - "GNU General Public License for more details.", - " ", - "You should have received a copy of the GNU General Public License", - "along with SMIPL. If not, see <http://www.gnu.org/licenses/>."}; - #ifdef MAX_VER - NewVar("SMIPL_VER",MAX_VER); - #endif - - - try{ - FillLine('_'); - PrintCentered("SMIPL"); - PrintCentered("for licence information, write GPL"); - FillLine('_'); - int Lin,Address; - bool EnterProg, List=false, LIB_MODE=false; - int Mode=CON; - char Name[255], LIB_START[10]; - fstream Script, Library; - top: - MDS_Piece DataPiece=MDS_0; - Lin=0; - List=false; - EnterProg=false; - cout<<endl<<"? "; - if(Mode==CON) cin.getline(Cmd, 80); - if(Mode==SCR) {Script.getline(Cmd, 80);cout<<Cmd<<endl;if(Script.eof()) {Script.close();Mode=CON;}} - - for(int c1=0;Cmd[c1]!=0;c1++) Cmd[c1]=toupper(Cmd[c1]); - - if(!strcmp(Cmd,"GPL")) {cout<<endl;for(int y=0;strcmp(Licence[y], ""); y++) cout<<Licence[y]<<endl;cout<<endl;} - - if(!strcmp(Cmd,"NEW")) { - pthread_mutex_lock(&MDS); - while(MDS_First()!=NULL) MDS_Delete(MDS_First()); - pthread_mutex_unlock(&MDS); - for(int a=0;a<=10000;a++)strcpy(Data[a],"PROGRAM END"); - VM0.StackP=-1; - } - - if(!strcmp(Cmd,"PROGRAM START")) { - EnterProg=true;Lin=0; - while(EnterProg) { - cout<<Lin<<" "; - if(Mode==CON) cin.getline(Data[Lin], 80); - if(Mode==SCR) {Script.getline(Data[Lin], 80);cout<<Data[Lin]<<endl;} - if(!strcasecmp(Data[Lin], "PROGRAM END")) {EnterProg=false;goto top;} - Lin++; - if(Lin>10000) {cout<<"PROGRAM TO COMPLEX, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} - } - } - if(!strcmp(Cmd,"LOAD")) { - cout<<"FILENAME: "; - cin.getline(Cmd,80); - the_file.open(Cmd,ios::in); - if(!the_file.is_open()) {cout<<"FILE NOT FOUND!"<<endl;goto top;} - the_file.getline(Cmd,80); - if(strcmp(Cmd,"SMIPL PROGRAM")) {cout<<"UNKNOWN FILE TYPE"<<endl;the_file.close();goto top;} - do{ - the_file.getline(Data[Lin++],80); - }while(!the_file.eof()); - the_file.close(); - goto top; - } - if(!strcmp(Cmd,"SAVE")) { - cout<<"FILENAME: "; - cin.getline(Cmd,80); - the_file.open(Cmd,ios::out); - the_file<<"SMIPL PROGRAM"<<endl; - Lin=0; - cout<<"SAVING..."; - do{ - the_file<<Data[Lin]<<endl; - }while(strcmp(Data[Lin++],"PROGRAM END")); - cout<<"OK"<<endl; - the_file.close(); - } - if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!stricmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} - if(!strcmp(Cmd,"RUN")) { - Steps=MAX_STEPS; - VM0.Run((void*)0); - } - if(!strcmp(Cmd,"BACKGROUND-RUN")) { - Steps=MAX_STEPS; - StartNewSVMThread(0); - } - if(!strcmp(Cmd,"DUMP")) { - cout<<endl<<"DUMPING MDS..."<<endl; - DataPiece=MDS_0; - pthread_mutex_lock(&MDS); - while(DataPiece.Next!=NULL){ - DataPiece=*DataPiece.Next; - cout<<"NAME:\""<<DataPiece.Name<<"\" VALUE:\""<<DataPiece.Value<<"\""<<endl; - } - pthread_mutex_unlock(&MDS); - pthread_mutex_lock(&Level0); - cout<<endl<<"DUMPING STACK..."<<endl; - for(int a=0;a<VM0.StackP;a++) cout<<"\""<<VM0.Stack[a]<<"\""<<endl; - pthread_mutex_unlock(&Level0); - } - if(!strcmp(Cmd,"QUIT")) goto End; - if(!strcmp(Cmd,"EXIT")) goto End; - if(!strcmp(Cmd,"LIBRARY")) { - do{ - cout<<"LIBRARY NAME? "; - cin.getline(Name, 255); - Library.open(Name); - cout<<"LIBRARY START? "; - cin.getline(LIB_START, 255); - }while(atoi(LIB_START)>10000); - Address=Find(Name); - if(!Address) NewVar(Name, LIB_START); - else Set(Name, LIB_START); - if(Library.is_open()) LIB_MODE=true; - else goto top; - Lin=atoi(LIB_START); - while(LIB_MODE) { - Library.getline(Data[atoi(LIB_START)+Lin], 80); - if(Library.eof()) {LIB_MODE=false;Library.close();goto top;} - Lin++; - if(Lin>10000) {cout<<"LIBRARY TO COMPLEX OR START ADDRESS TO HIGH, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} - } - VM0.Run((void*)atoi(LIB_START)); //Library auto-init - } - - if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} - - if(!strcmp(Cmd,"TEST-SMIPL")) {TestAll();cout<<endl;} - - if((Atoi(Cmd)!=0)||(isdigit(Cmd[0]))){ - EnterProg=true;Lin=Atoi(Cmd); - while(EnterProg) { - cout<<Lin<<" "; - if(Mode==CON) cin.getline(Data[Lin], 80); - if(Mode==SCR) {Script.getline(Data[Lin], 80);cout<<Data[Lin]<<endl;} - if(!strcasecmp(Data[Lin], "PROGRAM END")) {EnterProg=false;goto top;} - Lin++; - if(Lin>10000) {cout<<"PROGRAM TO COMPLEX, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} - } - } - goto top; - } - catch(char* err) {cout<<"ERROR: "<<err<<endl;} - catch(bad_alloc&) {cout<<"R/E: Allocation failure"<<endl;for(;;);} //Might not work, but then again it is better to have tried, and failed than never to have tried at all! - catch(...) {cout<<"R/E: GENERIC ERROR"<<endl;for(;;);} - End:; -} - Deleted: smipl-devel/SVM.h =================================================================== --- smipl-devel/SVM.h 2009-07-24 11:32:53 UTC (rev 16) +++ smipl-devel/SVM.h 2009-07-28 20:21:55 UTC (rev 17) @@ -1,296 +0,0 @@ -#define MAXSVMTHREADS 128 -pthread_mutex_t SVM_ThreadList=PTHREAD_MUTEX_INITIALIZER; -pthread_t SVMthread[MAXSVMTHREADS]; -int SVMThreadP=0; -pthread_t StartNewSVMThread(int Line=0); -struct SVM_Thread{ - double Stack[8000]; -int StackP; -double Pop() { - if(StackP<0) throw StackUnderflow; - pthread_mutex_lock(&Level0); - double Address=Stack[StackP]; - StackP--; - pthread_mutex_unlock(&Level0); - return Address; -} -void Push(double Data) { - if(StackP>80000) throw StackOverflow; - pthread_mutex_lock(&Level0); - StackP++; - Stack[StackP]=Data; - pthread_mutex_unlock(&Level0); -} - - int Line; - MIDI_Message MIDI_Melding; - char argv[10][80],str[80],Op; - int argc,c1, c2, Address; - MDS_Piece *DataPiece; - bool disallow_spaces_in_names, command_executed; - -void *Run(void *function_input_argument) { - #ifdef DEBUG - printf("[%d]: Run()\n",pthread_self()); - #endif - Line=0; - disallow_spaces_in_names=true; - if(function_input_argument!=NULL) Line=(int)function_input_argument; - try{ - disallow_spaces_in_names=true; - double A,B; - while((Steps--)>0) { - try{ - command_executed=false; - c1=0; - c2=0; - argc=0; - for(int a=0;a<=10;a++)argv[a][0]=0; - c1=0; - Op=0; - while(Data[Line][c1]!=0) { - c2=0; - while(!isDelim(Data[Line][c1],disallow_spaces_in_names)) { - if(argc!=0) argv[argc][c2]=Data[Line][c1]; - else argv[argc][c2]=toupper(Data[Line][c1]); - if(argv[argc][c2]=='"') disallow_spaces_in_names=!disallow_spaces_in_names; - c1++; - c2++; - } - if(Data[Line][c1]=='<') {Op='<';} - if(Data[Line][c1]=='>') {Op='>';} - if(Data[Line][c1]=='=') {Op='=';} - argv[argc][c2]='\0'; - if(Op!=0) c1++; - if(strlen(argv[argc])>0) argc++; - NextArg: - //cout<<"."; - if(Data[Line][c1]=='\0') goto Parse; - while(!isgraph(Data[Line][c1])) {if(Data[Line][c1++]=='\0') break;} - } - - Parse: - #ifdef DEBUG - cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; - cout<<"C1:"<<c1<<" C2:"<<c2<<endl; - #endif - if(strlen(argv[0])==0) break; - - if(!strcmp(argv[0],"CREATE-THREAD")) { - pthread_mutex_lock(&SVM); - if(argc==1)StartNewSVMThread(); - if(argc==2)StartNewSVMThread(Atoi(argv[1])); - //if(argc==3){sprintf(str,"%d",StartNewSVMThread(Atoi(argv[1])));Set(argv[2],str);} //Won't work with - pthread_mutex_unlock(&SVM); - command_executed=true; - } - - - if(!strcmp(argv[0],"NEW")) { - if(argc>=1) { - if(Find(argv[1])) MDS_Delete(MDS_Read(argv[1])); - NewVar(argv[1],argv[2]); - NewVar(argv[1],""); - } - command_executed=true; - } - if(!strcmp(argv[0],"DELETE")) { - for(int a=1;strlen(argv[a])>0;a++) if(Find(argv[a]))MDS_Delete(MDS_Read(argv[a])); - command_executed=true; - } - - if(!strcmp(argv[0], "SET")) { - if(!Find(argv[1])) NewVar(argv[1], argv[2]); - else Set(argv[1], argv[2]); - command_executed=true; - } - if(!strcmp(argv[0], "ADD")) {if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])+Atof(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "SUBTRACT")) {if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])-Atof(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "MULTIPLY")) {if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])*Atof(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "DIVIDE")) {if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])/Atof(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - - if(!strcmp(argv[0], "ROOT")) {if(Find(argv[1])) { - sprintf(str,"%f",sqrt(Atof(argv[argc-1]))); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "LOG")) {if(Find(argv[1])) { - sprintf(str,"%f",log(Atof(argv[argc-1]))); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "POWER")) {if((Find(argv[1]))&&(argc>=3)) { - sprintf(str,"%f",pow(Atof(argv[argc-2]), Atof(argv[argc-1]))); - Set(argv[1],str); - } - command_executed=true; - } - - if(!strcmp(argv[0],"NOT")) {if(Find(argv[1])) { - sprintf(str,"%f",!Atoi(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "OR")) {if(Find(argv[1])) { - sprintf(str,"%f",Atoi(argv[1])|Atoi(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0],"AND")) {if(Find(argv[1])) { - sprintf(str,"%f",Atoi(argv[1])&Atoi(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0],"XOR")) {if(Find(argv[1])) { - sprintf(str,"%f",Atoi(argv[1])^Atoi(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "PRINT")) { - for(int a=1;a<argc;a++) { - if(Find(argv[a])) cout<<argv[a]<<"="<<Atof(argv[a])<<" "; - else cout<<"\""<<argv[a]<<"\" not found"; - } - cout<<endl; - command_executed=true; - } - - if(!strcmp(argv[0], "GOTO")) { - Line=Atoi(argv[1])-1; - command_executed=true; - } - - if(!strcmp(argv[0], "GOSUB")) { - Push(Line); - Line=Atoi(argv[1])-1; - command_executed=true; - } - if(!strcmp(argv[0], "RETURN")) { - if(StackP<0) goto End; - Line=(int)Pop(); - command_executed=true; - } - if(!strcmp(argv[0], "IF")) { - A=Atof(argv[1]); - B=Atof(argv[2]); - if(Op=='=') if(A!=B) Line++; - if(Op=='<') if(A>=B) Line++; - if(Op=='>') if(A<=B) Line++; - command_executed=true; - } - if(!strcmp(argv[0], "IF!")){ - A=Atof(argv[1]); - B=Atof(argv[2]); - if(Op=='=') if(!(A!=B)) Line++; - if(Op=='<') if(!(A>=B)) Line++; - if(Op=='>') if(!(A<=B)) Line++; - command_executed=true; - } - if(!strcmp(argv[0], "NEWLINE")) { - cout<<endl; - command_executed=true; - } - if(!strcmp(argv[0], "STOP")) { - command_executed=true; - goto End; - } - if((!strcmp(argv[0], "PROGRAM"))&&(!strcmp(argv[1],"END"))) { - command_executed=true; - goto End; - } - if(!strcmp(argv[0], "PUSH")) { - Push(Atof(argv[1])); - command_executed=true; - } - if(!strcmp(argv[0], "POP")) { - if(Find(argv[1])) { - DataPiece=MDS_Read(argv[1]); - DataPiece->Value=Pop(); - } - command_executed=true; - } - if(!strcmp(argv[0], "MIDI")) { - if(!MIDI_OUT_INITED){ - MIDI_Init(); - if(!MIDI_OUT_INITED) goto End; - } - MIDI_Melding.data[0] = 0x90; // MIDI note-on message (requires to data bytes) - MIDI_Melding.data[1] = 60; // MIDI note-on message: Key number (60 = middle C) - MIDI_Melding.data[2] = 100; // MIDI note-on message: Key velocity (100 = loud) - MIDI_Melding.data[3] = 0; // Unused parameter - if(argc==2) MIDI_Melding.data[1]=Atoi(argv[1]); - if(argc==3) {MIDI_Melding.data[1]=Atoi(argv[1]);MIDI_Melding.data[2]=Atoi(argv[2]);} - if(argc>=4) {MIDI_Melding.data[0]=Atoi(argv[1]);MIDI_Melding.data[1]=Atoi(argv[2]);MIDI_Melding.data[3]=Atoi(argv[3]);} - MIDI_Write(MIDI_Melding); - - command_executed=true; - } - if(!strcmp(argv[0], "SLEEP")) {sys_sleep(Atoi(argv[1]));command_executed=true;} - - if(!command_executed) { - if(Find(argv[0])) { - Push(Line); - Line=Atoi(argv[0])-1; - for(int a=1;a<argc;a++) Push(Atof(argv[a])); - Push(argc-1); - command_executed=true; - } - } - if(!command_executed) {cout<<"UNKNOWN COMMAND:\""<<argv[0]<<"\""<<endl;} - Line++; - } - catch(int VE_Err) { - if(Find("ONWARNING_HANDLER")) {Push(--Line);Line=Atoi("ONWARNING_HANDLER");Push(VE_Err);Push(1);} - else throw VE_Err; - } - catch(...) {throw;} - } - if(Steps==0) cout<<"ERROR: VIRTUAL PROGRAM KILLED OFF, MORE THAN "<<MAX_STEPS<<" PROGRAM LINES EXECUTED"<<endl; - } - catch(int err) {cout<<"ERROR: "<<err<<endl;} - catch(...){throw;} - End: - pthread_mutex_lock(&SVM); - if(pthread_equal(pthread_self(),MainThread)) { - for(int a=0;a<SVMThreadP;a++) pthread_cancel(SVMthread[a]); - } - pthread_mutex_unlock(&SVM); -} -SVM_Thread() { - StackP=0; -} -}VM0; -void *RunNewSVMThread(void *Line) { - SVM_Thread newthread=*new SVM_Thread; - newthread.Run(Line); -} -pthread_t StartNewSVMThread(int Line) { - pthread_create(&SVMthread[SVMThreadP++],NULL,RunNewSVMThread,(void*)Line); - return SVMthread[SVMThreadP]; -} Deleted: smipl-devel/TestSuite.h =================================================================== --- smipl-devel/TestSuite.h 2009-07-24 11:32:53 UTC (rev 16) +++ smipl-devel/TestSuite.h 2009-07-28 20:21:55 UTC (rev 17) @@ -1,68 +0,0 @@ -void TestMDS() { - cout<<(char)9<<"READ: "; - MDS_Read(""); - cout<<"OK"<<endl; - cout<<(char)9<<"Last Piece: "; - MDS_Last_Piece(); - cout<<"OK"<<endl; - cout<<(char)9<<"First: "; - MDS_First(); - cout<<"OK"<<endl; -} -void TestSIA() { - cout<<(char)9<<"sleep: "; - sys_sleep(1); - cout<<"OK"<<endl;; -} -void TestSIASOUND() { - cout<<(char)9<<"Init: "; - MIDI_Init(); - if(MIDI_OUT_INITED)cout<<"OK"<<endl; - else cout<<"FAIL"<<endl; - MIDI_Message MIDIMSG; - MIDIMSG.word=0x903C6400; - cout<<(char)9<<"Write: "; - MIDI_Write(MIDIMSG); - cout<<"OK"<<endl; -} -void TestLevel0() { - cout<<(char)9<<"Find: "; - Find(""); - cout<<"OK"<<endl; - cout<<(char)9<<"NewVar: "; - NewVar("TEST","0"); - cout<<"OK"<<endl; - cout<<(char)9<<"Set: "; - Set("TEST","1"); - cout<<"OK"<<endl; -} -void TestSVM() { -} -void TestAll() { - try{ - cout<<"MDS"<<endl; - TestMDS(); - } - catch(...) {cout<<"Exception!"<<endl;} - try{ - cout<<"SIA"<<endl; - TestSIA(); - } - catch(...) {cout<<"Exception!"<<endl;} - try{ - cout<<"SIASOUND"<<endl; - TestSIASOUND(); - } - catch(...) {cout<<"Exception!"<<endl;} - try{ - cout<<"Level0"<<endl; - TestLevel0(); - } - catch(...) {cout<<"Exception!"<<endl;} - try{ - cout<<"SVM"<<endl; - TestSVM(); - } - catch(...) {cout<<"Exception!"<<endl;} - cout<<endl; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-24 11:33:00
|
Revision: 16 http://smipl.svn.sourceforge.net/smipl/?rev=16&view=rev Author: the_student Date: 2009-07-24 11:32:53 +0000 (Fri, 24 Jul 2009) Log Message: ----------- Added TestSuite Modified Paths: -------------- smipl-devel/Legacy/Level0.h smipl-devel/SMIPL.cpp Added Paths: ----------- smipl-devel/TestSuite.h Modified: smipl-devel/Legacy/Level0.h =================================================================== --- smipl-devel/Legacy/Level0.h 2009-07-21 20:17:13 UTC (rev 15) +++ smipl-devel/Legacy/Level0.h 2009-07-24 11:32:53 UTC (rev 16) @@ -22,6 +22,7 @@ } int Find (char *Arg1) { + cout<<"Find(\""<<Arg1<<"\");"<<endl; if(!strcmp(Arg1,"ANSI")) return true; if(!strcmp(Arg1,"?")) return true; if(MDS_Read(Arg1)!=NULL) return true; @@ -29,6 +30,7 @@ } double Atof(char *Arg1) { + cout<<"Ato*(\""<<Arg1<<"\");"<<endl; double r; if(!strcmp(Arg1,"")) return 0; if(!strcmp(Arg1,"ANSI")) return cin.get(); @@ -41,6 +43,9 @@ int Atoi(char *Arg1) {return(int)Atof(Arg1);} void Set(char *Arg1, char *Arg2) { + #ifdef DEBUG + cout<<"Set(\""<<Arg1<<"\",\""<<Arg2<<"\");"<<endl; + #endif if(Find(Arg1)) { MDS_Piece *DataPiece=MDS_Read(Arg1); double r=Atof(Arg2); @@ -64,13 +69,26 @@ } void NewVar(char *Arg1, char *Arg2) { + #ifdef DEBUG + cout<<"NewVar(\""<<Arg1<<"\",\""<<Arg2<<"\");"<<endl; + #endif + pthread_mutex_lock(&MDS); + cout<<"1"; MDS_Piece Data; + cout<<"2"; if(!strcmp(Arg1,"?")) goto end; + cout<<"3"; strcpy(Data.Name,Arg1); + cout<<"4"; Data.Value=Atof(Arg2); + cout<<"5"; Data.Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; + cout<<"6"; Data.Next=NULL; + cout<<"7"; MDS_Create(Data); + cout<<"8"; delete &Data; - end: ; + cout<<"9"; + end: pthread_mutex_unlock(&MDS); } Modified: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-07-21 20:17:13 UTC (rev 15) +++ smipl-devel/SMIPL.cpp 2009-07-24 11:32:53 UTC (rev 16) @@ -43,6 +43,8 @@ #include "SVM.h" #define CON 0 #define SCR 1 + +#include "TestSuite.h" int main() { MainThread=pthread_self(); fstream the_file; @@ -181,6 +183,9 @@ } if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} + + if(!strcmp(Cmd,"TEST-SMIPL")) {TestAll();cout<<endl;} + if((Atoi(Cmd)!=0)||(isdigit(Cmd[0]))){ EnterProg=true;Lin=Atoi(Cmd); while(EnterProg) { Added: smipl-devel/TestSuite.h =================================================================== --- smipl-devel/TestSuite.h (rev 0) +++ smipl-devel/TestSuite.h 2009-07-24 11:32:53 UTC (rev 16) @@ -0,0 +1,68 @@ +void TestMDS() { + cout<<(char)9<<"READ: "; + MDS_Read(""); + cout<<"OK"<<endl; + cout<<(char)9<<"Last Piece: "; + MDS_Last_Piece(); + cout<<"OK"<<endl; + cout<<(char)9<<"First: "; + MDS_First(); + cout<<"OK"<<endl; +} +void TestSIA() { + cout<<(char)9<<"sleep: "; + sys_sleep(1); + cout<<"OK"<<endl;; +} +void TestSIASOUND() { + cout<<(char)9<<"Init: "; + MIDI_Init(); + if(MIDI_OUT_INITED)cout<<"OK"<<endl; + else cout<<"FAIL"<<endl; + MIDI_Message MIDIMSG; + MIDIMSG.word=0x903C6400; + cout<<(char)9<<"Write: "; + MIDI_Write(MIDIMSG); + cout<<"OK"<<endl; +} +void TestLevel0() { + cout<<(char)9<<"Find: "; + Find(""); + cout<<"OK"<<endl; + cout<<(char)9<<"NewVar: "; + NewVar("TEST","0"); + cout<<"OK"<<endl; + cout<<(char)9<<"Set: "; + Set("TEST","1"); + cout<<"OK"<<endl; +} +void TestSVM() { +} +void TestAll() { + try{ + cout<<"MDS"<<endl; + TestMDS(); + } + catch(...) {cout<<"Exception!"<<endl;} + try{ + cout<<"SIA"<<endl; + TestSIA(); + } + catch(...) {cout<<"Exception!"<<endl;} + try{ + cout<<"SIASOUND"<<endl; + TestSIASOUND(); + } + catch(...) {cout<<"Exception!"<<endl;} + try{ + cout<<"Level0"<<endl; + TestLevel0(); + } + catch(...) {cout<<"Exception!"<<endl;} + try{ + cout<<"SVM"<<endl; + TestSVM(); + } + catch(...) {cout<<"Exception!"<<endl;} + cout<<endl; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-21 20:17:15
|
Revision: 15 http://smipl.svn.sourceforge.net/smipl/?rev=15&view=rev Author: the_student Date: 2009-07-21 20:17:13 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Daily closing Modified Paths: -------------- smipl-devel/SVM.h Modified: smipl-devel/SVM.h =================================================================== --- smipl-devel/SVM.h 2009-07-21 20:13:24 UTC (rev 14) +++ smipl-devel/SVM.h 2009-07-21 20:17:13 UTC (rev 15) @@ -84,9 +84,7 @@ pthread_mutex_unlock(&SVM); command_executed=true; } - if(!strcmp(argv[0],"LOCK")) { - - } + if(!strcmp(argv[0],"NEW")) { if(argc>=1) { @@ -214,7 +212,6 @@ if(Op=='>') if(!(A<=B)) Line++; command_executed=true; } - if(!strcmp(argv[0], "NEWLINE")) { cout<<endl; command_executed=true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-21 20:13:27
|
Revision: 14 http://smipl.svn.sourceforge.net/smipl/?rev=14&view=rev Author: the_student Date: 2009-07-21 20:13:24 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Added MultiThreading Modified Paths: -------------- smipl-devel/Legacy/Level0.h smipl-devel/SMIPL.cpp Added Paths: ----------- smipl-devel/SVM.h Modified: smipl-devel/Legacy/Level0.h =================================================================== --- smipl-devel/Legacy/Level0.h 2009-07-20 17:30:57 UTC (rev 13) +++ smipl-devel/Legacy/Level0.h 2009-07-21 20:13:24 UTC (rev 14) @@ -21,24 +21,6 @@ return false; } -double Stack[8000]; -int StackP; -double Pop() { - if(StackP<0) throw StackUnderflow; - pthread_mutex_lock(&Level0); - double Address=Stack[StackP]; - StackP--; - pthread_mutex_unlock(&Level0); - return Address; -} -void Push(double Data) { - if(StackP>80000) throw StackOverflow; - pthread_mutex_lock(&Level0); - StackP++; - Stack[StackP]=Data; - pthread_mutex_unlock(&Level0); -} - int Find (char *Arg1) { if(!strcmp(Arg1,"ANSI")) return true; if(!strcmp(Arg1,"?")) return true; Modified: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-07-20 17:30:57 UTC (rev 13) +++ smipl-devel/SMIPL.cpp 2009-07-21 20:13:24 UTC (rev 14) @@ -17,6 +17,7 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> +#include <physfs.h> #include <iostream> #include <fstream> @@ -28,260 +29,22 @@ pthread_mutex_t MDS=PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t SIA=PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t Level0=PTHREAD_MUTEX_INITIALIZER; -pthread_mutex_t VM_Exec_muted=PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t SVM=PTHREAD_MUTEX_INITIALIZER; +pthread_t MainThread; #include "Error.h" #include "MDS.h" #include "SIA.h" #include "SIASOUND.h" - #include "Legacy/Level0.h" #define MAX_STEPS 100000 int Steps; char Data[10000][80],Cmd[80]; -void *Run(void *function_input_argument) { - pthread_t anythread; - cout<<"Run()"<<endl; - int Line=0; - if(function_input_argument!=NULL) Line=(int)function_input_argument; - try{ - MIDI_Message MIDI_Melding; - char argv[10][80],str[80],Op; - bool disallow_spaces_in_names=true, command_executed; - MDS_Piece *DataPiece; - int argc,c1, c2, Address; - double A,B; - while((Steps--)>0) { - pthread_mutex_lock(&VM_Exec_muted); - try{ - command_executed=false; - c1=0; - c2=0; - argc=0; - for(int a=0;a<=10;a++)argv[a][0]=0; - c1=0; - Op=0; - while(Data[Line][c1]!=0) { - c2=0; - while(!isDelim(Data[Line][c1],disallow_spaces_in_names)) { - if(argc!=0) argv[argc][c2]=Data[Line][c1]; - else argv[argc][c2]=toupper(Data[Line][c1]); - if(argv[argc][c2]=='"') disallow_spaces_in_names=!disallow_spaces_in_names; - c1++; - c2++; - } - if(Data[Line][c1]=='<') {Op='<';} - if(Data[Line][c1]=='>') {Op='>';} - if(Data[Line][c1]=='=') {Op='=';} - argv[argc][c2]='\0'; - if(Op!=0) c1++; - if(strlen(argv[argc])>0) argc++; - NextArg: - //cout<<"."; - if(Data[Line][c1]=='\0') goto Parse; - while(!isgraph(Data[Line][c1])) {if(Data[Line][c1++]=='\0') break;} - } - - Parse: - #ifdef DEBUG - cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; - cout<<"C1:"<<c1<<" C2:"<<c2<<endl; - #endif - if(strlen(argv[0])==0) continue; - - if(!strcmp(argv[0],"NEW")) { - if(argc>=1) { - if(Find(argv[1])) MDS_Delete(MDS_Read(argv[1])); - NewVar(argv[1],argv[2]); - NewVar(argv[1],""); - } - command_executed=true; - } - if(!strcmp(argv[0],"DELETE")) { - for(int a=1;strlen(argv[a])>0;a++) if(Find(argv[a]))MDS_Delete(MDS_Read(argv[a])); - command_executed=true; - } - - if(!strcmp(argv[0], "SET")) { - if(!Find(argv[1])) NewVar(argv[1], argv[2]); - else Set(argv[1], argv[2]); - command_executed=true; - } - if(!strcmp(argv[0], "ADD")) {if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])+Atof(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "SUBTRACT")) {if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])-Atof(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "MULTIPLY")) {if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])*Atof(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "DIVIDE")) {if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])/Atof(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - - if(!strcmp(argv[0], "ROOT")) {if(Find(argv[1])) { - sprintf(str,"%f",sqrt(Atof(argv[argc-1]))); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "LOG")) {if(Find(argv[1])) { - sprintf(str,"%f",log(Atof(argv[argc-1]))); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "POWER")) {if((Find(argv[1]))&&(argc>=3)) { - sprintf(str,"%f",pow(Atof(argv[argc-2]), Atof(argv[argc-1]))); - Set(argv[1],str); - } - command_executed=true; - } - - if(!strcmp(argv[0],"NOT")) {if(Find(argv[1])) { - sprintf(str,"%f",!Atoi(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "OR")) {if(Find(argv[1])) { - sprintf(str,"%f",Atoi(argv[1])|Atoi(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0],"AND")) {if(Find(argv[1])) { - sprintf(str,"%f",Atoi(argv[1])&Atoi(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0],"XOR")) {if(Find(argv[1])) { - sprintf(str,"%f",Atoi(argv[1])^Atoi(argv[2])); - Set(argv[1],str); - } - command_executed=true; - } - if(!strcmp(argv[0], "PRINT")) { - for(int a=1;a<argc;a++) { - if(Find(argv[a])) cout<<argv[a]<<"="<<Atof(argv[a])<<" "; - else cout<<"\""<<argv[a]<<"\" not found"; - } - cout<<endl; - command_executed=true; - } - - if(!strcmp(argv[0], "GOTO")) { - Line=Atoi(argv[1])-1; - command_executed=true; - } - - if(!strcmp(argv[0], "GOSUB")) { - Push(Line); - Line=Atoi(argv[1])-1; - command_executed=true; - } - if(!strcmp(argv[0], "RETURN")) { - if(StackP<0) goto End; - Line=(int)Pop(); - command_executed=true; - } - if(!strcmp(argv[0], "IF")) { - A=Atof(argv[1]); - B=Atof(argv[2]); - if(Op=='=') if(A!=B) Line++; - if(Op=='<') if(A>=B) Line++; - if(Op=='>') if(A<=B) Line++; - command_executed=true; - } - if(!strcmp(argv[0], "IF!")){ - A=Atof(argv[1]); - B=Atof(argv[2]); - if(Op=='=') if(!(A!=B)) Line++; - if(Op=='<') if(!(A>=B)) Line++; - if(Op=='>') if(!(A<=B)) Line++; - command_executed=true; - } - - if(!strcmp(argv[0], "NEWLINE")) { - cout<<endl; - command_executed=true; - } - if(!strcmp(argv[0], "STOP")) { - command_executed=true; - goto End; - } - if(!strcmp(argv[0], "PUSH")) { - Push(Atof(argv[1])); - command_executed=true; - } - if(!strcmp(argv[0], "POP")) { - if(Find(argv[1])) { - DataPiece=MDS_Read(argv[1]); - DataPiece->Value=Pop(); - } - command_executed=true; - } - if(!strcmp(argv[0], "MIDI")) { - if(!MIDI_OUT_INITED){ - MIDI_Init(); - if(!MIDI_OUT_INITED) goto End; - } - MIDI_Melding.data[0] = 0x90; // MIDI note-on message (requires to data bytes) - MIDI_Melding.data[1] = 60; // MIDI note-on message: Key number (60 = middle C) - MIDI_Melding.data[2] = 100; // MIDI note-on message: Key velocity (100 = loud) - MIDI_Melding.data[3] = 0; // Unused parameter - if(argc==2) MIDI_Melding.data[1]=Atoi(argv[1]); - if(argc==3) {MIDI_Melding.data[1]=Atoi(argv[1]);MIDI_Melding.data[2]=Atoi(argv[2]);} - if(argc>=4) {MIDI_Melding.data[0]=Atoi(argv[1]);MIDI_Melding.data[1]=Atoi(argv[2]);MIDI_Melding.data[3]=Atoi(argv[3]);} - MIDI_Write(MIDI_Melding); - - command_executed=true; - } - if(!strcmp(argv[0], "SLEEP")) {sys_sleep(Atoi(argv[1]));command_executed=true;} - - if(!command_executed) { - if(Find(argv[0])) { - Push(Line); - Line=Atoi(argv[0])-1; - for(int a=1;a<argc;a++) Push(Atof(argv[a])); - Push(argc-1); - command_executed=true; - } - } - if(!command_executed) {cout<<"UNKNOWN COMMAND:\""<<argv[0]<<"\""<<endl;} - Line++; - pthread_mutex_unlock(&VM_Exec_muted); - } - catch(int VE_Err) { - if(Find("ONWARNING_HANDLER")) {Push(--Line);Line=Atoi("ONWARNING_HANDLER");Push(VE_Err);Push(1);} - else throw VE_Err; - } - catch(...) {throw;} - } - if(Steps==0) cout<<"ERROR: VIRTUAL PROGRAM KILLED OFF, MORE THAN "<<MAX_STEPS<<" PROGRAM LINES EXECUTED"<<endl; - } - catch(int err) {cout<<"ERROR: "<<err<<endl;} - catch(...){throw;} - End: - ; -} +#include "SVM.h" #define CON 0 #define SCR 1 int main() { + MainThread=pthread_self(); fstream the_file; char Licence[15][80]={ "SMIPL is free software: you can redistribute it and/or modify", @@ -329,7 +92,7 @@ while(MDS_First()!=NULL) MDS_Delete(MDS_First()); pthread_mutex_unlock(&MDS); for(int a=0;a<=10000;a++)strcpy(Data[a],"PROGRAM END"); - StackP=-1; + VM0.StackP=-1; } if(!strcmp(Cmd,"PROGRAM START")) { @@ -372,8 +135,12 @@ if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!stricmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} if(!strcmp(Cmd,"RUN")) { Steps=MAX_STEPS; - Run((void*)0); + VM0.Run((void*)0); } + if(!strcmp(Cmd,"BACKGROUND-RUN")) { + Steps=MAX_STEPS; + StartNewSVMThread(0); + } if(!strcmp(Cmd,"DUMP")) { cout<<endl<<"DUMPING MDS..."<<endl; DataPiece=MDS_0; @@ -385,7 +152,7 @@ pthread_mutex_unlock(&MDS); pthread_mutex_lock(&Level0); cout<<endl<<"DUMPING STACK..."<<endl; - for(int a=0;a<StackP;a++) cout<<"\""<<Stack[a]<<"\""<<endl; + for(int a=0;a<VM0.StackP;a++) cout<<"\""<<VM0.Stack[a]<<"\""<<endl; pthread_mutex_unlock(&Level0); } if(!strcmp(Cmd,"QUIT")) goto End; @@ -410,7 +177,7 @@ Lin++; if(Lin>10000) {cout<<"LIBRARY TO COMPLEX OR START ADDRESS TO HIGH, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} } - Run((void*)atoi(LIB_START)); //Library auto-init + VM0.Run((void*)atoi(LIB_START)); //Library auto-init } if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} @@ -430,7 +197,6 @@ catch(char* err) {cout<<"ERROR: "<<err<<endl;} catch(bad_alloc&) {cout<<"R/E: Allocation failure"<<endl;for(;;);} //Might not work, but then again it is better to have tried, and failed than never to have tried at all! catch(...) {cout<<"R/E: GENERIC ERROR"<<endl;for(;;);} - End: - ; + End:; } Added: smipl-devel/SVM.h =================================================================== --- smipl-devel/SVM.h (rev 0) +++ smipl-devel/SVM.h 2009-07-21 20:13:24 UTC (rev 14) @@ -0,0 +1,299 @@ +#define MAXSVMTHREADS 128 +pthread_mutex_t SVM_ThreadList=PTHREAD_MUTEX_INITIALIZER; +pthread_t SVMthread[MAXSVMTHREADS]; +int SVMThreadP=0; +pthread_t StartNewSVMThread(int Line=0); +struct SVM_Thread{ + double Stack[8000]; +int StackP; +double Pop() { + if(StackP<0) throw StackUnderflow; + pthread_mutex_lock(&Level0); + double Address=Stack[StackP]; + StackP--; + pthread_mutex_unlock(&Level0); + return Address; +} +void Push(double Data) { + if(StackP>80000) throw StackOverflow; + pthread_mutex_lock(&Level0); + StackP++; + Stack[StackP]=Data; + pthread_mutex_unlock(&Level0); +} + + int Line; + MIDI_Message MIDI_Melding; + char argv[10][80],str[80],Op; + int argc,c1, c2, Address; + MDS_Piece *DataPiece; + bool disallow_spaces_in_names, command_executed; + +void *Run(void *function_input_argument) { + #ifdef DEBUG + printf("[%d]: Run()\n",pthread_self()); + #endif + Line=0; + disallow_spaces_in_names=true; + if(function_input_argument!=NULL) Line=(int)function_input_argument; + try{ + disallow_spaces_in_names=true; + double A,B; + while((Steps--)>0) { + try{ + command_executed=false; + c1=0; + c2=0; + argc=0; + for(int a=0;a<=10;a++)argv[a][0]=0; + c1=0; + Op=0; + while(Data[Line][c1]!=0) { + c2=0; + while(!isDelim(Data[Line][c1],disallow_spaces_in_names)) { + if(argc!=0) argv[argc][c2]=Data[Line][c1]; + else argv[argc][c2]=toupper(Data[Line][c1]); + if(argv[argc][c2]=='"') disallow_spaces_in_names=!disallow_spaces_in_names; + c1++; + c2++; + } + if(Data[Line][c1]=='<') {Op='<';} + if(Data[Line][c1]=='>') {Op='>';} + if(Data[Line][c1]=='=') {Op='=';} + argv[argc][c2]='\0'; + if(Op!=0) c1++; + if(strlen(argv[argc])>0) argc++; + NextArg: + //cout<<"."; + if(Data[Line][c1]=='\0') goto Parse; + while(!isgraph(Data[Line][c1])) {if(Data[Line][c1++]=='\0') break;} + } + + Parse: + #ifdef DEBUG + cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; + cout<<"C1:"<<c1<<" C2:"<<c2<<endl; + #endif + if(strlen(argv[0])==0) break; + + if(!strcmp(argv[0],"CREATE-THREAD")) { + pthread_mutex_lock(&SVM); + if(argc==1)StartNewSVMThread(); + if(argc==2)StartNewSVMThread(Atoi(argv[1])); + //if(argc==3){sprintf(str,"%d",StartNewSVMThread(Atoi(argv[1])));Set(argv[2],str);} //Won't work with + pthread_mutex_unlock(&SVM); + command_executed=true; + } + if(!strcmp(argv[0],"LOCK")) { + + } + + if(!strcmp(argv[0],"NEW")) { + if(argc>=1) { + if(Find(argv[1])) MDS_Delete(MDS_Read(argv[1])); + NewVar(argv[1],argv[2]); + NewVar(argv[1],""); + } + command_executed=true; + } + if(!strcmp(argv[0],"DELETE")) { + for(int a=1;strlen(argv[a])>0;a++) if(Find(argv[a]))MDS_Delete(MDS_Read(argv[a])); + command_executed=true; + } + + if(!strcmp(argv[0], "SET")) { + if(!Find(argv[1])) NewVar(argv[1], argv[2]); + else Set(argv[1], argv[2]); + command_executed=true; + } + if(!strcmp(argv[0], "ADD")) {if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])+Atof(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "SUBTRACT")) {if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])-Atof(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "MULTIPLY")) {if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])*Atof(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "DIVIDE")) {if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])/Atof(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + + if(!strcmp(argv[0], "ROOT")) {if(Find(argv[1])) { + sprintf(str,"%f",sqrt(Atof(argv[argc-1]))); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "LOG")) {if(Find(argv[1])) { + sprintf(str,"%f",log(Atof(argv[argc-1]))); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "POWER")) {if((Find(argv[1]))&&(argc>=3)) { + sprintf(str,"%f",pow(Atof(argv[argc-2]), Atof(argv[argc-1]))); + Set(argv[1],str); + } + command_executed=true; + } + + if(!strcmp(argv[0],"NOT")) {if(Find(argv[1])) { + sprintf(str,"%f",!Atoi(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "OR")) {if(Find(argv[1])) { + sprintf(str,"%f",Atoi(argv[1])|Atoi(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0],"AND")) {if(Find(argv[1])) { + sprintf(str,"%f",Atoi(argv[1])&Atoi(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0],"XOR")) {if(Find(argv[1])) { + sprintf(str,"%f",Atoi(argv[1])^Atoi(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "PRINT")) { + for(int a=1;a<argc;a++) { + if(Find(argv[a])) cout<<argv[a]<<"="<<Atof(argv[a])<<" "; + else cout<<"\""<<argv[a]<<"\" not found"; + } + cout<<endl; + command_executed=true; + } + + if(!strcmp(argv[0], "GOTO")) { + Line=Atoi(argv[1])-1; + command_executed=true; + } + + if(!strcmp(argv[0], "GOSUB")) { + Push(Line); + Line=Atoi(argv[1])-1; + command_executed=true; + } + if(!strcmp(argv[0], "RETURN")) { + if(StackP<0) goto End; + Line=(int)Pop(); + command_executed=true; + } + if(!strcmp(argv[0], "IF")) { + A=Atof(argv[1]); + B=Atof(argv[2]); + if(Op=='=') if(A!=B) Line++; + if(Op=='<') if(A>=B) Line++; + if(Op=='>') if(A<=B) Line++; + command_executed=true; + } + if(!strcmp(argv[0], "IF!")){ + A=Atof(argv[1]); + B=Atof(argv[2]); + if(Op=='=') if(!(A!=B)) Line++; + if(Op=='<') if(!(A>=B)) Line++; + if(Op=='>') if(!(A<=B)) Line++; + command_executed=true; + } + + if(!strcmp(argv[0], "NEWLINE")) { + cout<<endl; + command_executed=true; + } + if(!strcmp(argv[0], "STOP")) { + command_executed=true; + goto End; + } + if((!strcmp(argv[0], "PROGRAM"))&&(!strcmp(argv[1],"END"))) { + command_executed=true; + goto End; + } + if(!strcmp(argv[0], "PUSH")) { + Push(Atof(argv[1])); + command_executed=true; + } + if(!strcmp(argv[0], "POP")) { + if(Find(argv[1])) { + DataPiece=MDS_Read(argv[1]); + DataPiece->Value=Pop(); + } + command_executed=true; + } + if(!strcmp(argv[0], "MIDI")) { + if(!MIDI_OUT_INITED){ + MIDI_Init(); + if(!MIDI_OUT_INITED) goto End; + } + MIDI_Melding.data[0] = 0x90; // MIDI note-on message (requires to data bytes) + MIDI_Melding.data[1] = 60; // MIDI note-on message: Key number (60 = middle C) + MIDI_Melding.data[2] = 100; // MIDI note-on message: Key velocity (100 = loud) + MIDI_Melding.data[3] = 0; // Unused parameter + if(argc==2) MIDI_Melding.data[1]=Atoi(argv[1]); + if(argc==3) {MIDI_Melding.data[1]=Atoi(argv[1]);MIDI_Melding.data[2]=Atoi(argv[2]);} + if(argc>=4) {MIDI_Melding.data[0]=Atoi(argv[1]);MIDI_Melding.data[1]=Atoi(argv[2]);MIDI_Melding.data[3]=Atoi(argv[3]);} + MIDI_Write(MIDI_Melding); + + command_executed=true; + } + if(!strcmp(argv[0], "SLEEP")) {sys_sleep(Atoi(argv[1]));command_executed=true;} + + if(!command_executed) { + if(Find(argv[0])) { + Push(Line); + Line=Atoi(argv[0])-1; + for(int a=1;a<argc;a++) Push(Atof(argv[a])); + Push(argc-1); + command_executed=true; + } + } + if(!command_executed) {cout<<"UNKNOWN COMMAND:\""<<argv[0]<<"\""<<endl;} + Line++; + } + catch(int VE_Err) { + if(Find("ONWARNING_HANDLER")) {Push(--Line);Line=Atoi("ONWARNING_HANDLER");Push(VE_Err);Push(1);} + else throw VE_Err; + } + catch(...) {throw;} + } + if(Steps==0) cout<<"ERROR: VIRTUAL PROGRAM KILLED OFF, MORE THAN "<<MAX_STEPS<<" PROGRAM LINES EXECUTED"<<endl; + } + catch(int err) {cout<<"ERROR: "<<err<<endl;} + catch(...){throw;} + End: + pthread_mutex_lock(&SVM); + if(pthread_equal(pthread_self(),MainThread)) { + for(int a=0;a<SVMThreadP;a++) pthread_cancel(SVMthread[a]); + } + pthread_mutex_unlock(&SVM); +} +SVM_Thread() { + StackP=0; +} +}VM0; +void *RunNewSVMThread(void *Line) { + SVM_Thread newthread=*new SVM_Thread; + newthread.Run(Line); +} +pthread_t StartNewSVMThread(int Line) { + pthread_create(&SVMthread[SVMThreadP++],NULL,RunNewSVMThread,(void*)Line); + return SVMthread[SVMThreadP]; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-20 17:31:01
|
Revision: 13 http://smipl.svn.sourceforge.net/smipl/?rev=13&view=rev Author: the_student Date: 2009-07-20 17:30:57 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Added mutexes, and thus the possibility of multithreading Modified Paths: -------------- smipl-devel/Legacy/Level0.h smipl-devel/MDS.h smipl-devel/SMIPL.cpp Modified: smipl-devel/Legacy/Level0.h =================================================================== --- smipl-devel/Legacy/Level0.h 2009-07-19 15:25:51 UTC (rev 12) +++ smipl-devel/Legacy/Level0.h 2009-07-20 17:30:57 UTC (rev 13) @@ -25,14 +25,18 @@ int StackP; double Pop() { if(StackP<0) throw StackUnderflow; + pthread_mutex_lock(&Level0); double Address=Stack[StackP]; StackP--; + pthread_mutex_unlock(&Level0); return Address; } void Push(double Data) { if(StackP>80000) throw StackOverflow; + pthread_mutex_lock(&Level0); StackP++; Stack[StackP]=Data; + pthread_mutex_unlock(&Level0); } int Find (char *Arg1) { @@ -58,6 +62,7 @@ if(Find(Arg1)) { MDS_Piece *DataPiece=MDS_Read(Arg1); double r=Atof(Arg2); + pthread_mutex_lock(&MDS); if(!Find(Arg1)) {cout<<"\""<<Arg1<<"\" not found"<<endl;goto End;} if(!strcmp(Arg1,"?")) goto End; if(!strcmp(Arg1,"ANSI")){ @@ -73,7 +78,7 @@ #endif } End: - ; + pthread_mutex_unlock(&MDS); } void NewVar(char *Arg1, char *Arg2) { Modified: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h 2009-07-19 15:25:51 UTC (rev 12) +++ smipl-devel/MDS.h 2009-07-20 17:30:57 UTC (rev 13) @@ -34,28 +34,36 @@ MDS_Piece *MDS_Read(char *Name, char *Password=NULL) { MDS_Piece *DataPiece; DataPiece=&MDS_0; + pthread_mutex_lock(&MDS); while(1) { if(!strcmp(DataPiece->Name,Name)) break; - if(DataPiece->Next==NULL) return NULL; + if(DataPiece->Next==NULL) {pthread_mutex_unlock(&MDS);return NULL;} DataPiece=DataPiece->Next; } - if((DataPiece->Attribute)) return DataPiece; + pthread_mutex_unlock(&MDS); + return DataPiece; return DataPiece; return NULL; } MDS_Piece *MDS_Last_Piece() { MDS_Piece *DataPiece=&MDS_0; + pthread_mutex_lock(&MDS); while(DataPiece->Next!=NULL) DataPiece=DataPiece->Next; + pthread_mutex_unlock(&MDS); return DataPiece; } bool MDS_Create(MDS_Piece Data) { + pthread_mutex_lock(&MDS); MDS_Piece *DataPiece=MDS_Last_Piece(); DataPiece->Next=new MDS_Piece(Data); + pthread_mutex_unlock(&MDS); } bool MDS_Delete(MDS_Piece *Data){ + pthread_mutex_lock(&MDS); MDS_Piece *PreviousD=&MDS_0, *NextD=Data->Next; - for(;PreviousD->Next!=Data;) {if(PreviousD->Next!=NULL)PreviousD=PreviousD->Next;else return false;} + for(;PreviousD->Next!=Data;) {if(PreviousD->Next!=NULL)PreviousD=PreviousD->Next;else {pthread_mutex_unlock(&MDS);return false;}} if(Data->Attribute&MDS_DELETE)delete Data; PreviousD->Next=NextD; + pthread_mutex_unlock(&MDS); } MDS_Piece *MDS_First() { return MDS_0.Next; Modified: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-07-19 15:25:51 UTC (rev 12) +++ smipl-devel/SMIPL.cpp 2009-07-20 17:30:57 UTC (rev 13) @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with SMIPL. If not, see <http://www.gnu.org/licenses/>. */ - +#include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <math.h> @@ -25,6 +25,11 @@ using namespace std; +pthread_mutex_t MDS=PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t SIA=PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t Level0=PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t VM_Exec_muted=PTHREAD_MUTEX_INITIALIZER; + #include "Error.h" #include "MDS.h" #include "SIA.h" @@ -34,8 +39,11 @@ #define MAX_STEPS 100000 int Steps; char Data[10000][80],Cmd[80]; -struct VirtualThread{ -void Run(int Line=0) { +void *Run(void *function_input_argument) { + pthread_t anythread; + cout<<"Run()"<<endl; + int Line=0; + if(function_input_argument!=NULL) Line=(int)function_input_argument; try{ MIDI_Message MIDI_Melding; char argv[10][80],str[80],Op; @@ -44,6 +52,7 @@ int argc,c1, c2, Address; double A,B; while((Steps--)>0) { + pthread_mutex_lock(&VM_Exec_muted); try{ command_executed=false; c1=0; @@ -255,6 +264,7 @@ } if(!command_executed) {cout<<"UNKNOWN COMMAND:\""<<argv[0]<<"\""<<endl;} Line++; + pthread_mutex_unlock(&VM_Exec_muted); } catch(int VE_Err) { if(Find("ONWARNING_HANDLER")) {Push(--Line);Line=Atoi("ONWARNING_HANDLER");Push(VE_Err);Push(1);} @@ -268,8 +278,7 @@ catch(...){throw;} End: ; -}; -}; +} #define CON 0 #define SCR 1 int main() { @@ -291,7 +300,6 @@ NewVar("SMIPL_VER",MAX_VER); #endif - VirtualThread CurrentSmiplThread; try{ FillLine('_'); @@ -317,7 +325,9 @@ if(!strcmp(Cmd,"GPL")) {cout<<endl;for(int y=0;strcmp(Licence[y], ""); y++) cout<<Licence[y]<<endl;cout<<endl;} if(!strcmp(Cmd,"NEW")) { + pthread_mutex_lock(&MDS); while(MDS_First()!=NULL) MDS_Delete(MDS_First()); + pthread_mutex_unlock(&MDS); for(int a=0;a<=10000;a++)strcpy(Data[a],"PROGRAM END"); StackP=-1; } @@ -362,17 +372,21 @@ if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!stricmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} if(!strcmp(Cmd,"RUN")) { Steps=MAX_STEPS; - CurrentSmiplThread.Run(); + Run((void*)0); } if(!strcmp(Cmd,"DUMP")) { - cout<<endl<<"DUMPING MBS..."<<endl; + cout<<endl<<"DUMPING MDS..."<<endl; DataPiece=MDS_0; + pthread_mutex_lock(&MDS); while(DataPiece.Next!=NULL){ DataPiece=*DataPiece.Next; cout<<"NAME:\""<<DataPiece.Name<<"\" VALUE:\""<<DataPiece.Value<<"\""<<endl; - } + } + pthread_mutex_unlock(&MDS); + pthread_mutex_lock(&Level0); cout<<endl<<"DUMPING STACK..."<<endl; - for(int a=0;a<=StackP;a++) cout<<"\""<<Stack[a]<<"\""<<endl; + for(int a=0;a<StackP;a++) cout<<"\""<<Stack[a]<<"\""<<endl; + pthread_mutex_unlock(&Level0); } if(!strcmp(Cmd,"QUIT")) goto End; if(!strcmp(Cmd,"EXIT")) goto End; @@ -396,7 +410,7 @@ Lin++; if(Lin>10000) {cout<<"LIBRARY TO COMPLEX OR START ADDRESS TO HIGH, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} } - CurrentSmiplThread.Run(atoi(LIB_START)); //Library auto-init + Run((void*)atoi(LIB_START)); //Library auto-init } if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-19 15:25:52
|
Revision: 12 http://smipl.svn.sourceforge.net/smipl/?rev=12&view=rev Author: the_student Date: 2009-07-19 15:25:51 +0000 (Sun, 19 Jul 2009) Log Message: ----------- SMIPL-42cc Added Paths: ----------- smipl-42cc-stable/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-19 15:23:39
|
Revision: 11 http://smipl.svn.sourceforge.net/smipl/?rev=11&view=rev Author: the_student Date: 2009-07-19 15:23:32 +0000 (Sun, 19 Jul 2009) Log Message: ----------- Modified Paths: -------------- smipl-devel/SMIPL.cpp Modified: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-07-13 20:58:42 UTC (rev 10) +++ smipl-devel/SMIPL.cpp 2009-07-19 15:23:32 UTC (rev 11) @@ -359,7 +359,7 @@ cout<<"OK"<<endl; the_file.close(); } - if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!strcmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} + if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!stricmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} if(!strcmp(Cmd,"RUN")) { Steps=MAX_STEPS; CurrentSmiplThread.Run(); @@ -400,7 +400,6 @@ } if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} - if(!strcmp(Cmd,"EDIT")) {cout<<"LINE> ";cin.getline(Cmd,80); if((Atoi(Cmd)!=0)||(isdigit(Cmd[0]))){ EnterProg=true;Lin=Atoi(Cmd); while(EnterProg) { @@ -412,7 +411,6 @@ if(Lin>10000) {cout<<"PROGRAM TO COMPLEX, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} } } - } goto top; } catch(char* err) {cout<<"ERROR: "<<err<<endl;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 20:58:46
|
Revision: 10 http://smipl.svn.sourceforge.net/smipl/?rev=10&view=rev Author: the_student Date: 2009-07-13 20:58:42 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Fixed MIDI, fixed Level0.h. Modified Paths: -------------- smipl-devel/Legacy/Level0.h smipl-devel/SIASOUND.h Modified: smipl-devel/Legacy/Level0.h =================================================================== --- smipl-devel/Legacy/Level0.h 2009-07-13 20:07:47 UTC (rev 9) +++ smipl-devel/Legacy/Level0.h 2009-07-13 20:58:42 UTC (rev 10) @@ -36,10 +36,9 @@ } int Find (char *Arg1) { - cout<<"Searching"<<endl; if(!strcmp(Arg1,"ANSI")) return true; if(!strcmp(Arg1,"?")) return true; - if(MDS_Read(Arg1)!=NULL)if(MDS_Read(Arg1)->Attribute!=0) return true; + if(MDS_Read(Arg1)!=NULL) return true; else return false; } @@ -50,23 +49,11 @@ if(!strcmp(Arg1,"?")) {cout<<">";cin>>r;return r;} if(!Find(Arg1)) return atof(Arg1); MDS_Piece *DataPiece=MDS_Read(Arg1); - if(DataPiece==NULL) cout<<"Find returned true, but Arg1 was a unknown"<<endl; if(DataPiece->Attribute&MDS_READ)return DataPiece->Value; else return 0; } int Atoi(char *Arg1) {return(int)Atof(Arg1);} -void NewVar(char *Arg1, char *Arg2) { - MDS_Piece Data; - if(!strcmp(Arg1,"?")) goto end; - strcpy(Data.Name,Arg1); - Data.Value=Atof(Arg2); - Data.Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; - Data.Next=NULL; - MDS_Create(Data); - delete &Data; - end: ; -} void Set(char *Arg1, char *Arg2) { if(Find(Arg1)) { MDS_Piece *DataPiece=MDS_Read(Arg1); @@ -88,7 +75,6 @@ End: ; } -<<<<<<< .mine void NewVar(char *Arg1, char *Arg2) { MDS_Piece Data; @@ -101,5 +87,3 @@ delete &Data; end: ; } -======= ->>>>>>> .r6 Modified: smipl-devel/SIASOUND.h =================================================================== --- smipl-devel/SIASOUND.h 2009-07-13 20:07:47 UTC (rev 9) +++ smipl-devel/SIASOUND.h 2009-07-13 20:58:42 UTC (rev 10) @@ -13,7 +13,7 @@ } void MIDI_Write(MIDI_Message Melding) { if(MIDI_OUT_INITED) { - write(MIDI_Out, Melding.data, sizeof(Melding)); + write(MIDI_Out, Melding.data, sizeof(Melding.data)); } } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 20:07:49
|
Revision: 9 http://smipl.svn.sourceforge.net/smipl/?rev=9&view=rev Author: the_student Date: 2009-07-13 20:07:47 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Added Paths: ----------- smipl-demos/gosub-return.program.smipl smipl-demos/set-arithmetics-if-goto-print.program.smipl Added: smipl-demos/gosub-return.program.smipl =================================================================== --- smipl-demos/gosub-return.program.smipl (rev 0) +++ smipl-demos/gosub-return.program.smipl 2009-07-13 20:07:47 UTC (rev 9) @@ -0,0 +1,7 @@ +SET A 1 +PRINT A +GOSUB 5 +PRINT A +STOP +SET A 4 +RETURN \ No newline at end of file Added: smipl-demos/set-arithmetics-if-goto-print.program.smipl =================================================================== --- smipl-demos/set-arithmetics-if-goto-print.program.smipl (rev 0) +++ smipl-demos/set-arithmetics-if-goto-print.program.smipl 2009-07-13 20:07:47 UTC (rev 9) @@ -0,0 +1,12 @@ +SET A=2 +SET X=0 +SET B=2 +SET C=A +MULTIPLY C X +ADD C B +IF C=10 +GOTO 10 +ADD X 1 +GOTO 3 +PRINT X +STOP \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 19:55:12
|
Revision: 8 http://smipl.svn.sourceforge.net/smipl/?rev=8&view=rev Author: the_student Date: 2009-07-13 19:55:09 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Modified Paths: -------------- smipl-devel/SMIPL.cpp Modified: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-07-13 19:54:25 UTC (rev 7) +++ smipl-devel/SMIPL.cpp 2009-07-13 19:55:09 UTC (rev 8) @@ -75,8 +75,8 @@ Parse: #ifdef DEBUG - //cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; - //cout<<"C1:"<<c1<<" C2:"<<c2<<endl; + cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; + cout<<"C1:"<<c1<<" C2:"<<c2<<endl; #endif if(strlen(argv[0])==0) continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 19:54:26
|
Revision: 7 http://smipl.svn.sourceforge.net/smipl/?rev=7&view=rev Author: the_student Date: 2009-07-13 19:54:25 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Fixed Stack error Modified Paths: -------------- smipl-devel/Legacy/Level0.h Modified: smipl-devel/Legacy/Level0.h =================================================================== --- smipl-devel/Legacy/Level0.h 2009-07-13 15:25:16 UTC (rev 6) +++ smipl-devel/Legacy/Level0.h 2009-07-13 19:54:25 UTC (rev 7) @@ -25,12 +25,13 @@ int StackP; double Pop() { if(StackP<0) throw StackUnderflow; - double Address=Stack[StackP--]; + double Address=Stack[StackP]; + StackP--; return Address; } void Push(double Data) { + if(StackP>80000) throw StackOverflow; StackP++; - if(StackP>80000) throw StackOverflow; Stack[StackP]=Data; } @@ -87,3 +88,18 @@ End: ; } +<<<<<<< .mine + +void NewVar(char *Arg1, char *Arg2) { + MDS_Piece Data; + if(!strcmp(Arg1,"?")) goto end; + strcpy(Data.Name,Arg1); + Data.Value=Atof(Arg2); + Data.Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; + Data.Next=NULL; + MDS_Create(Data); + delete &Data; + end: ; +} +======= +>>>>>>> .r6 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 15:25:24
|
Revision: 6 http://smipl.svn.sourceforge.net/smipl/?rev=6&view=rev Author: the_student Date: 2009-07-13 15:25:16 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Added Paths: ----------- smipl-demos/version testing.program.smipl Removed Paths: ------------- smipl-demos/version testing.smipl.program Copied: smipl-demos/version testing.program.smipl (from rev 5, smipl-demos/version testing.smipl.program) =================================================================== --- smipl-demos/version testing.program.smipl (rev 0) +++ smipl-demos/version testing.program.smipl 2009-07-13 15:25:16 UTC (rev 6) @@ -0,0 +1,16 @@ +set min_ver=1 +set ver=smipl_ver +if ver<min_ver +goto 8 +set err=0 +print err +stop +set smipl_ver=min_ver +if smipl_ver=min_ver +goto 14 +set err=2 +print err +stop +set err=1 +print err +stop \ No newline at end of file Deleted: smipl-demos/version testing.smipl.program =================================================================== --- smipl-demos/version testing.smipl.program 2009-07-13 15:23:23 UTC (rev 5) +++ smipl-demos/version testing.smipl.program 2009-07-13 15:25:16 UTC (rev 6) @@ -1,16 +0,0 @@ -set min_ver=1 -set ver=smipl_ver -if ver<min_ver -goto 8 -set err=0 -print err -stop -set smipl_ver=min_ver -if smipl_ver=min_ver -goto 14 -set err=2 -print err -stop -set err=1 -print err -stop \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 15:23:24
|
Revision: 5 http://smipl.svn.sourceforge.net/smipl/?rev=5&view=rev Author: the_student Date: 2009-07-13 15:23:23 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Added Paths: ----------- smipl-demos/ smipl-demos/function test.program.smipl smipl-demos/version testing.smipl.program Added: smipl-demos/function test.program.smipl =================================================================== --- smipl-demos/function test.program.smipl (rev 0) +++ smipl-demos/function test.program.smipl 2009-07-13 15:23:23 UTC (rev 5) @@ -0,0 +1,16 @@ +set a=1 +set b=2 +set c=3 +set cmd=6 +cmd a b c +stop +set args=0 +pop args +print args +set arg=0 +if args=0 +return +pop arg +print arg +subtract args 1 +goto 10 \ No newline at end of file Added: smipl-demos/version testing.smipl.program =================================================================== --- smipl-demos/version testing.smipl.program (rev 0) +++ smipl-demos/version testing.smipl.program 2009-07-13 15:23:23 UTC (rev 5) @@ -0,0 +1,16 @@ +set min_ver=1 +set ver=smipl_ver +if ver<min_ver +goto 8 +set err=0 +print err +stop +set smipl_ver=min_ver +if smipl_ver=min_ver +goto 14 +set err=2 +print err +stop +set err=1 +print err +stop \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 13:53:14
|
Revision: 4 http://smipl.svn.sourceforge.net/smipl/?rev=4&view=rev Author: the_student Date: 2009-07-13 13:53:11 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Removed Paths: ------------- smipl-devel/Makefile Deleted: smipl-devel/Makefile =================================================================== --- smipl-devel/Makefile 2009-07-13 12:44:25 UTC (rev 3) +++ smipl-devel/Makefile 2009-07-13 13:53:11 UTC (rev 4) @@ -1,5 +0,0 @@ -all: - g++ SMIPL.cpp -clean: - rm -f gmon.out - rm -f a.out \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 12:44:30
|
Revision: 3 http://smipl.svn.sourceforge.net/smipl/?rev=3&view=rev Author: the_student Date: 2009-07-13 12:44:25 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Attempt to fix gosub bug Modified Paths: -------------- smipl-devel/Legacy/Level0.h smipl-devel/MDS.h smipl-devel/SMIPL.cpp Added Paths: ----------- smipl-devel/Makefile Modified: smipl-devel/Legacy/Level0.h =================================================================== --- smipl-devel/Legacy/Level0.h 2009-07-13 12:42:43 UTC (rev 2) +++ smipl-devel/Legacy/Level0.h 2009-07-13 12:44:25 UTC (rev 3) @@ -22,29 +22,23 @@ } double Stack[8000]; -int StackP=-1; +int StackP; double Pop() { - double Address=Stack[StackP]; - StackP--; - if(StackP<0) throw StackOverflow; + if(StackP<0) throw StackUnderflow; + double Address=Stack[StackP--]; return Address; } void Push(double Data) { StackP++; + if(StackP>80000) throw StackOverflow; Stack[StackP]=Data; - if(StackP>80000) throw StackUnderflow; } -int Find (char *Pref,char *Arg1) { - if(!strcmp(Arg1,"ANSI")) return true; - if(!strcmp(Arg1,"?")) return true; - if(MDS_Read(Pref,Arg1)!=NULL) return true; - else return false; -} int Find (char *Arg1) { + cout<<"Searching"<<endl; if(!strcmp(Arg1,"ANSI")) return true; if(!strcmp(Arg1,"?")) return true; - if(MDS_Read(Arg1)!=NULL) return true; + if(MDS_Read(Arg1)!=NULL)if(MDS_Read(Arg1)->Attribute!=0) return true; else return false; } @@ -55,7 +49,9 @@ if(!strcmp(Arg1,"?")) {cout<<">";cin>>r;return r;} if(!Find(Arg1)) return atof(Arg1); MDS_Piece *DataPiece=MDS_Read(Arg1); - return DataPiece->Value; + if(DataPiece==NULL) cout<<"Find returned true, but Arg1 was a unknown"<<endl; + if(DataPiece->Attribute&MDS_READ)return DataPiece->Value; + else return 0; } int Atoi(char *Arg1) {return(int)Atof(Arg1);} @@ -65,13 +61,12 @@ strcpy(Data.Name,Arg1); Data.Value=Atof(Arg2); Data.Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; - Data.READ_PW=Data.WRITE_PW=Data.DELETE_PW; Data.Next=NULL; MDS_Create(Data); delete &Data; end: ; } -void Set (char *Arg1, char *Arg2) { +void Set(char *Arg1, char *Arg2) { if(Find(Arg1)) { MDS_Piece *DataPiece=MDS_Read(Arg1); double r=Atof(Arg2); @@ -89,7 +84,6 @@ DataPiece->Value=r; #endif } - else NewVar(Arg1,Arg2); End: ; } Modified: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h 2009-07-13 12:42:43 UTC (rev 2) +++ smipl-devel/MDS.h 2009-07-13 12:44:25 UTC (rev 3) @@ -3,17 +3,11 @@ #define MDS_READ 0x01 #define MDS_WRITE 0x02 #define MDS_DELETE 0x04 -#define MDS_PW_READ 0x41 -#define MDS_PW_WRITE 0x32 -#define MDS_PW_DELETE 0x24 struct MDS_Piece{ char *Name; double Value; char Attribute; - char *READ_PW; - char *WRITE_PW; - char *DELETE_PW; MDS_Piece *Next; MDS_Piece() { @@ -21,27 +15,18 @@ strcpy(Name,""); Value=0; Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; - READ_PW = NULL; - WRITE_PW = NULL; - DELETE_PW = NULL; Next=NULL; } MDS_Piece(char *Name, double Value) { this->Name=new char[MDS_NAME_LENGTH]; this->Value=Value; this->Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; - this->READ_PW = NULL; - this->WRITE_PW = NULL; - this->DELETE_PW = NULL; this->Next=NULL; } - MDS_Piece(char *Name, double Value, unsigned char Attribute, char *READ_PW, char *WRITE_PW, char *DELETE_PW) { + MDS_Piece(char *Name, double Value, char attribute) { this->Name=new char[MDS_NAME_LENGTH]; this->Value=Value; - this->Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; - strcpy(this->READ_PW, READ_PW); - strcpy(this->WRITE_PW, WRITE_PW); - strcpy(this->DELETE_PW, DELETE_PW); + this->Attribute=attribute; this->Next=NULL; } }MDS_0; @@ -54,8 +39,7 @@ if(DataPiece->Next==NULL) return NULL; DataPiece=DataPiece->Next; } - if((DataPiece->Attribute&MDS_READ)) return DataPiece; - if(((DataPiece->Attribute&MDS_PW_READ))&&(DataPiece->READ_PW!=NULL)&&(Password!=NULL)) if(!strcmp(DataPiece->READ_PW,Password)) return DataPiece; + if((DataPiece->Attribute)) return DataPiece; return NULL; } MDS_Piece *MDS_Last_Piece() { @@ -70,7 +54,7 @@ bool MDS_Delete(MDS_Piece *Data){ MDS_Piece *PreviousD=&MDS_0, *NextD=Data->Next; for(;PreviousD->Next!=Data;) {if(PreviousD->Next!=NULL)PreviousD=PreviousD->Next;else return false;} - delete Data; + if(Data->Attribute&MDS_DELETE)delete Data; PreviousD->Next=NextD; } MDS_Piece *MDS_First() { Added: smipl-devel/Makefile =================================================================== --- smipl-devel/Makefile (rev 0) +++ smipl-devel/Makefile 2009-07-13 12:44:25 UTC (rev 3) @@ -0,0 +1,5 @@ +all: + g++ SMIPL.cpp +clean: + rm -f gmon.out + rm -f a.out \ No newline at end of file Modified: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-07-13 12:42:43 UTC (rev 2) +++ smipl-devel/SMIPL.cpp 2009-07-13 12:44:25 UTC (rev 3) @@ -32,25 +32,23 @@ #include "Legacy/Level0.h" #define MAX_STEPS 100000 - -int Steps=0; - +int Steps; char Data[10000][80],Cmd[80]; - +struct VirtualThread{ void Run(int Line=0) { try{ MIDI_Message MIDI_Melding; char argv[10][80],str[80],Op; bool disallow_spaces_in_names=true, command_executed; MDS_Piece *DataPiece; - int argc, Line=0,c1, c2, Address; + int argc,c1, c2, Address; double A,B; while((Steps--)>0) { try{ command_executed=false; c1=0; c2=0; - Address=0;argc=0; + argc=0; for(int a=0;a<=10;a++)argv[a][0]=0; c1=0; Op=0; @@ -77,8 +75,8 @@ Parse: #ifdef DEBUG - cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; - cout<<"C1:"<<c1<<" C2:"<<c2<<endl; + //cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; + //cout<<"C1:"<<c1<<" C2:"<<c2<<endl; #endif if(strlen(argv[0])==0) continue; @@ -188,8 +186,8 @@ command_executed=true; } if(!strcmp(argv[0], "RETURN")) { + if(StackP<0) goto End; Line=(int)Pop(); - Set("RETURN", argv[1]); command_executed=true; } if(!strcmp(argv[0], "IF")) { @@ -246,12 +244,14 @@ } if(!strcmp(argv[0], "SLEEP")) {sys_sleep(Atoi(argv[1]));command_executed=true;} - if(!command_executed) if(Find(argv[0])) { - Push(Line); - Line=Atoi(argv[0])-1; - for(int a=1;a<argc;a++) Push(Atof(argv[a])); - Push(argc-1); - command_executed=true; + if(!command_executed) { + if(Find(argv[0])) { + Push(Line); + Line=Atoi(argv[0])-1; + for(int a=1;a<argc;a++) Push(Atof(argv[a])); + Push(argc-1); + command_executed=true; + } } if(!command_executed) {cout<<"UNKNOWN COMMAND:\""<<argv[0]<<"\""<<endl;} Line++; @@ -268,7 +268,8 @@ catch(...){throw;} End: ; -} +}; +}; #define CON 0 #define SCR 1 int main() { @@ -289,6 +290,9 @@ #ifdef MAX_VER NewVar("SMIPL_VER",MAX_VER); #endif + + VirtualThread CurrentSmiplThread; + try{ FillLine('_'); PrintCentered("SMIPL"); @@ -358,7 +362,7 @@ if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!strcmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} if(!strcmp(Cmd,"RUN")) { Steps=MAX_STEPS; - Run(); + CurrentSmiplThread.Run(); } if(!strcmp(Cmd,"DUMP")) { cout<<endl<<"DUMPING MBS..."<<endl; @@ -392,10 +396,11 @@ Lin++; if(Lin>10000) {cout<<"LIBRARY TO COMPLEX OR START ADDRESS TO HIGH, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} } - Run(atoi(LIB_START)); //Library auto-init + CurrentSmiplThread.Run(atoi(LIB_START)); //Library auto-init } if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} + if(!strcmp(Cmd,"EDIT")) {cout<<"LINE> ";cin.getline(Cmd,80); if((Atoi(Cmd)!=0)||(isdigit(Cmd[0]))){ EnterProg=true;Lin=Atoi(Cmd); while(EnterProg) { @@ -407,6 +412,7 @@ if(Lin>10000) {cout<<"PROGRAM TO COMPLEX, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} } } + } goto top; } catch(char* err) {cout<<"ERROR: "<<err<<endl;} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 12:42:48
|
Revision: 2 http://smipl.svn.sourceforge.net/smipl/?rev=2&view=rev Author: the_student Date: 2009-07-13 12:42:43 +0000 (Mon, 13 Jul 2009) Log Message: ----------- 41cc Modified Paths: -------------- smipl-devel/Legacy/Level0.h smipl-devel/MDS.h smipl-devel/SIA.h smipl-devel/SIASOUND.h smipl-devel/SMIPL.cpp Modified: smipl-devel/Legacy/Level0.h =================================================================== --- smipl-devel/Legacy/Level0.h 2009-07-13 12:15:18 UTC (rev 1) +++ smipl-devel/Legacy/Level0.h 2009-07-13 12:42:43 UTC (rev 2) @@ -18,11 +18,10 @@ if(a=='<') return true; if(a=='>') return true; if(a=='=') return true; - return false; } -double Stack[80000]; +double Stack[8000]; int StackP=-1; double Pop() { double Address=Stack[StackP]; @@ -36,12 +35,19 @@ if(StackP>80000) throw StackUnderflow; } +int Find (char *Pref,char *Arg1) { + if(!strcmp(Arg1,"ANSI")) return true; + if(!strcmp(Arg1,"?")) return true; + if(MDS_Read(Pref,Arg1)!=NULL) return true; + else return false; +} int Find (char *Arg1) { - if(!strcmp(Arg1,"ANSI")) return true; - if(!strcmp(Arg1,"?")) return true; - if(MDS_Read(Arg1)!=NULL) return true; - else return false; + if(!strcmp(Arg1,"ANSI")) return true; + if(!strcmp(Arg1,"?")) return true; + if(MDS_Read(Arg1)!=NULL) return true; + else return false; } + double Atof(char *Arg1) { double r; if(!strcmp(Arg1,"")) return 0; @@ -52,7 +58,21 @@ return DataPiece->Value; } int Atoi(char *Arg1) {return(int)Atof(Arg1);} + +void NewVar(char *Arg1, char *Arg2) { + MDS_Piece Data; + if(!strcmp(Arg1,"?")) goto end; + strcpy(Data.Name,Arg1); + Data.Value=Atof(Arg2); + Data.Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; + Data.READ_PW=Data.WRITE_PW=Data.DELETE_PW; + Data.Next=NULL; + MDS_Create(Data); + delete &Data; + end: ; +} void Set (char *Arg1, char *Arg2) { + if(Find(Arg1)) { MDS_Piece *DataPiece=MDS_Read(Arg1); double r=Atof(Arg2); if(!Find(Arg1)) {cout<<"\""<<Arg1<<"\" not found"<<endl;goto End;} @@ -68,20 +88,8 @@ if(!strcmp(Arg1, "SMIPL_VER")) goto End; DataPiece->Value=r; #endif - + } + else NewVar(Arg1,Arg2); End: ; } - -void NewVar(char *Arg1, char *Arg2) { - MDS_Piece Data; - if(!strcmp(Arg1,"?")) goto end; - strcpy(Data.Name,Arg1); - Data.Value=Atof(Arg2); - Data.Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; - Data.READ_PW=Data.WRITE_PW=Data.DELETE_PW; - Data.Next=NULL; - MDS_Create(Data); - delete &Data; - end: ; -} Modified: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h 2009-07-13 12:15:18 UTC (rev 1) +++ smipl-devel/MDS.h 2009-07-13 12:42:43 UTC (rev 2) @@ -63,23 +63,13 @@ while(DataPiece->Next!=NULL) DataPiece=DataPiece->Next; return DataPiece; } -bool MDS_Write(MDS_Piece Data) { - MDS_Piece *DataPiece=&MDS_0; - while(1) { - if(!strcmp(DataPiece->Name,Data.Name)) break; - if(DataPiece->Next==NULL) return false; - DataPiece=DataPiece->Next; - } - *DataPiece=Data; - return true; -} bool MDS_Create(MDS_Piece Data) { MDS_Piece *DataPiece=MDS_Last_Piece(); DataPiece->Next=new MDS_Piece(Data); } bool MDS_Delete(MDS_Piece *Data){ MDS_Piece *PreviousD=&MDS_0, *NextD=Data->Next; - for(;PreviousD->Next!=Data;) PreviousD=PreviousD->Next; + for(;PreviousD->Next!=Data;) {if(PreviousD->Next!=NULL)PreviousD=PreviousD->Next;else return false;} delete Data; PreviousD->Next=NextD; } Modified: smipl-devel/SIA.h =================================================================== --- smipl-devel/SIA.h 2009-07-13 12:15:18 UTC (rev 1) +++ smipl-devel/SIA.h 2009-07-13 12:42:43 UTC (rev 2) @@ -1,6 +1,9 @@ -#ifdef LINUX +#ifdef __linux__ +#include <unistd.h> +#include <fcntl.h> void sys_sleep(int time) {usleep(time);} #endif #ifdef WIN32 +#include <windows.h> void sys_sleep(int time) {Sleep(time);} #endif Modified: smipl-devel/SIASOUND.h =================================================================== --- smipl-devel/SIASOUND.h 2009-07-13 12:15:18 UTC (rev 1) +++ smipl-devel/SIASOUND.h 2009-07-13 12:42:43 UTC (rev 2) @@ -1,9 +1,7 @@ bool MIDI_OUT_INITED=false; typedef union { unsigned long word; unsigned char data[4]; }MIDI_Message; -#ifdef LINUX +#ifdef __linux__ #include <linux/soundcard.h> -#include <unistd.h> -#include <fcntl.h> int MIDI_Out; void MIDI_Init() { if(MIDI_Out=open("/dev/midi",O_WRONLY,0)<0) goto End; @@ -15,13 +13,12 @@ } void MIDI_Write(MIDI_Message Melding) { if(MIDI_OUT_INITED) { - write(MIDI_Out, Melding, sizeof(Melding)); + write(MIDI_Out, Melding.data, sizeof(Melding)); } } #endif #ifdef WIN32 -#include <windows.h> HMIDIOUT MIDI_Out; void MIDI_Init() { if (midiOutOpen(&MIDI_Out, 0, 0, 0, CALLBACK_NULL) != MMSYSERR_NOERROR) { Modified: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp 2009-07-13 12:15:18 UTC (rev 1) +++ smipl-devel/SMIPL.cpp 2009-07-13 12:42:43 UTC (rev 2) @@ -1,346 +1,418 @@ -/*This file is part of SMIPL. - - SMIPL is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - SMIPL is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with SMIPL. If not, see <http://www.gnu.org/licenses/>. -*/ -#include <stdio.h> -#include <ctype.h> -#include <iostream.h> -#include <fstream.h> -#include <math.h> -using namespace std; - -#include "Error.h" -#include "MDS.h" -#include "SIASOUND.h" -#include "SIA.h" - -#include "Legacy\Level0.h" -#define MAX_STEPS 100000 - -int Steps=0; - -char Data[10000][80],Cmd[80]; - -void Run(int Line=0) { - try{ - MIDI_Message MIDI_Melding; - char argv[10][80],str[80],Op; - bool disallow_spaces_in_names=true, command_executed; - MDS_Piece *DataPiece; - int argc, Line=0,c1, c2, Address; - double A,B; - while((Steps--)>0) { - try{ - command_executed=false; - c1=0; - c2=0; - Address=0;argc=0; - for(int a=0;a<=10;a++)argv[a][0]=0; - c1=0; - Op=0; - while(Data[Line][c1]!=0) { - c2=0; - while(!isDelim(Data[Line][c1],disallow_spaces_in_names)) { - if(argc!=0) argv[argc][c2]=Data[Line][c1]; - else argv[argc][c2]=toupper(Data[Line][c1]); - if(argv[argc][c2]=='"') disallow_spaces_in_names=!disallow_spaces_in_names; - c1++; - c2++; - } - if(Data[Line][c1]=='<') {Op='<';} - if(Data[Line][c1]=='>') {Op='>';} - if(Data[Line][c1]=='=') {Op='=';} - argv[argc][c2]='\0'; - if(Op!=0) c1++; - if(strlen(argv[argc])>0) argc++; - NextArg: - //cout<<"."; - if(Data[Line][c1]=='\0') goto Parse; - while(!isgraph(Data[Line][c1])) {if(Data[Line][c1++]=='\0') break;} - } - - Parse: - #ifdef DEBUG - cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; - cout<<"C1:"<<c1<<" C2:"<<c2<<endl; - #endif - if(strlen(argv[0])==0) continue; - if(!strcmp(argv[0],"NEW")) { - if(Find(argv[1])) MDS_Delete(MDS_Read(argv[1])); - NewVar(argv[1],argv[2]); - } - if(!strcmp(argv[0], "SET")) { - if(!Find(argv[1])) NewVar(argv[1], argv[2]); - else Set(argv[1], argv[2]); - command_executed=true; - } - if(!strcmp(argv[0], "ADD")) if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])+Atof(argv[2])); - Set(argv[1],str); - command_executed=true; - } - if(!strcmp(argv[0], "SUBTRACT")) if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])-Atof(argv[2])); - Set(argv[1],str); - command_executed=true; - } - if(!strcmp(argv[0], "MULTIPLY")) if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])*Atof(argv[2])); - Set(argv[1],str); - command_executed=true; - } - if(!strcmp(argv[0], "DIVIDE")) if(Find(argv[1])) { - sprintf(str,"%f",Atof(argv[1])/Atof(argv[2])); - Set(argv[1],str); - command_executed=true; - } - - if(!strcmp(argv[0], "PRINT")) { - if(Find(argv[1])) { - if(strcmp(argv[1],"?")){DataPiece=MDS_Read(argv[1]); - cout<<DataPiece->Name<<"="<<DataPiece->Value<<endl;} - else cout<<"?="<<Atoi("?"); - } - else cout<<"\""<<argv[1]<<"\" not found"<<endl; - command_executed=true; - } - - if(!strcmp(argv[0], "GOTO")) { - Line=Atoi(argv[1])-1; - command_executed=true; - } - - if(!strcmp(argv[0], "GOSUB")) { - Push(Line); - Line=Atoi(argv[1])-1; - command_executed=true; - } - if(!strcmp(argv[0], "RETURN")) { - Line=(int)Pop(); - command_executed=true; - } - if(!strcmp(argv[0], "IF")) { - A=Atof(argv[1]); - B=Atof(argv[2]); - if(Op=='=') if(A!=B) Line++; - if(Op=='<') if(A>=B) Line++; - if(Op=='>') if(A<=B) Line++; - command_executed=true; - } - if(!strcmp(argv[0], "IF!")){ - A=Atof(argv[1]); - B=Atof(argv[2]); - if(Op=='=') if(!(A!=B)) Line++; - if(Op=='<') if(!(A>=B)) Line++; - if(Op=='>') if(!(A<=B)) Line++; - command_executed=true; - } - - if(!strcmp(argv[0], "NEWLINE")) { - cout<<endl; - command_executed=true; - } - if(!strcmp(argv[0], "STOP")) { - command_executed=true; - goto End; - } - if(!strcmp(argv[0], "PUSH")) { - Push(Atof(argv[1])); - command_executed=true; - } - if(!strcmp(argv[0], "POP")) { - if(Find(argv[1])) { - DataPiece=MDS_Read(argv[1]); - DataPiece->Value=Pop(); - } - command_executed=true; - } - if(!strcmp(argv[0], "MIDI")) { - if(!MIDI_OUT_INITED){ - MIDI_Init(); - if(!MIDI_OUT_INITED) goto End; - } - MIDI_Melding.data[0] = 0x90; // MIDI note-on message (requires to data bytes) - MIDI_Melding.data[1] = 60; // MIDI note-on message: Key number (60 = middle C) - MIDI_Melding.data[2] = 100; // MIDI note-on message: Key velocity (100 = loud) - MIDI_Melding.data[3] = 0; // Unused parameter - if(argc==2) MIDI_Melding.data[1]=Atoi(argv[1]); - if(argc==3) {MIDI_Melding.data[1]=Atoi(argv[1]);MIDI_Melding.data[2]=Atoi(argv[2]);} - if(argc>=4) {MIDI_Melding.data[0]=Atoi(argv[1]);MIDI_Melding.data[1]=Atoi(argv[2]);MIDI_Melding.data[3]=Atoi(argv[3]);} - MIDI_Write(MIDI_Melding); - - command_executed=true; - } - if(!strcmp(argv[0], "SLEEP")) sys_sleep(Atoi(argv[1])); - - if(!command_executed) if(Find(argv[0])) { - Push(Line); - Line=Atoi(argv[0])-1; - for(int a=1;a<argc;a++) Push(Atof(argv[a])); - Push(argc-1); - command_executed=true; - } - Line++; - } - catch(int VE_Err) { - if(Find("ONWARNING_HANDLER")) {Push(--Line);Line=Atoi("ONWARNING_HANDLER");Push(VE_Err);Push(1);} - else throw VE_Err; - } - catch(...) {throw;} - } - if(Steps==0) cout<<"ERROR: VIRTUAL PROGRAM KILLED OFF, MORE THAN "<<MAX_STEPS<<" PROGRAM LINES EXECUTED"<<endl; - } - catch(int err) {cout<<"ERROR: "<<err<<endl;} - catch(...){throw;} - End: - ; -} -#define CON 0 -#define SCR 1 -int main() { - fstream the_file; - char Licence[15][80]={ - "SMIPL is free software: you can redistribute it and/or modify", - "it under the terms of the GNU General Public License as published by", - "the Free Software Foundation, either version 3 of the License, or", - "(at your option) any later version.", - " ", - "SMIPL is distributed in the hope that it will be useful,", - "but WITHOUT ANY WARRANTY; without even the implied warranty of", - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the", - "GNU General Public License for more details.", - " ", - "You should have received a copy of the GNU General Public License", - "along with SMIPL. If not, see <http://www.gnu.org/licenses/>."}; - #ifdef MAX_VER - NewVar("SMIPL_VER",MAX_VER); - #endif - try{ - PrintCentered("SMIPL"); - PrintCentered("for licence information, write GPL"); - FillLine('_'); - int Lin,Address; - bool EnterProg, List=false, LIB_MODE=false; - int Mode=CON; - char Name[255], LIB_START[10]; - fstream Script, Library; - top: - MDS_Piece DataPiece=MDS_0; - Lin=0; - List=false; - EnterProg=false; - cout<<endl<<"? "; - if(Mode==CON) cin.getline(Cmd, 80); - if(Mode==SCR) {Script.getline(Cmd, 80);cout<<Cmd<<endl;if(Script.eof()) {Script.close();Mode=CON;}} - - for(int c1=0;Cmd[c1]!=0;c1++) Cmd[c1]=toupper(Cmd[c1]); - - if(!strcmp(Cmd,"GPL")) {cout<<endl;for(int y=0;strcmp(Licence[y], ""); y++) cout<<Licence[y]<<endl;cout<<endl;} - - if(!strcmp(Cmd,"NEW")) { - while(MDS_First()!=NULL) MDS_Delete(MDS_First()); - for(int a=0;a<=10000;a++)strcpy(Data[a],"PROGRAM END"); - StackP=-1; - } - - if(!strcmp(Cmd,"PROGRAM START")) { - EnterProg=true;Lin=0; - while(EnterProg) { - cout<<Lin<<" "; - if(Mode==CON) cin.getline(Data[Lin], 80); - if(Mode==SCR) {Script.getline(Data[Lin], 80);cout<<Data[Lin]<<endl;} - if(!strcasecmp(Data[Lin], "PROGRAM END")) {EnterProg=false;goto top;} - Lin++; - if(Lin>10000) {cout<<"PROGRAM TO COMPLEX, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} - } - } - if(!strcmp(Cmd,"LOAD")) { - cout<<"FILENAME: "; - cin.getline(Cmd,80); - the_file.open(Cmd,ios::in); - if(!the_file.is_open()) {cout<<"FILE NOT FOUND!"<<endl;goto top;} - the_file.getline(Cmd,80); - if(strcmp(Cmd,"SMIPL PROGRAM")) {cout<<"UNKNOWN FILE TYPE"<<endl;the_file.close();goto top;} - do{ - the_file.getline(Data[Lin++],80); - }while(!the_file.eof()); - the_file.close(); - goto top; - } - if(!strcmp(Cmd,"SAVE")) { - cout<<"FILENAME: "; - cin.getline(Cmd,80); - the_file.open(Cmd,ios::out); - the_file<<"SMIPL PROGRAM"<<endl; - Lin=0; - cout<<"SAVING..."; - do{ - the_file<<Data[Lin]<<endl; - }while(strcmp(Data[Lin++],"PROGRAM END")); - cout<<"OK"<<endl; - the_file.close(); - } - if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!strcmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} - if(!strcmp(Cmd,"RUN")) { - Steps=MAX_STEPS; - Run(); - } - if(!strcmp(Cmd,"DUMP")) { - cout<<endl<<"DUMPING MBS..."<<endl; - DataPiece=MDS_0; - while(DataPiece.Next!=NULL){ - DataPiece=*DataPiece.Next; - cout<<"NAME:\""<<DataPiece.Name<<"\" VALUE:\""<<DataPiece.Value<<"\""<<endl; - } - cout<<endl<<"DUMPING STACK..."<<endl; - for(int a=0;a<=StackP;a++) cout<<"\""<<Stack[a]<<"\""<<endl; - } - if(!strcmp(Cmd,"QUIT")) goto End; - if(!strcmp(Cmd,"EXIT")) goto End; - if(!strcmp(Cmd,"LIBRARY")) { - do{ - cout<<"LIBRARY NAME? "; - cin.getline(Name, 255); - Library.open(Name); - cout<<"LIBRARY START? "; - cin.getline(LIB_START, 255); - }while(atoi(LIB_START)>10000); - Address=Find(Name); - if(!Address) NewVar(Name, LIB_START); - else Set(Name, LIB_START); - if(Library.is_open()) LIB_MODE=true; - else goto top; - Lin=atoi(LIB_START); - while(LIB_MODE) { - Library.getline(Data[atoi(LIB_START)+Lin], 80); - if(Library.eof()) {LIB_MODE=false;Library.close();goto top;} - Lin++; - if(Lin>10000) {cout<<"LIBRARY TO COMPLEX OR START ADDRESS TO HIGH, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} - } - Run(atoi(LIB_START)); //Library auto-init - } - - if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} - goto top; - } - catch(char* err) {cout<<"ERROR: "<<err<<endl;} - catch(bad_alloc&) {cout<<"R/E: Allocation failure"<<endl;for(;;);} //Might not work, but then again it is better to have tried, and failed than never to have tried at all! - catch(bad_cast&) {cout<<"R/E: Casting failure"<<endl;for(;;);} - catch(bad_exception&) {cout<<"R/E: Unknown exception"<<endl;for(;;);} - catch(bad_typeid&) {cout<<"R/E: Typeid exception"<<endl;for(;;);} - catch(ios_base::failure&) {cout<<"R/E: IOS_BASE failure"<<endl;for(;;);} //Might not work, but then again it is better to have tried, and failed than never to have tried at all! - catch(...) {cout<<"R/E: GENERIC ERROR"<<endl;for(;;);} - End: - ; -} +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <math.h> + +#include <iostream> +#include <fstream> + +#include <string.h> + +using namespace std; + +#include "Error.h" +#include "MDS.h" +#include "SIA.h" +#include "SIASOUND.h" + +#include "Legacy/Level0.h" +#define MAX_STEPS 100000 + +int Steps=0; + +char Data[10000][80],Cmd[80]; + +void Run(int Line=0) { + try{ + MIDI_Message MIDI_Melding; + char argv[10][80],str[80],Op; + bool disallow_spaces_in_names=true, command_executed; + MDS_Piece *DataPiece; + int argc, Line=0,c1, c2, Address; + double A,B; + while((Steps--)>0) { + try{ + command_executed=false; + c1=0; + c2=0; + Address=0;argc=0; + for(int a=0;a<=10;a++)argv[a][0]=0; + c1=0; + Op=0; + while(Data[Line][c1]!=0) { + c2=0; + while(!isDelim(Data[Line][c1],disallow_spaces_in_names)) { + if(argc!=0) argv[argc][c2]=Data[Line][c1]; + else argv[argc][c2]=toupper(Data[Line][c1]); + if(argv[argc][c2]=='"') disallow_spaces_in_names=!disallow_spaces_in_names; + c1++; + c2++; + } + if(Data[Line][c1]=='<') {Op='<';} + if(Data[Line][c1]=='>') {Op='>';} + if(Data[Line][c1]=='=') {Op='=';} + argv[argc][c2]='\0'; + if(Op!=0) c1++; + if(strlen(argv[argc])>0) argc++; + NextArg: + //cout<<"."; + if(Data[Line][c1]=='\0') goto Parse; + while(!isgraph(Data[Line][c1])) {if(Data[Line][c1++]=='\0') break;} + } + + Parse: + #ifdef DEBUG + cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; + cout<<"C1:"<<c1<<" C2:"<<c2<<endl; + #endif + if(strlen(argv[0])==0) continue; + + if(!strcmp(argv[0],"NEW")) { + if(argc>=1) { + if(Find(argv[1])) MDS_Delete(MDS_Read(argv[1])); + NewVar(argv[1],argv[2]); + NewVar(argv[1],""); + } + command_executed=true; + } + if(!strcmp(argv[0],"DELETE")) { + for(int a=1;strlen(argv[a])>0;a++) if(Find(argv[a]))MDS_Delete(MDS_Read(argv[a])); + command_executed=true; + } + + if(!strcmp(argv[0], "SET")) { + if(!Find(argv[1])) NewVar(argv[1], argv[2]); + else Set(argv[1], argv[2]); + command_executed=true; + } + if(!strcmp(argv[0], "ADD")) {if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])+Atof(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "SUBTRACT")) {if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])-Atof(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "MULTIPLY")) {if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])*Atof(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "DIVIDE")) {if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])/Atof(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + + if(!strcmp(argv[0], "ROOT")) {if(Find(argv[1])) { + sprintf(str,"%f",sqrt(Atof(argv[argc-1]))); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "LOG")) {if(Find(argv[1])) { + sprintf(str,"%f",log(Atof(argv[argc-1]))); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "POWER")) {if((Find(argv[1]))&&(argc>=3)) { + sprintf(str,"%f",pow(Atof(argv[argc-2]), Atof(argv[argc-1]))); + Set(argv[1],str); + } + command_executed=true; + } + + if(!strcmp(argv[0],"NOT")) {if(Find(argv[1])) { + sprintf(str,"%f",!Atoi(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "OR")) {if(Find(argv[1])) { + sprintf(str,"%f",Atoi(argv[1])|Atoi(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0],"AND")) {if(Find(argv[1])) { + sprintf(str,"%f",Atoi(argv[1])&Atoi(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0],"XOR")) {if(Find(argv[1])) { + sprintf(str,"%f",Atoi(argv[1])^Atoi(argv[2])); + Set(argv[1],str); + } + command_executed=true; + } + if(!strcmp(argv[0], "PRINT")) { + for(int a=1;a<argc;a++) { + if(Find(argv[a])) cout<<argv[a]<<"="<<Atof(argv[a])<<" "; + else cout<<"\""<<argv[a]<<"\" not found"; + } + cout<<endl; + command_executed=true; + } + + if(!strcmp(argv[0], "GOTO")) { + Line=Atoi(argv[1])-1; + command_executed=true; + } + + if(!strcmp(argv[0], "GOSUB")) { + Push(Line); + Line=Atoi(argv[1])-1; + command_executed=true; + } + if(!strcmp(argv[0], "RETURN")) { + Line=(int)Pop(); + Set("RETURN", argv[1]); + command_executed=true; + } + if(!strcmp(argv[0], "IF")) { + A=Atof(argv[1]); + B=Atof(argv[2]); + if(Op=='=') if(A!=B) Line++; + if(Op=='<') if(A>=B) Line++; + if(Op=='>') if(A<=B) Line++; + command_executed=true; + } + if(!strcmp(argv[0], "IF!")){ + A=Atof(argv[1]); + B=Atof(argv[2]); + if(Op=='=') if(!(A!=B)) Line++; + if(Op=='<') if(!(A>=B)) Line++; + if(Op=='>') if(!(A<=B)) Line++; + command_executed=true; + } + + if(!strcmp(argv[0], "NEWLINE")) { + cout<<endl; + command_executed=true; + } + if(!strcmp(argv[0], "STOP")) { + command_executed=true; + goto End; + } + if(!strcmp(argv[0], "PUSH")) { + Push(Atof(argv[1])); + command_executed=true; + } + if(!strcmp(argv[0], "POP")) { + if(Find(argv[1])) { + DataPiece=MDS_Read(argv[1]); + DataPiece->Value=Pop(); + } + command_executed=true; + } + if(!strcmp(argv[0], "MIDI")) { + if(!MIDI_OUT_INITED){ + MIDI_Init(); + if(!MIDI_OUT_INITED) goto End; + } + MIDI_Melding.data[0] = 0x90; // MIDI note-on message (requires to data bytes) + MIDI_Melding.data[1] = 60; // MIDI note-on message: Key number (60 = middle C) + MIDI_Melding.data[2] = 100; // MIDI note-on message: Key velocity (100 = loud) + MIDI_Melding.data[3] = 0; // Unused parameter + if(argc==2) MIDI_Melding.data[1]=Atoi(argv[1]); + if(argc==3) {MIDI_Melding.data[1]=Atoi(argv[1]);MIDI_Melding.data[2]=Atoi(argv[2]);} + if(argc>=4) {MIDI_Melding.data[0]=Atoi(argv[1]);MIDI_Melding.data[1]=Atoi(argv[2]);MIDI_Melding.data[3]=Atoi(argv[3]);} + MIDI_Write(MIDI_Melding); + + command_executed=true; + } + if(!strcmp(argv[0], "SLEEP")) {sys_sleep(Atoi(argv[1]));command_executed=true;} + + if(!command_executed) if(Find(argv[0])) { + Push(Line); + Line=Atoi(argv[0])-1; + for(int a=1;a<argc;a++) Push(Atof(argv[a])); + Push(argc-1); + command_executed=true; + } + if(!command_executed) {cout<<"UNKNOWN COMMAND:\""<<argv[0]<<"\""<<endl;} + Line++; + } + catch(int VE_Err) { + if(Find("ONWARNING_HANDLER")) {Push(--Line);Line=Atoi("ONWARNING_HANDLER");Push(VE_Err);Push(1);} + else throw VE_Err; + } + catch(...) {throw;} + } + if(Steps==0) cout<<"ERROR: VIRTUAL PROGRAM KILLED OFF, MORE THAN "<<MAX_STEPS<<" PROGRAM LINES EXECUTED"<<endl; + } + catch(int err) {cout<<"ERROR: "<<err<<endl;} + catch(...){throw;} + End: + ; +} +#define CON 0 +#define SCR 1 +int main() { + fstream the_file; + char Licence[15][80]={ + "SMIPL is free software: you can redistribute it and/or modify", + "it under the terms of the GNU General Public License as published by", + "the Free Software Foundation, either version 3 of the License, or", + "(at your option) any later version.", + " ", + "SMIPL is distributed in the hope that it will be useful,", + "but WITHOUT ANY WARRANTY; without even the implied warranty of", + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the", + "GNU General Public License for more details.", + " ", + "You should have received a copy of the GNU General Public License", + "along with SMIPL. If not, see <http://www.gnu.org/licenses/>."}; + #ifdef MAX_VER + NewVar("SMIPL_VER",MAX_VER); + #endif + try{ + FillLine('_'); + PrintCentered("SMIPL"); + PrintCentered("for licence information, write GPL"); + FillLine('_'); + int Lin,Address; + bool EnterProg, List=false, LIB_MODE=false; + int Mode=CON; + char Name[255], LIB_START[10]; + fstream Script, Library; + top: + MDS_Piece DataPiece=MDS_0; + Lin=0; + List=false; + EnterProg=false; + cout<<endl<<"? "; + if(Mode==CON) cin.getline(Cmd, 80); + if(Mode==SCR) {Script.getline(Cmd, 80);cout<<Cmd<<endl;if(Script.eof()) {Script.close();Mode=CON;}} + + for(int c1=0;Cmd[c1]!=0;c1++) Cmd[c1]=toupper(Cmd[c1]); + + if(!strcmp(Cmd,"GPL")) {cout<<endl;for(int y=0;strcmp(Licence[y], ""); y++) cout<<Licence[y]<<endl;cout<<endl;} + + if(!strcmp(Cmd,"NEW")) { + while(MDS_First()!=NULL) MDS_Delete(MDS_First()); + for(int a=0;a<=10000;a++)strcpy(Data[a],"PROGRAM END"); + StackP=-1; + } + + if(!strcmp(Cmd,"PROGRAM START")) { + EnterProg=true;Lin=0; + while(EnterProg) { + cout<<Lin<<" "; + if(Mode==CON) cin.getline(Data[Lin], 80); + if(Mode==SCR) {Script.getline(Data[Lin], 80);cout<<Data[Lin]<<endl;} + if(!strcasecmp(Data[Lin], "PROGRAM END")) {EnterProg=false;goto top;} + Lin++; + if(Lin>10000) {cout<<"PROGRAM TO COMPLEX, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} + } + } + if(!strcmp(Cmd,"LOAD")) { + cout<<"FILENAME: "; + cin.getline(Cmd,80); + the_file.open(Cmd,ios::in); + if(!the_file.is_open()) {cout<<"FILE NOT FOUND!"<<endl;goto top;} + the_file.getline(Cmd,80); + if(strcmp(Cmd,"SMIPL PROGRAM")) {cout<<"UNKNOWN FILE TYPE"<<endl;the_file.close();goto top;} + do{ + the_file.getline(Data[Lin++],80); + }while(!the_file.eof()); + the_file.close(); + goto top; + } + if(!strcmp(Cmd,"SAVE")) { + cout<<"FILENAME: "; + cin.getline(Cmd,80); + the_file.open(Cmd,ios::out); + the_file<<"SMIPL PROGRAM"<<endl; + Lin=0; + cout<<"SAVING..."; + do{ + the_file<<Data[Lin]<<endl; + }while(strcmp(Data[Lin++],"PROGRAM END")); + cout<<"OK"<<endl; + the_file.close(); + } + if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!strcmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} + if(!strcmp(Cmd,"RUN")) { + Steps=MAX_STEPS; + Run(); + } + if(!strcmp(Cmd,"DUMP")) { + cout<<endl<<"DUMPING MBS..."<<endl; + DataPiece=MDS_0; + while(DataPiece.Next!=NULL){ + DataPiece=*DataPiece.Next; + cout<<"NAME:\""<<DataPiece.Name<<"\" VALUE:\""<<DataPiece.Value<<"\""<<endl; + } + cout<<endl<<"DUMPING STACK..."<<endl; + for(int a=0;a<=StackP;a++) cout<<"\""<<Stack[a]<<"\""<<endl; + } + if(!strcmp(Cmd,"QUIT")) goto End; + if(!strcmp(Cmd,"EXIT")) goto End; + if(!strcmp(Cmd,"LIBRARY")) { + do{ + cout<<"LIBRARY NAME? "; + cin.getline(Name, 255); + Library.open(Name); + cout<<"LIBRARY START? "; + cin.getline(LIB_START, 255); + }while(atoi(LIB_START)>10000); + Address=Find(Name); + if(!Address) NewVar(Name, LIB_START); + else Set(Name, LIB_START); + if(Library.is_open()) LIB_MODE=true; + else goto top; + Lin=atoi(LIB_START); + while(LIB_MODE) { + Library.getline(Data[atoi(LIB_START)+Lin], 80); + if(Library.eof()) {LIB_MODE=false;Library.close();goto top;} + Lin++; + if(Lin>10000) {cout<<"LIBRARY TO COMPLEX OR START ADDRESS TO HIGH, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} + } + Run(atoi(LIB_START)); //Library auto-init + } + + if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} + if((Atoi(Cmd)!=0)||(isdigit(Cmd[0]))){ + EnterProg=true;Lin=Atoi(Cmd); + while(EnterProg) { + cout<<Lin<<" "; + if(Mode==CON) cin.getline(Data[Lin], 80); + if(Mode==SCR) {Script.getline(Data[Lin], 80);cout<<Data[Lin]<<endl;} + if(!strcasecmp(Data[Lin], "PROGRAM END")) {EnterProg=false;goto top;} + Lin++; + if(Lin>10000) {cout<<"PROGRAM TO COMPLEX, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} + } + } + goto top; + } + catch(char* err) {cout<<"ERROR: "<<err<<endl;} + catch(bad_alloc&) {cout<<"R/E: Allocation failure"<<endl;for(;;);} //Might not work, but then again it is better to have tried, and failed than never to have tried at all! + catch(...) {cout<<"R/E: GENERIC ERROR"<<endl;for(;;);} + End: + ; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <the...@us...> - 2009-07-13 12:15:22
|
Revision: 1 http://smipl.svn.sourceforge.net/smipl/?rev=1&view=rev Author: the_student Date: 2009-07-13 12:15:18 +0000 (Mon, 13 Jul 2009) Log Message: ----------- SMIPL-40cc Added Paths: ----------- smipl-devel/ smipl-devel/Error.h smipl-devel/Legacy/ smipl-devel/Legacy/Level0.h smipl-devel/MDS.h smipl-devel/SIA.h smipl-devel/SIASOUND.h smipl-devel/SMIPL.cpp Added: smipl-devel/Error.h =================================================================== --- smipl-devel/Error.h (rev 0) +++ smipl-devel/Error.h 2009-07-13 12:15:18 UTC (rev 1) @@ -0,0 +1,2 @@ +#define StackUnderflow 1 +#define StackOverflow 2 Added: smipl-devel/Legacy/Level0.h =================================================================== --- smipl-devel/Legacy/Level0.h (rev 0) +++ smipl-devel/Legacy/Level0.h 2009-07-13 12:15:18 UTC (rev 1) @@ -0,0 +1,87 @@ +void FillLine(char with) {for(int a=1;a<=80;a++)cout<<with;cout<<endl;} +void PrintCentered(char *a) { + for(int b=1;b<=((80-strlen(a))/2);b++) cout<<" "; + cout<<a<<endl; +} +bool isArithm(char a) { + if(a=='+') return true; + if(a=='-') return true; + if(a=='*') return true; + if(a=='/') return true; + return false; +} +bool isDelim(char a, bool disallow_spaces=true) { + if(disallow_spaces)if(a==' ') return true; + if(a=='\n') return true; + if(a=='\0') return true; + + if(a=='<') return true; + if(a=='>') return true; + if(a=='=') return true; + + return false; +} + +double Stack[80000]; +int StackP=-1; +double Pop() { + double Address=Stack[StackP]; + StackP--; + if(StackP<0) throw StackOverflow; + return Address; +} +void Push(double Data) { + StackP++; + Stack[StackP]=Data; + if(StackP>80000) throw StackUnderflow; +} + +int Find (char *Arg1) { + if(!strcmp(Arg1,"ANSI")) return true; + if(!strcmp(Arg1,"?")) return true; + if(MDS_Read(Arg1)!=NULL) return true; + else return false; +} +double Atof(char *Arg1) { + double r; + if(!strcmp(Arg1,"")) return 0; + if(!strcmp(Arg1,"ANSI")) return cin.get(); + if(!strcmp(Arg1,"?")) {cout<<">";cin>>r;return r;} + if(!Find(Arg1)) return atof(Arg1); + MDS_Piece *DataPiece=MDS_Read(Arg1); + return DataPiece->Value; +} +int Atoi(char *Arg1) {return(int)Atof(Arg1);} +void Set (char *Arg1, char *Arg2) { + MDS_Piece *DataPiece=MDS_Read(Arg1); + double r=Atof(Arg2); + if(!Find(Arg1)) {cout<<"\""<<Arg1<<"\" not found"<<endl;goto End;} + if(!strcmp(Arg1,"?")) goto End; + if(!strcmp(Arg1,"ANSI")){ + if((r>=32)&&(r<=127))cout<<(char)r; + goto End; + } + #ifdef SMIPL_MAX_VER + if((!strcmp(Arg1, "SMIPL_VER"))&&(r<=SMIPL_MAX_VER)) DataPiece->Value=r; + else DataPiece->Value=r; + #else + if(!strcmp(Arg1, "SMIPL_VER")) goto End; + DataPiece->Value=r; + #endif + + End: + ; +} + +void NewVar(char *Arg1, char *Arg2) { + MDS_Piece Data; + if(!strcmp(Arg1,"?")) goto end; + strcpy(Data.Name,Arg1); + Data.Value=Atof(Arg2); + Data.Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; + Data.READ_PW=Data.WRITE_PW=Data.DELETE_PW; + Data.Next=NULL; + MDS_Create(Data); + delete &Data; + end: ; +} Added: smipl-devel/MDS.h =================================================================== --- smipl-devel/MDS.h (rev 0) +++ smipl-devel/MDS.h 2009-07-13 12:15:18 UTC (rev 1) @@ -0,0 +1,88 @@ +#define MDS_NAME_LENGTH 25 + +#define MDS_READ 0x01 +#define MDS_WRITE 0x02 +#define MDS_DELETE 0x04 +#define MDS_PW_READ 0x41 +#define MDS_PW_WRITE 0x32 +#define MDS_PW_DELETE 0x24 + +struct MDS_Piece{ + char *Name; + double Value; + char Attribute; + char *READ_PW; + char *WRITE_PW; + char *DELETE_PW; + + MDS_Piece *Next; + MDS_Piece() { + Name=new char[MDS_NAME_LENGTH]; + strcpy(Name,""); + Value=0; + Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; + READ_PW = NULL; + WRITE_PW = NULL; + DELETE_PW = NULL; + Next=NULL; + } + MDS_Piece(char *Name, double Value) { + this->Name=new char[MDS_NAME_LENGTH]; + this->Value=Value; + this->Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; + this->READ_PW = NULL; + this->WRITE_PW = NULL; + this->DELETE_PW = NULL; + this->Next=NULL; + } + MDS_Piece(char *Name, double Value, unsigned char Attribute, char *READ_PW, char *WRITE_PW, char *DELETE_PW) { + this->Name=new char[MDS_NAME_LENGTH]; + this->Value=Value; + this->Attribute=MDS_READ|MDS_WRITE|MDS_DELETE; + strcpy(this->READ_PW, READ_PW); + strcpy(this->WRITE_PW, WRITE_PW); + strcpy(this->DELETE_PW, DELETE_PW); + this->Next=NULL; + } +}MDS_0; + +MDS_Piece *MDS_Read(char *Name, char *Password=NULL) { + MDS_Piece *DataPiece; + DataPiece=&MDS_0; + while(1) { + if(!strcmp(DataPiece->Name,Name)) break; + if(DataPiece->Next==NULL) return NULL; + DataPiece=DataPiece->Next; + } + if((DataPiece->Attribute&MDS_READ)) return DataPiece; + if(((DataPiece->Attribute&MDS_PW_READ))&&(DataPiece->READ_PW!=NULL)&&(Password!=NULL)) if(!strcmp(DataPiece->READ_PW,Password)) return DataPiece; + return NULL; +} +MDS_Piece *MDS_Last_Piece() { + MDS_Piece *DataPiece=&MDS_0; + while(DataPiece->Next!=NULL) DataPiece=DataPiece->Next; + return DataPiece; +} +bool MDS_Write(MDS_Piece Data) { + MDS_Piece *DataPiece=&MDS_0; + while(1) { + if(!strcmp(DataPiece->Name,Data.Name)) break; + if(DataPiece->Next==NULL) return false; + DataPiece=DataPiece->Next; + } + *DataPiece=Data; + return true; +} +bool MDS_Create(MDS_Piece Data) { + MDS_Piece *DataPiece=MDS_Last_Piece(); + DataPiece->Next=new MDS_Piece(Data); +} +bool MDS_Delete(MDS_Piece *Data){ + MDS_Piece *PreviousD=&MDS_0, *NextD=Data->Next; + for(;PreviousD->Next!=Data;) PreviousD=PreviousD->Next; + delete Data; + PreviousD->Next=NextD; +} +MDS_Piece *MDS_First() { + return MDS_0.Next; +} Added: smipl-devel/SIA.h =================================================================== --- smipl-devel/SIA.h (rev 0) +++ smipl-devel/SIA.h 2009-07-13 12:15:18 UTC (rev 1) @@ -0,0 +1,6 @@ +#ifdef LINUX +void sys_sleep(int time) {usleep(time);} +#endif +#ifdef WIN32 +void sys_sleep(int time) {Sleep(time);} +#endif Added: smipl-devel/SIASOUND.h =================================================================== --- smipl-devel/SIASOUND.h (rev 0) +++ smipl-devel/SIASOUND.h 2009-07-13 12:15:18 UTC (rev 1) @@ -0,0 +1,37 @@ +bool MIDI_OUT_INITED=false; +typedef union { unsigned long word; unsigned char data[4]; }MIDI_Message; +#ifdef LINUX +#include <linux/soundcard.h> +#include <unistd.h> +#include <fcntl.h> +int MIDI_Out; +void MIDI_Init() { + if(MIDI_Out=open("/dev/midi",O_WRONLY,0)<0) goto End; + + + MIDI_OUT_INITED=true; + End: + ; +} +void MIDI_Write(MIDI_Message Melding) { + if(MIDI_OUT_INITED) { + write(MIDI_Out, Melding, sizeof(Melding)); + } +} +#endif + +#ifdef WIN32 +#include <windows.h> +HMIDIOUT MIDI_Out; +void MIDI_Init() { + if (midiOutOpen(&MIDI_Out, 0, 0, 0, CALLBACK_NULL) != MMSYSERR_NOERROR) { + printf("Error opening MIDI Output.\n"); + goto end; + } + MIDI_OUT_INITED=true; + end: + ; +} +void MIDI_Write(MIDI_Message Melding) { + if(MIDI_OUT_INITED) {if(midiOutShortMsg(MIDI_Out, Melding.word) != MMSYSERR_NOERROR) {throw "MIDI ERROR";}}} +#endif Added: smipl-devel/SMIPL.cpp =================================================================== --- smipl-devel/SMIPL.cpp (rev 0) +++ smipl-devel/SMIPL.cpp 2009-07-13 12:15:18 UTC (rev 1) @@ -0,0 +1,346 @@ +/*This file is part of SMIPL. + + SMIPL is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + SMIPL is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with SMIPL. If not, see <http://www.gnu.org/licenses/>. +*/ +#include <stdio.h> +#include <ctype.h> +#include <iostream.h> +#include <fstream.h> +#include <math.h> +using namespace std; + +#include "Error.h" +#include "MDS.h" +#include "SIASOUND.h" +#include "SIA.h" + +#include "Legacy\Level0.h" +#define MAX_STEPS 100000 + +int Steps=0; + +char Data[10000][80],Cmd[80]; + +void Run(int Line=0) { + try{ + MIDI_Message MIDI_Melding; + char argv[10][80],str[80],Op; + bool disallow_spaces_in_names=true, command_executed; + MDS_Piece *DataPiece; + int argc, Line=0,c1, c2, Address; + double A,B; + while((Steps--)>0) { + try{ + command_executed=false; + c1=0; + c2=0; + Address=0;argc=0; + for(int a=0;a<=10;a++)argv[a][0]=0; + c1=0; + Op=0; + while(Data[Line][c1]!=0) { + c2=0; + while(!isDelim(Data[Line][c1],disallow_spaces_in_names)) { + if(argc!=0) argv[argc][c2]=Data[Line][c1]; + else argv[argc][c2]=toupper(Data[Line][c1]); + if(argv[argc][c2]=='"') disallow_spaces_in_names=!disallow_spaces_in_names; + c1++; + c2++; + } + if(Data[Line][c1]=='<') {Op='<';} + if(Data[Line][c1]=='>') {Op='>';} + if(Data[Line][c1]=='=') {Op='=';} + argv[argc][c2]='\0'; + if(Op!=0) c1++; + if(strlen(argv[argc])>0) argc++; + NextArg: + //cout<<"."; + if(Data[Line][c1]=='\0') goto Parse; + while(!isgraph(Data[Line][c1])) {if(Data[Line][c1++]=='\0') break;} + } + + Parse: + #ifdef DEBUG + cout<<MAX_STEPS-Steps<<"."<<Line<<": argc:\""<<argc<<"\", argv[0]: \""<<argv[0]<<"\", argv[1]:\""<<argv[1]<<"\", argv[2]:\""<<argv[2]<<"\", argv[3]:\""<<argv[3]<<"\", Op:\""<<Op<<"\""<<endl; + cout<<"C1:"<<c1<<" C2:"<<c2<<endl; + #endif + if(strlen(argv[0])==0) continue; + if(!strcmp(argv[0],"NEW")) { + if(Find(argv[1])) MDS_Delete(MDS_Read(argv[1])); + NewVar(argv[1],argv[2]); + } + if(!strcmp(argv[0], "SET")) { + if(!Find(argv[1])) NewVar(argv[1], argv[2]); + else Set(argv[1], argv[2]); + command_executed=true; + } + if(!strcmp(argv[0], "ADD")) if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])+Atof(argv[2])); + Set(argv[1],str); + command_executed=true; + } + if(!strcmp(argv[0], "SUBTRACT")) if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])-Atof(argv[2])); + Set(argv[1],str); + command_executed=true; + } + if(!strcmp(argv[0], "MULTIPLY")) if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])*Atof(argv[2])); + Set(argv[1],str); + command_executed=true; + } + if(!strcmp(argv[0], "DIVIDE")) if(Find(argv[1])) { + sprintf(str,"%f",Atof(argv[1])/Atof(argv[2])); + Set(argv[1],str); + command_executed=true; + } + + if(!strcmp(argv[0], "PRINT")) { + if(Find(argv[1])) { + if(strcmp(argv[1],"?")){DataPiece=MDS_Read(argv[1]); + cout<<DataPiece->Name<<"="<<DataPiece->Value<<endl;} + else cout<<"?="<<Atoi("?"); + } + else cout<<"\""<<argv[1]<<"\" not found"<<endl; + command_executed=true; + } + + if(!strcmp(argv[0], "GOTO")) { + Line=Atoi(argv[1])-1; + command_executed=true; + } + + if(!strcmp(argv[0], "GOSUB")) { + Push(Line); + Line=Atoi(argv[1])-1; + command_executed=true; + } + if(!strcmp(argv[0], "RETURN")) { + Line=(int)Pop(); + command_executed=true; + } + if(!strcmp(argv[0], "IF")) { + A=Atof(argv[1]); + B=Atof(argv[2]); + if(Op=='=') if(A!=B) Line++; + if(Op=='<') if(A>=B) Line++; + if(Op=='>') if(A<=B) Line++; + command_executed=true; + } + if(!strcmp(argv[0], "IF!")){ + A=Atof(argv[1]); + B=Atof(argv[2]); + if(Op=='=') if(!(A!=B)) Line++; + if(Op=='<') if(!(A>=B)) Line++; + if(Op=='>') if(!(A<=B)) Line++; + command_executed=true; + } + + if(!strcmp(argv[0], "NEWLINE")) { + cout<<endl; + command_executed=true; + } + if(!strcmp(argv[0], "STOP")) { + command_executed=true; + goto End; + } + if(!strcmp(argv[0], "PUSH")) { + Push(Atof(argv[1])); + command_executed=true; + } + if(!strcmp(argv[0], "POP")) { + if(Find(argv[1])) { + DataPiece=MDS_Read(argv[1]); + DataPiece->Value=Pop(); + } + command_executed=true; + } + if(!strcmp(argv[0], "MIDI")) { + if(!MIDI_OUT_INITED){ + MIDI_Init(); + if(!MIDI_OUT_INITED) goto End; + } + MIDI_Melding.data[0] = 0x90; // MIDI note-on message (requires to data bytes) + MIDI_Melding.data[1] = 60; // MIDI note-on message: Key number (60 = middle C) + MIDI_Melding.data[2] = 100; // MIDI note-on message: Key velocity (100 = loud) + MIDI_Melding.data[3] = 0; // Unused parameter + if(argc==2) MIDI_Melding.data[1]=Atoi(argv[1]); + if(argc==3) {MIDI_Melding.data[1]=Atoi(argv[1]);MIDI_Melding.data[2]=Atoi(argv[2]);} + if(argc>=4) {MIDI_Melding.data[0]=Atoi(argv[1]);MIDI_Melding.data[1]=Atoi(argv[2]);MIDI_Melding.data[3]=Atoi(argv[3]);} + MIDI_Write(MIDI_Melding); + + command_executed=true; + } + if(!strcmp(argv[0], "SLEEP")) sys_sleep(Atoi(argv[1])); + + if(!command_executed) if(Find(argv[0])) { + Push(Line); + Line=Atoi(argv[0])-1; + for(int a=1;a<argc;a++) Push(Atof(argv[a])); + Push(argc-1); + command_executed=true; + } + Line++; + } + catch(int VE_Err) { + if(Find("ONWARNING_HANDLER")) {Push(--Line);Line=Atoi("ONWARNING_HANDLER");Push(VE_Err);Push(1);} + else throw VE_Err; + } + catch(...) {throw;} + } + if(Steps==0) cout<<"ERROR: VIRTUAL PROGRAM KILLED OFF, MORE THAN "<<MAX_STEPS<<" PROGRAM LINES EXECUTED"<<endl; + } + catch(int err) {cout<<"ERROR: "<<err<<endl;} + catch(...){throw;} + End: + ; +} +#define CON 0 +#define SCR 1 +int main() { + fstream the_file; + char Licence[15][80]={ + "SMIPL is free software: you can redistribute it and/or modify", + "it under the terms of the GNU General Public License as published by", + "the Free Software Foundation, either version 3 of the License, or", + "(at your option) any later version.", + " ", + "SMIPL is distributed in the hope that it will be useful,", + "but WITHOUT ANY WARRANTY; without even the implied warranty of", + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the", + "GNU General Public License for more details.", + " ", + "You should have received a copy of the GNU General Public License", + "along with SMIPL. If not, see <http://www.gnu.org/licenses/>."}; + #ifdef MAX_VER + NewVar("SMIPL_VER",MAX_VER); + #endif + try{ + PrintCentered("SMIPL"); + PrintCentered("for licence information, write GPL"); + FillLine('_'); + int Lin,Address; + bool EnterProg, List=false, LIB_MODE=false; + int Mode=CON; + char Name[255], LIB_START[10]; + fstream Script, Library; + top: + MDS_Piece DataPiece=MDS_0; + Lin=0; + List=false; + EnterProg=false; + cout<<endl<<"? "; + if(Mode==CON) cin.getline(Cmd, 80); + if(Mode==SCR) {Script.getline(Cmd, 80);cout<<Cmd<<endl;if(Script.eof()) {Script.close();Mode=CON;}} + + for(int c1=0;Cmd[c1]!=0;c1++) Cmd[c1]=toupper(Cmd[c1]); + + if(!strcmp(Cmd,"GPL")) {cout<<endl;for(int y=0;strcmp(Licence[y], ""); y++) cout<<Licence[y]<<endl;cout<<endl;} + + if(!strcmp(Cmd,"NEW")) { + while(MDS_First()!=NULL) MDS_Delete(MDS_First()); + for(int a=0;a<=10000;a++)strcpy(Data[a],"PROGRAM END"); + StackP=-1; + } + + if(!strcmp(Cmd,"PROGRAM START")) { + EnterProg=true;Lin=0; + while(EnterProg) { + cout<<Lin<<" "; + if(Mode==CON) cin.getline(Data[Lin], 80); + if(Mode==SCR) {Script.getline(Data[Lin], 80);cout<<Data[Lin]<<endl;} + if(!strcasecmp(Data[Lin], "PROGRAM END")) {EnterProg=false;goto top;} + Lin++; + if(Lin>10000) {cout<<"PROGRAM TO COMPLEX, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} + } + } + if(!strcmp(Cmd,"LOAD")) { + cout<<"FILENAME: "; + cin.getline(Cmd,80); + the_file.open(Cmd,ios::in); + if(!the_file.is_open()) {cout<<"FILE NOT FOUND!"<<endl;goto top;} + the_file.getline(Cmd,80); + if(strcmp(Cmd,"SMIPL PROGRAM")) {cout<<"UNKNOWN FILE TYPE"<<endl;the_file.close();goto top;} + do{ + the_file.getline(Data[Lin++],80); + }while(!the_file.eof()); + the_file.close(); + goto top; + } + if(!strcmp(Cmd,"SAVE")) { + cout<<"FILENAME: "; + cin.getline(Cmd,80); + the_file.open(Cmd,ios::out); + the_file<<"SMIPL PROGRAM"<<endl; + Lin=0; + cout<<"SAVING..."; + do{ + the_file<<Data[Lin]<<endl; + }while(strcmp(Data[Lin++],"PROGRAM END")); + cout<<"OK"<<endl; + the_file.close(); + } + if(!strcmp(Cmd,"LIST")) {List=true;while(List) {cout<<Lin<<":"<<Data[Lin]<<endl;if(!strcmp(Data[Lin], "PROGRAM END")) {List=false;goto top;}Lin++;}} + if(!strcmp(Cmd,"RUN")) { + Steps=MAX_STEPS; + Run(); + } + if(!strcmp(Cmd,"DUMP")) { + cout<<endl<<"DUMPING MBS..."<<endl; + DataPiece=MDS_0; + while(DataPiece.Next!=NULL){ + DataPiece=*DataPiece.Next; + cout<<"NAME:\""<<DataPiece.Name<<"\" VALUE:\""<<DataPiece.Value<<"\""<<endl; + } + cout<<endl<<"DUMPING STACK..."<<endl; + for(int a=0;a<=StackP;a++) cout<<"\""<<Stack[a]<<"\""<<endl; + } + if(!strcmp(Cmd,"QUIT")) goto End; + if(!strcmp(Cmd,"EXIT")) goto End; + if(!strcmp(Cmd,"LIBRARY")) { + do{ + cout<<"LIBRARY NAME? "; + cin.getline(Name, 255); + Library.open(Name); + cout<<"LIBRARY START? "; + cin.getline(LIB_START, 255); + }while(atoi(LIB_START)>10000); + Address=Find(Name); + if(!Address) NewVar(Name, LIB_START); + else Set(Name, LIB_START); + if(Library.is_open()) LIB_MODE=true; + else goto top; + Lin=atoi(LIB_START); + while(LIB_MODE) { + Library.getline(Data[atoi(LIB_START)+Lin], 80); + if(Library.eof()) {LIB_MODE=false;Library.close();goto top;} + Lin++; + if(Lin>10000) {cout<<"LIBRARY TO COMPLEX OR START ADDRESS TO HIGH, SMIPL RAN OUT"<<endl;EnterProg=false;goto top;} + } + Run(atoi(LIB_START)); //Library auto-init + } + + if(!strcmp(Cmd,"SCRIPT")) {cin.getline(Name, 255); Script.open(Name); if(Script.is_open())Mode=SCR;} + goto top; + } + catch(char* err) {cout<<"ERROR: "<<err<<endl;} + catch(bad_alloc&) {cout<<"R/E: Allocation failure"<<endl;for(;;);} //Might not work, but then again it is better to have tried, and failed than never to have tried at all! + catch(bad_cast&) {cout<<"R/E: Casting failure"<<endl;for(;;);} + catch(bad_exception&) {cout<<"R/E: Unknown exception"<<endl;for(;;);} + catch(bad_typeid&) {cout<<"R/E: Typeid exception"<<endl;for(;;);} + catch(ios_base::failure&) {cout<<"R/E: IOS_BASE failure"<<endl;for(;;);} //Might not work, but then again it is better to have tried, and failed than never to have tried at all! + catch(...) {cout<<"R/E: GENERIC ERROR"<<endl;for(;;);} + End: + ; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |