00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __loaded__doc_cpp__
00021 #define __loaded__doc_cpp__
00022 using namespace std;
00023 #line 1 "doc.c++"
00024 #include <map>
00025 #include <iostream>
00026 #include <fstream>
00027 #include <stdlib.h>
00028 #include <assert.h>
00029 #include <stdio.h>
00030 #include <vector>
00031 #include "do-lexer.h"
00032 #include "do-grammar.h"
00033 #include "do-syntax.h"
00034 #include "do-printer.h"
00035 outputbuf object;
00036 outputbuf methods;
00037 outputbuf meta;
00038 outputbuf msgs;
00039 outputbuf msgs1;
00040 outputbuf globhead;
00041 string field2init;
00042 char* current_do=NULL;
00043 char* current_pa=NULL;
00044 char* makers_emitted_for=NULL;
00045 bool access_checks=true;
00046 extern void doset_in(FILE * i);
00047 int doparse();
00048 int main(int argc,char* argv[])
00049 {
00050 assert(argc==3 || argc==4);
00051 char * ifn;
00052 char * ofn;
00053 if (strcmp(argv[1],"--noaccess")==0)
00054 {
00055 access_checks=false;
00056 ifn=argv[2];
00057 ofn=argv[3];
00058 }
00059 else
00060 {
00061 ifn=argv[1];
00062 ofn=argv[2];
00063 }
00064 FILE* f=fopen(ifn,"rb");
00065 assert(f);
00066 doset_in(f);
00067 doparse();
00068 fclose(f);
00069 ofstream out(ofn);
00070 out << "/****\n"
00071 "Data Object compiled file\n"
00072 "Copyright (C) 2006-2010 Werner Van Belle\n"
00073 "Do not change. Changes might be lost\n"
00074 "------------------------------------------\n"
00075 "\n"
00076 "This program is free software; you can redistribute it and/or modify\n"
00077 "it under the terms of the GNU General Public License as published by\n"
00078 "the Free Software Foundation; either version 2 of the License, or\n"
00079 "(at your option) any later version.\n"
00080 "\n"
00081 "This program is distributed in the hope that it will be useful,\n"
00082 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
00083 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
00084 "GNU General Public License for more details.\n"
00085 "\n"
00086 "You should have received a copy of the GNU General Public License\n"
00087 "along with this program; if not, write to the Free Software\n"
00088 "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"
00089 "****/\n\n";
00090
00091 char* s = strdup(ofn);
00092 for(unsigned int j = 0 ; j < strlen(s) ; j++)
00093 {
00094 s[j]=toupper(s[j]);
00095 if (!isalnum(s[j]))
00096 s[j]='_';
00097 }
00098
00099 out << "#ifndef __" << s <<"\n";
00100 out << "#define __" << s <<"\n";
00101 out << "#include <typeinfo>\n";
00102 if (access_checks)
00103 out << "#define DATA_RO_FIELD\n";
00104 out << "#include \"data-reference-count.h\"\n";
00105
00106 for(unsigned i = 0 ; i < globhead.size(); i++)
00107 out << globhead[i];
00108
00109
00110
00111
00112
00113 out << "\n//-------------------------------------"
00114 "\n// Data Meta Definition "
00115 "\n//-------------------------------------\n";
00116 for(unsigned i = 0 ; i < meta.size(); i++)
00117 out << meta[i];
00118 out <<
00119 "\n//-------------------------------------"
00120 "\n// Data Object Definition"
00121 "\n//-------------------------------------\n";
00122 for(unsigned i = 0 ; i < object.size(); i++)
00123 out << object[i];
00124 out << "\n//-------------------------------------"
00125 "\n// Data Methods"
00126 "\n//-------------------------------------\n";
00127 for(unsigned i = 0 ; i < methods.size(); i++)
00128 out << methods[i];
00129 out << "#endif // __" << s <<"\n";
00130 out.close();
00131 exit(0);
00132 }
00133 #endif // __loaded__doc_cpp__