Closed markusvoelter closed 11 years ago
But the header file contains a "#include" not followed by the name of the file to include?
According to http://gcc.gnu.org/onlinedocs/cpp/Include-Syntax.html it is an error
EDIT: I mean, did you copy the original stdio.h or the result of the import?
CStubFile.parseHeaderFiles invokes parser.parseHFile inside a read action. parseHFile among the other things try to add new roots to a model causing the exception signaled by Markus.
I tried substituting it with a command or a write action but it does not work. I really wonder what an undoable command is.
Substituting the readAction with a "execute command in EDT" it imports the file BUT trigger an MPS error… (ui shown to the user) OR it freezes the IDE (it depends on the mood of MPS…)
Now... I would like to understand why it complains about nodes being added to a root... I do that in my branch and it works... I will try to see if I found the reason for that
I confirm that in the branch cimporter I use the "model.add root" statement inside a command and it works, the same approach does not work in the stub importer from the core...
I wonder if it is caused by the add of the ProgressMonitor because it maybe launch a second thread where the task is executed. I would try to remove it but the language com.mbeddr.core.cstubs does not compile for me because of erros in ImportHeaderResultDialog
Ok, it seems to work now for me. Modifications:
If it is ok for you to give up the monitor for now I could implement this in the core. Of course I am not 100% confident there will be not side effects...
Please implement this for the master branch if that is ok for you. We can add the monitor back later.
Implemented and pushed.
Please note that the importer now is executed, the dialog showed and the file added but importing stdio.h it has some problems with finding headers (<sys/cdefs.h> and others). I did not intended that as part of the issue, just the fact the imported could not run at all. So if you consider the issue still open let me know and I will try to look at it.
I am trying to import a header file. I have copied stdlib.h into a separate dir which I then import. Nothing is actually imported, I get the errors below:
Error: Include not found: #include in /Users/markusvoelter/Documents/mbeddr/mbeddr.core/code/applications/tutorial/headers/stdlib.h
Error: Include not found: #include <_types.h> in /Users/markusvoelter/Documents/mbeddr/mbeddr.core/code/applications/tutorial/headers/stdlib.h
Error: Include not found: #include <sys/wait.h> in /Users/markusvoelter/Documents/mbeddr/mbeddr.core/code/applications/tutorial/headers/stdlib.h
Error: Include not found: #include in /Users/markusvoelter/Documents/mbeddr/mbeddr.core/code/applications/tutorial/headers/stdlib.h
Error: Include not found: #include <machine/types.h> in /Users/markusvoelter/Documents/mbeddr/mbeddr.core/code/applications/tutorial/headers/stdlib.h
Info: start parsing: /Users/markusvoelter/Documents/mbeddr/mbeddr.core/code/applications/tutorial/headers/stdlib.h into model: stdlib
/Users/markusvoelter/Documents/mbeddr/mbeddr.core/code/applications/tutorial/headers/stdlib.h: /*
ifndef _STDLIBH
define _STDLIBH
include
include <_types.h>
if !defined(_ANSI_SOURCE)
include <sys/wait.h>
if (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
include
endif /* (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
endif /* !_ANSI_SOURCE */
ifndef _SIZE_T
define _SIZE_T
/* DO NOT REMOVE THIS COMMENT: fixincludes needs to see:
endif
if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
ifndef _CT_RUNE_T
define _CT_RUNE_T
typedef __darwin_ct_rune_t ct_rune_t;
endif
ifndef _RUNE_T
define _RUNE_T
typedef __darwin_rune_t rune_t;
endif
endif /* !_ANSI_SOURCE && (!_POSIX_C_SOURCE || _DARWIN_C_SOURCE) */
ifndef __cplusplus
ifndef _WCHAR_T
define _WCHAR_T
typedef __darwin_wchar_t wchar_t;
endif /* _WCHAR_T */
endif /* __cplusplus */
typedef struct { int quot; /* quotient / int rem; / remainder */ } div_t;
typedef struct { long quot; /* quotient / long rem; / remainder */ } ldiv_t;
if !__DARWIN_NO_LONG_LONG
typedef struct { long long quot; long long rem; } lldiv_t;
endif /* !__DARWIN_NO_LONG_LONG */
ifndef NULL
define NULL __DARWIN_NULL
endif /* ! NULL */
define EXIT_FAILURE 1
define EXIT_SUCCESS 0
define RAND_MAX 0x7fffffff
ifdef _USE_EXTENDEDLOCALES
include <_xlocale.h>
endif /* _USE_EXTENDEDLOCALES */
ifndef MB_CUR_MAX
ifdef _USE_EXTENDEDLOCALES
define MB_CUR_MAX (___mb_cur_max())
ifndef MB_CUR_MAX_L
define MB_CUR_MAX_L(x) (___mb_cur_max_l(x))
endif /* !MB_CUR_MAX_L */
else /* !_USE_EXTENDEDLOCALES */
extern int __mb_cur_max;
define MB_CUR_MAX __mb_cur_max
endif /* _USE_EXTENDEDLOCALES */
endif /* MB_CUR_MAX */
if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE)) \
define MB_CUR_MAX_L(x) (___mb_cur_max_l(x))
endif
__BEGIN_DECLS void abort(void) dead2; int abs(int) pure2; int atexit(void ()(void)); double atof(const char ); int atoi(const char ); long atol(const char );
if !__DARWIN_NO_LONG_LONG
long long atoll(const char *);
endif /* !__DARWIN_NO_LONG_LONG */
void _bsearch(const void , const void , size_t, sizet, int ()(const void , const void )); void calloc(size_t, size_t); div_t div(int, int) pure2; void exit(int) dead2; void free(void ); char getenv(const char ); long labs(long) __pure2; ldiv_t ldiv(long, long) __pure2;
if !__DARWIN_NO_LONG_LONG
long long llabs(long long); lldiv_t lldiv(long long, long long);
endif /* !__DARWIN_NO_LONG_LONG */
void _malloc(size_t); int mblen(const char , size_t); size_t mbstowcs(wchar_t * restrict , const char * restrict, size_t); int mbtowc(wchar_t * restrict, const char * restrict, size_t); int posix_memalign(void _, size_t, size_t) OSX_AVAILABLE_STARTING(MAC_10_6, IPHONE_30); void qsort(void , size_t, sizet, int ()(const void _, const void )); int rand(void); void realloc(void , size_t); void srand(unsigned); double strtod(const char , char _) __DARWINALIAS(strtod); float strtof(const char , char _) DARWINALIAS(strtof); long strtol(const char , char , int); long double strtold(const char , char _);
if !__DARWIN_NO_LONG_LONG
long long strtoll(const char , char *, int);
endif /* !__DARWIN_NO_LONG_LONG */
unsigned long strtoul(const char , char *, int);
if !__DARWIN_NO_LONG_LONG
unsigned long long strtoull(const char , char *, int);
endif /* !__DARWIN_NO_LONG_LONG */
int system(const char ) DARWIN_ALIAS_C(system); size_t wcstombs(char * __restrict, const wchar_t * restrict, size_t); int wctomb(char , wchar_t);
ifndef _ANSI_SOURCE
void _Exit(int) _dead2; long a64l(const char ); double drand48(void); char ecvt(double, int, int restrict, int *restrict); / LEGACY / double erand48(unsigned short[3]); char fcvt(double, int, int restrict, int *restrict); / LEGACY / char gcvt(double, int, char ); / LEGACY / int getsubopt(char , char * const , char _); int grantpt(int);
if __DARWIN_UNIX03
char _initstate(unsigned, char , sizet); / no __DARWIN_ALIAS needed /
else /* !__DARWIN_UNIX03 */
char initstate(unsigned long, char , long);
endif /* __DARWIN_UNIX03 */
long jrand48(unsigned short[3]); char l64a(long); void lcong48(unsigned short[7]); long lrand48(void); char mktemp(char ); int mkstemp(char ); long mrand48(void); long nrand48(unsigned short[3]); int posix_openpt(int); char ptsname(int); int putenv(char ) __DARWIN_ALIAS(putenv); long random(void); int rand_r(unsigned *);
if (__DARWIN_UNIX03 && !defined(_POSIX_C_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(_DARWIN_BETTER_REALPATH)
char realpath(const char * __restrict, char \ restrict) DARWIN_EXTSN(realpath);
else /* (!__DARWIN_UNIX03 || _POSIX_C_SOURCE) && !_DARWIN_C_SOURCE && !_DARWIN_BETTER_REALPATH */
char realpath(const char * __restrict, char \ restrict) DARWIN_ALIAS(realpath);
endif /* (__DARWIN_UNIX03 && _POSIX_C_SOURCE) || _DARWIN_C_SOURCE || _DARWIN_BETTER_REALPATH */
unsigned short seed48(unsigned short[3]); int setenv(const char , const char *, int) __DARWIN_ALIAS(setenv);
if __DARWIN_UNIX03
void setkey(const char *) __DARWIN_ALIAS(setkey);
else /* !__DARWIN_UNIX03 */
int setkey(const char *);
endif /* __DARWIN_UNIX03 */
char setstate(const char ); void srand48(long);
if __DARWIN_UNIX03
void srandom(unsigned);
else /* !__DARWIN_UNIX03 */
void srandom(unsigned long);
endif /* __DARWIN_UNIX03 */
int unlockpt(int);
if __DARWIN_UNIX03
int unsetenv(const char *) __DARWIN_ALIAS(unsetenv);
else /* !__DARWIN_UNIX03 */
void unsetenv(const char *);
endif /* __DARWIN_UNIX03 */
endif /* !_ANSI_SOURCE */
if !defined(_ANSI_SOURCE) && (!defined(_POSIX_C_SOURCE) || defined(_DARWIN_C_SOURCE))
include <machine/types.h>
ifndef _DEV_T
typedef __darwin_dev_t dev_t;
define _DEV_T
endif
ifndef _MODE_T
typedef __darwin_mode_t mode_t;
define _MODE_T
endif
u_int32_t arc4random(void); void arc4random_addrandom(unsigned char * /dat/, int /datlen/); void arc4random_buf(void * /buf/, size_t /nbytes/) OSX_AVAILABLE_STARTING(MAC_10_7, __IPHONE_4_3); void arc4random_stir(void); u_int32_t arc4random_uniform(u_int32_t /_upperbound/) OSX_AVAILABLE_STARTING(MAC_10_7, __IPHONE_4_3);
ifdef BLOCKS
int atexit_b(void (^)(void)) OSX_AVAILABLE_STARTING(MAC_10_6, __IPHONE_3_2); void bsearch_b(const void , const void , size_t, size_t, int (^)(const void , const void *)) OSX_AVAILABLE_STARTING(MAC_10_6, __IPHONE_3_2);
endif /* BLOCKS */
char cgetcap(char , const char , int); int cgetclose(void); int cgetent(char *, char _, const char ); int cgetfirst(char _, char ); int cgetmatch(const char , const char ); int cgetnext(char *, char _); int cgetnum(char , const char , long ); int cgetset(const char ); int cgetstr(char , const char , char ); int cgetustr(char , const char , char _);
int daemon(int, int) DARWIN_1050(daemon) __OSX_AVAILABLE_BUT_DEPRECATED(MAC_10_0, MAC_10_5, IPHONE_2_0, __IPHONE_2_0); char devname(dev_t, mode_t); char devname_r(dev_t, mode_t, char buf, int len); char getbsize(int , long ); int getloadavg(double [], int); const char *getprogname(void);
int heapsort(void _, size_t, sizet, int ()(const void , const void ));
ifdef BLOCKS
int heapsort_b(void , size_t, size_t, int (^)(const void , const void *)) OSX_AVAILABLE_STARTING(MAC_10_6, __IPHONE_3_2);
endif /* BLOCKS */
int mergesort(void _, size_t, sizet, int ()(const void , const void ));
ifdef BLOCKS
int mergesort_b(void , size_t, size_t, int (^)(const void , const void *)) OSX_AVAILABLE_STARTING(MAC_10_6, __IPHONE_3_2);
endif /* BLOCKS */
void psort(void _, size_t, sizet, int ()(const void , const void )) OSX_AVAILABLE_STARTING(MAC_10_6, __IPHONE_3_2);
ifdef BLOCKS
void psort_b(void , size_t, size_t, int (^)(const void , const void *)) OSX_AVAILABLE_STARTING(MAC_10_6, __IPHONE_3_2);
endif /* BLOCKS */
void psortr(void , size_t, sizet, void *, int ()(void , const void , const void *)) OSX_AVAILABLE_STARTING(MAC_10_6, __IPHONE_3_2);
ifdef BLOCKS
void qsort_b(void , size_t, size_t, int (^)(const void , const void *)) OSX_AVAILABLE_STARTING(MAC_10_6, __IPHONE_3_2);
endif /* BLOCKS */
void qsortr(void , size_t, sizet, void *, int ()(void , const void , const void )); int radixsort(const unsigned char *, int, const unsigned char , unsigned); void setprogname(const char ); int sradixsort(const unsigned char , int, const unsigned char , unsigned); void sranddev(void); void srandomdev(void); void reallocf(void *, size_t);
if !__DARWIN_NO_LONG_LONG
long long strtoq(const char , char *, int); unsigned long long strtouq(const char , char *, int);
endif /* !__DARWIN_NO_LONG_LONG */
extern char suboptarg; / getsubopt(3) external variable / void valloc(size_t);
endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
/* Poison the following routines if -fshort-wchar is set */
if !defined(cplusplus) && defined(__WCHAR_MAX) && WCHAR_MAX <= 0xffffU
pragma GCC poison mbstowcs mbtowc wcstombs wctomb
endif
__END_DECLS
ifdef _USE_EXTENDEDLOCALES
include <xlocale/_stdlib.h>
endif /* _USE_EXTENDEDLOCALES */
endif /* _STDLIBH */
void dummyMacroFunction(){ int define0 = ; int define1 = ; int define2 = ; int define3 = ; int define4 = ; int define5 = __DARWIN_NULL; int define6 = 1; int define7 = 0; int define8 = 0x7fffffff; int define9 = __mb_cur_max; int define10 = ; int define11 = ; };
[5100988] ERROR - plication.impl.ApplicationImpl - node registration is only allowed inside undoable command or in 'loading' model ImplementationModule "dummystdlib"[null] in 1351848020558@$orphan-stuff$ jetbrains.mps.smodel.IllegalModelChangeError: node registration is only allowed inside undoable command or in 'loading' model ImplementationModule "dummystdlib"[null] in 1351848020558@$orphan-stuff$ at jetbrains.mps.smodel.ModelChange.assertLegalNodeRegistration(ModelChange.java:28) at jetbrains.mps.smodel.SModel.addRoot(SModel.java:156) at jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations.addRootNode(SModelOperations.java:159) at com.mbeddr.core.modules.runtime.include.CFileParser.replaceDefines(CFileParser.java:537) at com.mbeddr.core.modules.runtime.include.CFileParser.parseHFile(CFileParser.java:501) at com.mbeddr.core.modules.runtime.include.CStubUtil$2.run(CStubUtil.java:44) at jetbrains.mps.ide.smodel.WorkbenchModelAccess$2.run(WorkbenchModelAccess.java:118) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:860) at jetbrains.mps.ide.smodel.WorkbenchModelAccess.runReadAction(WorkbenchModelAccess.java:114) at com.mbeddr.core.modules.runtime.include.CStubUtil.parseHeaderFiles(CStubUtil.java:42) at com.mbeddr.core.cstubs.editor.HeaderImportSpecHFile_Editor$7.run(HeaderImportSpecHFile_Editor.java:535) at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:469) at com.intellij.openapi.progress.impl.ProgressManagerImpl$6.run(ProgressManagerImpl.java:288) at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:218) at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:169) at com.intellij.openapi.application.impl.ApplicationImpl$8$1.run(ApplicationImpl.java:641) at com.intellij.openapi.application.impl.ApplicationImpl$6.run(ApplicationImpl.java:434) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:145) [5100989] ERROR - plication.impl.ApplicationImpl - JetBrains MPS 2.5 Build #MPS-117.9351 [5100989] ERROR - plication.impl.ApplicationImpl - JDK: 1.6.0_35 [5100989] ERROR - plication.impl.ApplicationImpl - VM: Java HotSpot(TM) 64-Bit Server VM [5100989] ERROR - plication.impl.ApplicationImpl - Vendor: Apple Inc. [5100989] ERROR - plication.impl.ApplicationImpl - OS: Mac OS X