// TestPCHClang_NoRebuild //------------------------------------------------------------------------------ void TestPrecompiledHeaders::TestPCHClang_NoRebuild() const { FBuildOptions options; options.m_ConfigFile = "Data/TestPrecompiledHeaders/fbuild.bff"; options.m_ShowSummary = true; // required to generate stats for node count checks AStackString<> obj( "../../../../ftmp/Test/PrecompiledHeaders/Clang/PCHUser.obj" ); AStackString<> pch( "../../../../ftmp/Test/PrecompiledHeaders/Clang/PrecompiledHeader.pch" ); FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( GetPCHDBClangFileName() ) ); AStackString<> target( "PCHTestClang" ); TEST_ASSERT( fBuild.Build( target ) ); TEST_ASSERT( fBuild.SaveDependencyGraph( GetPCHDBClangFileName() ) ); // Check stats // Seen, Built, Type CheckStatsNode ( 2, 2, Node::FILE_NODE ); // cpp + pch CheckStatsNode ( 1, 0, Node::COMPILER_NODE ); CheckStatsNode ( 2, 0, Node::OBJECT_NODE );// obj + pch obj CheckStatsNode ( 1, 0, Node::OBJECT_LIST_NODE ); CheckStatsTotal( 6, 2 ); }
// TestPCHClangWithCache //------------------------------------------------------------------------------ void TestPrecompiledHeaders::TestPCHClangWithCache() const { FBuildOptions options; options.m_ConfigFile = "Data/TestPrecompiledHeaders/fbuild.bff"; options.m_ForceCleanBuild = true; options.m_UseCacheRead = true; options.m_ShowSummary = true; // required to generate stats for node count checks AStackString<> obj( "../../../../ftmp/Test/PrecompiledHeaders/Clang/PCHUser.obj" ); AStackString<> pch( "../../../../ftmp/Test/PrecompiledHeaders/Clang/PrecompiledHeader.pch" ); EnsureFileDoesNotExist( obj ); EnsureFileDoesNotExist( pch ); FBuild fBuild( options ); TEST_ASSERT( fBuild.Initialize( nullptr ) ); AStackString<> target( "PCHTestClang" ); TEST_ASSERT( fBuild.Build( target ) ); TEST_ASSERT( fBuild.SaveDependencyGraph( GetPCHDBClangFileName() ) ); EnsureFileExists( obj ); EnsureFileExists( pch ); // Check stats // Seen, Built, Type CheckStatsNode ( 2, 2, Node::FILE_NODE ); // cpp + pch CheckStatsNode ( 1, 1, Node::COMPILER_NODE ); CheckStatsNode ( 2, 0, Node::OBJECT_NODE );// obj + pch obj CheckStatsNode ( 1, 1, Node::OBJECT_LIST_NODE ); CheckStatsTotal( 6, 4 ); // check we got both objects from the cache TEST_ASSERT( fBuild.GetStats().GetStatsFor( Node::OBJECT_NODE ).m_NumCacheHits == 2 ); // pch & the obj using it }
void qore_program_private::exportGlobalVariable(const char* vname, bool readonly, qore_program_private& tpgm, ExceptionSink* xsink) { if (&tpgm == this) { xsink->raiseException("PROGRAM-IMPORTGLOBALVARIABLE-EXCEPTION", "cannot import global variable \"%s\" with the same source and target Program objects", vname); return; } const qore_ns_private* vns = 0; Var* v; { ProgramRuntimeParseAccessHelper pah(xsink, pgm); if (*xsink) return; v = qore_root_ns_private::runtimeFindGlobalVar(*RootNS, vname, vns); } if (!v) { xsink->raiseException("PROGRAM-IMPORTGLOBALVARIABLE-EXCEPTION", "there is no global variable \"%s\"", vname); return; } // get exclusive access to program object for parsing ProgramRuntimeParseContextHelper pch(xsink, tpgm.pgm); if (*xsink) return; // find/create target namespace based on source namespace QoreNamespace* tns = vns->root ? tpgm.RootNS : qore_root_ns_private::runtimeFindCreateNamespacePath(*tpgm.RootNS, *vns); //printd(5, "qore_program_private::exportGlobalVariable() this: %p vname: '%s' ro: %d vns: %p '%s::' RootNS: %p '%s::'\n", this, vname, readonly, vns, vns->name.c_str(), RootNS, RootNS->getName()); qore_root_ns_private::runtimeImportGlobalVariable(*tpgm.RootNS, *tns, v, readonly, xsink); }
main() { char po[333] = "POST / HTTP/1.0\n\nasdfsadfasdfasdf"; char tmp[243]; printf("%d\n" , pch(po )); }
int select_file(char *prompt, char *fname) { int ret; static char p[256] = ""; filebox.h = screen_h - 10; filebox.height = screen_h - 14; filebox.w = MAX(screen_w - 16, 32); filebox.slen = filebox.w - 8; draw_box(prompt, 7, 2, filebox.w, 5, TRUE); draw_listbox(&filebox); hi_vid(); goto1(7,6); pch(LJOIN_CHAR); goto1(filebox.w+6,6); pch(RJOIN_CHAR); if (!fname[0]) { if (p[0]) strcpy(fname, p); else getcwd(fname, 256); cleanup_filename(fname); append_backslash(fname); } fill_filelist(fname); goto1(12, 4); ret = do_input_text(fname, 255, 54, is_filechar, fsel_proc, TRUE, fsel_mouse); if (ret != ESC) { strcpy(p, fname); *get_fname(p) = 0; } n_vid(); empty_filelist(); dirty_everything(); return ret; }
void draw_askbox(LISTBOX *l) { draw_box(l->title, l->x, l->y, l->w, l->h, TRUE); draw_contents(l); hi_vid(); goto1(l->x+4, l->y+2); mywrite((char *)l->parent); pch('?'); n_vid(); }
void dumpTag(int ttype, int tlength, void *tvalue) { infotag tag; assert(sizeof(tag) == 2); assert(info); tag.type = ttype; tag.length = tlength; fwrite(&tag, sizeof(tag), 1, info); if(tlength) { assert(tvalue); fwrite(tvalue, tlength, 1, info); } if(txt) { switch(ttype) { case INFO_END: fputs("End ", txt); break; case INFO_EXTRA_SPACE: fputs("Extra space ", txt); break; case INFO_POS_HEAPLEN: fputs("Heaplen position", txt); break; case INFO_ALIASES: fputs("Alias size ", txt); break; case INFO_HISTORY: fputs("History size ", txt); break; case INFO_DIRSTACK: fputs("Dirstack size ", txt); break; case INFO_BUFSIZE: fputs("Bufsize ", txt); break; default: fputs("Unknown tag ", txt); break; } fprintf(txt, ": %u", tlength); switch(tlength) { case 0: break; case 1: { unsigned char ch; ch = *(unsigned char*)tvalue; fprintf(txt, ": %u 0x%02x (%c)", ch, ch, pch(ch)); } break; case 2: { unsigned w; w = *(unsigned*)tvalue; fprintf(txt, ": %5u 0x%04x", w, w); } break; case 4: { unsigned long l; l = *(unsigned long*)tvalue; fprintf(txt, ": %lu 0x%08lx", l, l); } break; default: break; } putc('\n', txt); } }
void qore_program_private::importClass(ExceptionSink* xsink, qore_program_private& from_pgm, const char* path, const char* new_name, bool inject) { if (&from_pgm == this) { xsink->raiseException("CLASS-IMPORT-ERROR", "cannot import class \"%s\" with the same source and target Program objects", path); return; } if (inject && !(pwo.parse_options & PO_ALLOW_INJECTION)) { xsink->raiseException("CLASS-IMPORT-ERROR", "cannot import class \"%s\" with the injection flag set in a Program object without PO_ALLOW_INJECTION set", path); return; } const qore_ns_private* vns = 0; const QoreClass* c; { // acquire safe access to parse structures in the source program ProgramRuntimeParseAccessHelper rah(xsink, from_pgm.pgm); if (*xsink) return; c = qore_root_ns_private::runtimeFindClass(*from_pgm.RootNS, path, vns); } if (!c) { xsink->raiseException("CLASS-IMPORT-ERROR", "can't find class \"%s\" in source Program", path); return; } // get exclusive access to program object for parsing ProgramRuntimeParseContextHelper pch(xsink, pgm); if (*xsink) return; // find/create target namespace based on source namespace QoreNamespace* tns; if (new_name && strstr(new_name, "::")) { NamedScope nscope(new_name); tns = qore_root_ns_private::runtimeFindCreateNamespacePath(*RootNS, nscope, qore_class_private::isPublic(*c)); qore_root_ns_private::runtimeImportClass(*RootNS, xsink, *tns, c, from_pgm.pgm, nscope.getIdentifier(), inject); } else { tns = vns->root ? RootNS : qore_root_ns_private::runtimeFindCreateNamespacePath(*RootNS, *vns); //printd(5, "qore_program_private::importClass() this: %p path: %s nspath: %s tns: %p %s RootNS: %p %s\n", this, path, nspath.c_str(), tns, tns->getName(), RootNS, RootNS->getName()); qore_root_ns_private::runtimeImportClass(*RootNS, xsink, *tns, c, from_pgm.pgm, new_name, inject); } }
void qore_program_private::importFunction(ExceptionSink* xsink, QoreFunction* u, const qore_ns_private& oldns, const char* new_name, bool inject) { // get exclusive access to program object for parsing ProgramRuntimeParseContextHelper pch(xsink, pgm); if (*xsink) return; if (new_name && strstr(new_name, "::")) { NamedScope nscope(new_name); QoreNamespace* tns = qore_root_ns_private::runtimeFindCreateNamespacePath(*RootNS, nscope, u->hasPublic()); qore_root_ns_private::runtimeImportFunction(*RootNS, xsink, *tns, u, nscope.getIdentifier()); return; } // find/create target namespace based on source namespace QoreNamespace* tns = oldns.root ? RootNS : qore_root_ns_private::runtimeFindCreateNamespacePath(*RootNS, oldns); //printd(5, "qore_program_private::importFunction() this: %p tns: %p '%s' oldns: '%s' RootNS: %p %s\n", this, tns, tns->getName(), oldns.name.c_str(), RootNS, RootNS->getName()); assert(oldns.name == tns->getName()); qore_root_ns_private::runtimeImportFunction(*RootNS, xsink, *tns, u, new_name, inject); }
// TestPCH //------------------------------------------------------------------------------ void TestPrecompiledHeaders::TestPCH() const { FBuildOptions options; options.m_ForceCleanBuild = true; options.m_UseCacheWrite = true; options.m_ShowSummary = true; // required to generate stats for node count checks #if defined( __WINDOWS__ ) AStackString<> obj( "../../../../ftmp/Test/PrecompiledHeaders/PCHUser.obj" ); #else AStackString<> obj( "../../../../ftmp/Test/PrecompiledHeaders/PCHUser.o" ); #endif AStackString<> pch( "../../../../ftmp/Test/PrecompiledHeaders/PrecompiledHeader.pch" ); AStackString<> lib( "../../../../ftmp/Test/PrecompiledHeaders/TestPCH.lib" ); EnsureFileDoesNotExist( obj ); EnsureFileDoesNotExist( pch ); EnsureFileDoesNotExist( lib ); FBuildStats stats = Build( options, false ); // don't use DB EnsureFileExists( obj ); EnsureFileExists( pch ); EnsureFileExists( lib ); // Check stats // Seen, Built, Type CheckStatsNode ( stats, 3, 2, Node::FILE_NODE ); // cpp + pch CheckStatsNode ( stats, 1, 1, Node::COMPILER_NODE ); CheckStatsNode ( stats, 2, 2, Node::OBJECT_NODE );// obj + pch obj CheckStatsNode ( stats, 1, 1, Node::LIBRARY_NODE ); CheckStatsNode ( stats, 1, 1, Node::DIRECTORY_LIST_NODE ); CheckStatsNode ( stats, 1, 1, Node::ALIAS_NODE ); CheckStatsNode ( stats, 1, 1, Node::DLL_NODE ); CheckStatsTotal( stats, 10, 9 ); // check we wrote all objects to the cache TEST_ASSERT( stats.GetStatsFor( Node::OBJECT_NODE ).m_NumCacheStores == 1 ); // only the main obj can be cached }
void QoreProgram::parseCommit(ExceptionSink* xsink, ExceptionSink* wS, int wm) { ProgramRuntimeParseCommitContextHelper pch(xsink, this); if (*xsink) return; priv->parseCommit(xsink, wS, wm); }
int do_input_text(char *buf, int size, int width, int (*valid)(char), int (*proc)(int, char *, int *, int *), int mouse_flag, int (*mouse_proc)(int x, int y, char *buf, int *oldlen)) { KEYPRESS k; int key; int askey; int ret; int x, y, len, cpos; int oldlen, c; int gap; int sel = TRUE; x = x_pos; y = y_pos; len = oldlen = cpos = strlen(buf); n_vid(); do { goto1(x, y); if ((width > 0) && (len > width)) { gap = len - width; pch('.'); pch('.'); pch('.'); pch(' '); mywrite(buf+gap+4); } else { gap = 0; mywrite(buf); } hi_vid(); for (c=len-gap; c < ((width > 0) ? width : oldlen); c++) pch(' '); oldlen = len; if (cpos-gap > 0) goto2(x+cpos-gap, y); else goto2(x, y); show_c(); if (mouse_flag) { display_mouse(); while (m_b) poll_mouse(); while (TRUE) { if (input_waiting()) { k = input_char(); key = k.key; if ((ascii(key) == CR) && (k.flags & KF_CTRL)) key = LF; if (key) break; } poll_mouse(); if ((m_b) && (mouse_proc)) { hide_c(); key = (*mouse_proc)(x, y, buf, &oldlen); len = cpos = strlen(buf); sel = FALSE; show_c(); if (key > 0) break; } } hide_mouse(); } else { while (m_b) poll_mouse(); while ((!input_waiting()) && (!m_b)) poll_mouse(); if (m_b) { if (m_b & 2) key = ESC; else key = CR; } else { k = input_char(); key = k.key; if ((ascii(key) == CR) && (k.flags & KF_CTRL)) key = LF; } } if ((!proc) || (!(*proc)(key, buf, &len, &cpos))) { if ((key==CTRL_G) || (key==CTRL_C)) askey=ESC; else askey=ascii((char)key); if ((askey==ESC) || (askey==CR) || (askey==LF)) { ret = askey; break; } if (key==LEFT_ARROW) { if (cpos > 0) cpos--; } else if (key==RIGHT_ARROW) { if (cpos < len) cpos++; } else if (key==K_HOME) { cpos = 0; } else if (key==K_END) { cpos = MAX(len, 0); } else { if ((sel) && ((key==K_DELETE) || (askey==BACKSPACE) || ((*valid)(askey)))) { len = cpos = 0; buf[0] = 0; } if (key==K_DELETE) { if (cpos < len) { for (c=cpos; c<len; c++) buf[c] = buf[c+1]; len--; } } else if (askey==BACKSPACE) { if (cpos > 0) { cpos--; for (c=cpos; c<len; c++) buf[c] = buf[c+1]; len--; } } else { if ((len<size) && ((*valid)(askey))) { len++; for (c=len; c>cpos; c--) buf[c] = buf[c-1]; buf[cpos++]=askey; } } } if (proc) (*proc)(-1, buf, &len, &cpos); } sel = FALSE; } while (TRUE); n_vid(); return ret; }
int fsel_mouse(int x, int y, char *s, int *len) { int c, gap; int selitem; int first = TRUE; int changed; int d; #ifdef TARGET_CURSES int count = 0; #endif if ((m_x < filebox.x) || (m_x >= filebox.x + filebox.w) || (m_y < filebox.y) || (m_y >= filebox.y + filebox.h) || (m_b & 2)) return ESC; if (filebox.count <= 0) return 0; do { delay(10); selitem = -1; changed = d = FALSE; if (mouse_inside_list(&filebox)) { filebox.current = get_mouse_item(&filebox); if (filebox.current >= filebox.count) filebox.current = filebox.count - 1; else selitem = filebox.current; changed = TRUE; } else { if ((m_y < filebox.y + filebox.yoff) && (filebox.scroll > 0)) { filebox.scroll--; filebox.current = filebox.scroll; changed = d = TRUE; } else if ((m_y >= filebox.y + filebox.yoff + filebox.height) && (filebox.scroll < filebox.count - filebox.height)) { filebox.scroll++; filebox.current = filebox.scroll + filebox.height - 1; if (filebox.current >= filebox.count) filebox.current = filebox.count-1; changed = d = TRUE; } } if (changed) { hide_mouse(); draw_contents(&filebox); strcpy(s, filebox.data[filebox.current].text); goto1(x, y); hi_vid(); if (strlen(s) > 54) { gap = strlen(s) - 54; pch('.'); pch('.'); pch('.'); pch(' '); mywrite(s+gap+4); } else { gap = 0; mywrite(s); } for (c=strlen(s)-gap; c<54; c++) pch(' '); goto2(x+strlen(s+gap), y); *len = strlen(s); display_mouse(); } if (d) delay(20); if ((first) && (selitem >= 0)) if (!mouse_dclick(FALSE)) if (mouse_dclick(TRUE)) return CR; first = FALSE; refresh_screen(); #ifdef TARGET_CURSES if (d) { if (count++ >= 10) m_b = 0; } else while (m_b) #endif poll_mouse(); } while(m_b); clear_keybuf(); return 0; }
void draw_contents(LISTBOX *l) { int x, y; int c, c2; int len; char *p; hi_vid(); if (l->flags & LISTBOX_SCROLL) { goto1(l->x+l->xoff+3, l->y+1); for (c=0; c<4; c++) { if (l->scroll > 0) pch(UP_CHAR); else pch(' '); pch(' '); pch(' '); } goto1(l->x+l->xoff+3, l->y+l->h-2); for (c=0; c<4; c++) { if (l->scroll + l->width*l->height < l->count) pch(DOWN_CHAR); else pch(' '); pch(' '); pch(' '); } } for (y=0; y<l->height; y++) { for (x=0; x<l->width; x++) { goto1(l->x+l->xoff+(l->slen+2)*x, l->y+l->yoff+y); c = l->scroll + y*l->width + x; if (c==l->current) n_vid(); pch(' '); if (c < l->count) { if (l->data[c].draw_proc) { (*l->data[c].draw_proc)(l->slen+1, l, l->data+c); } else { p = l->data[c].text; len = l->slen; if (strlen(p) > len) { pch('.'); pch('.'); pch('.'); pch(' '); len -= 4; p += (strlen(p) - len); } for (c2=0; p[c2]; c2++) pch(p[c2]); while (c2++ <= len) pch(' '); } } else for (c2=0; c2<l->slen+1; c2++) pch(' '); if (c==l->current) { if ((config.comments) && (l->data[c].comment)) { strcpy(message, l->data[c].comment); display_message(0); hide_c(); } hi_vid(); } } } n_vid(); }
void draw_box(char *title, int _x, int _y, int _w, int _h, int shadow) { int x, y; hi_vid(); goto1(_x, _y); pch(TL_CHAR); pch(TOP_CHAR); x=2; if (title) { mywrite(title); x += strlen(title); } while (x<_w-1) { pch(TOP_CHAR); x++; } pch(TR_CHAR); for (y=1; y<_h-1; y++) { goto1(_x, _y+y); pch(SIDE_CHAR); for (x=1; x<_w-1; x++) pch(' '); pch(SIDE_CHAR); } goto1(_x, _y+_h-1); pch(BL_CHAR); for (x=1; x<_w-1; x++) pch(BOTTOM_CHAR); pch(BR_CHAR); if (shadow) { tattr(((config.hi_col >> 4) == 8) ? 0 : 128); for (y=1; y<_h; y++) { goto1(_x+_w, _y+y); pch(' '); } goto1(_x+1, _y+_h); for (x=0; x<_w; x++) pch(' '); } n_vid(); }