Symbol* newSymbol(){ symbolCount++; Symbol* symbol = (Symbol*)malloc(sizeof(Symbol)); initSymbol(symbol); addSymbolToTable(symbol); return symbol; }
bool InfoSlide1::init(){ if (!CCLayer::init()) { return false; } size = CCDirector::sharedDirector()->getWinSize(); dScaleX = size.width / 768 , dScaleY = size.height / 1024; count = 0; ccColor3B strokeColor = { 255, 255, 255 }; ccFontDefinition strokeTextDef; strokeTextDef.m_fontSize = 60*dScaleX; strokeTextDef.m_fontName = std::string("Dimbo Regular"); strokeTextDef.m_stroke.m_strokeColor = strokeColor; strokeTextDef.m_stroke.m_strokeEnabled = true; strokeTextDef.m_stroke.m_strokeSize = 1.8; m_lTitleLabel = CCLabelTTF::createWithFontDefinition("3 symbol match", strokeTextDef); m_lTitleLabel->setPosition(ccp(size.width / 2, size.height - 280*dScaleY)); m_lTitleLabel->setScaleX(m_lTitleLabel->getScaleX()*0.9f); m_lTitleLabel->setScaleY(m_lTitleLabel->getScaleY()*1.2f); addChild(m_lTitleLabel); m_lDescriptionLabel = CCLabelTTF::createWithFontDefinition("Make a vertical or horizontal line with 3 \nmatching Sneakers to send them back \nto your closet.", strokeTextDef); m_lDescriptionLabel->setPosition(ccp(size.width / 2, size.height / 2+ 50*dScaleY)); m_lDescriptionLabel->setScaleX(m_lDescriptionLabel->getScaleX()*0.6f); m_lDescriptionLabel->setScaleY(m_lDescriptionLabel->getScaleY()*0.8f); addChild(m_lDescriptionLabel); initSymbol(); return true; }
int msCopySymbol(symbolObj *dst, symbolObj *src, mapObj *map) { int i; initSymbol(dst); MS_COPYSTRING(dst->name, src->name); MS_COPYSTELEM(type); MS_COPYSTELEM(inmapfile); /* map is a special case */ dst->map = map; MS_COPYSTELEM(sizex); MS_COPYSTELEM(sizey); MS_COPYSTELEM(anchorpoint_x); MS_COPYSTELEM(anchorpoint_y); for (i=0; i < src->numpoints; i++) { MS_COPYPOINT(&(dst->points[i]), &(src->points[i])); } MS_COPYSTELEM(numpoints); MS_COPYSTELEM(filled); MS_COPYSTRING(dst->imagepath, src->imagepath); MS_COPYSTELEM(transparent); MS_COPYSTELEM(transparentcolor); MS_COPYSTRING(dst->character, src->character); MS_COPYSTELEM(antialias); MS_COPYSTRING(dst->font, src->font); MS_COPYSTRING(dst->full_pixmap_path,src->full_pixmap_path); return(MS_SUCCESS); }
int main( int argc, char *argv[] ) { FILE *tracef; char type; unsigned int address; if (argc != 2) { printf("Usage: pvtrace <image>\n\n"); exit(-1); } initSymbol( argv[1] ); stackInit(); tracef = fopen("trace.txt", "r"); if (tracef == NULL) { printf("Can't open trace.txt\n"); exit(-1); } while (!feof(tracef)) { fscanf( tracef, "%c0x%x\n", &type, &address ); if (type == 'E') { /* Function Entry */ addSymbol( address ); addCallTrace( address ); stackPush( address ); } else if (type == 'X') { /* Function Exit */ (void) stackPop(); } } emitSymbols(); fclose( tracef ); return 0; }
void FlowPart::setCaption(const QString &caption) { if (m_flowSymbol == FlowPart::ps_other) { m_caption = caption; return; } QWidget *w = new QWidget(); QPainter p(w); p.setFont(font()); const int text_width = p.boundingRect(boundingRect(), (Qt::SingleLine | Qt::AlignHCenter | Qt::AlignVCenter), caption).width(); p.end(); delete w; int width = std::max(((int)(text_width / 16)) * 16, 48); switch (m_flowSymbol) { case FlowPart::ps_call: width += 48; break; case FlowPart::ps_io: case FlowPart::ps_round: width += 32; break; case FlowPart::ps_decision: width += 64; break; case FlowPart::ps_process: default: width += 32; break; } bool hasSideConnectors = m_flowSymbol == FlowPart::ps_decision; if (hasSideConnectors && (width != this->width())) m_pFlowCodeDocument->requestRerouteInvalidatedConnectors(); initSymbol(m_flowSymbol, width); m_caption = caption; }
void InfoSlide1:: step(float dt){ count++; CCLOG("Schdule Schdule"); switch (count) { case 1: selectbox->setVisible(true); break; case 2: selectbox->setVisible(false); break; case 3: symbolA->runAction(CCMoveTo::create(0.2f, symbolB->getPosition())); symbolB->runAction(CCMoveTo::create(0.2f, symbolA->getPosition())); break; case 4: for (int i= 0 ; i< allSymbols->count(); i++) { SyntaxSymbol* temp = (SyntaxSymbol*)allSymbols->objectAtIndex(i); if (temp->isOfType == 3) { temp->runAction(CCSequence::create(CCBlink::create(0.3f, 5) , CCFadeTo::create(0.3f, 0) , NULL)); } } break; case 6: for (int j= 0 ; j< allSymbols->count(); j++) { SyntaxSymbol* temp = (SyntaxSymbol*)allSymbols->objectAtIndex(j); removeChild(temp, true); } allSymbols->removeAllObjects(); count = 0; unschedule(schedule_selector(InfoSlide1::step)); initSymbol(); default: break; } }
/* ** Ensure there is at least one free entry in the symbol array of this ** symbolSetObj. Grow the allocated symbol[] array if necessary and ** allocate a new symbol for symbol[numsymbols] if there is not already one ** and call initSymbol() on it. ** ** This function is safe to use for the initial allocation of the symbol[] ** array as well (i.e. when maxsymbols==0 and symbol==NULL) ** ** Returns a reference to the new symbolObj on success, NULL on error. */ symbolObj *msGrowSymbolSet( symbolSetObj *symbolset ) { /* Do we need to increase the size of symbol[] by MS_SYMBOL_ALLOCSIZE? */ if (symbolset->numsymbols == symbolset->maxsymbols) { int i; if (symbolset->maxsymbols == 0) { /* Initial allocation of array */ symbolset->maxsymbols += MS_SYMBOL_ALLOCSIZE; symbolset->numsymbols = 0; symbolset->symbol = (symbolObj**)malloc(symbolset->maxsymbols*sizeof(symbolObj*)); } else { /* realloc existing array */ symbolset->maxsymbols += MS_SYMBOL_ALLOCSIZE; symbolset->symbol = (symbolObj**)realloc(symbolset->symbol, symbolset->maxsymbols*sizeof(symbolObj*)); } if (symbolset->symbol == NULL) { msSetError(MS_MEMERR, "Failed to allocate memory for symbol array.", "msGrowSymbolSet()"); return NULL; } for(i=symbolset->numsymbols; i<symbolset->maxsymbols; i++) symbolset->symbol[i] = NULL; } if (symbolset->symbol[symbolset->numsymbols]==NULL) { symbolset->symbol[symbolset->numsymbols]=(symbolObj*)malloc(sizeof(symbolObj)); if (symbolset->symbol[symbolset->numsymbols]==NULL) { msSetError(MS_MEMERR, "Failed to allocate memory for a symbolObj", "msGrowSymbolSet()"); return NULL; } } /* Always call initSymbol() even if we didn't allocate a new symbolObj * Since it's possible to dynamically remove/reuse symbols */ initSymbol(symbolset->symbol[symbolset->numsymbols]); return symbolset->symbol[symbolset->numsymbols]; }
int _tmain(int argc, _TCHAR* argv[]) { //_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF); setlocale( LC_ALL, "" ); SetConsoleTitleW(L"Heap Monitor Controller"); initInnerDlls(); std::string imageName = readImgName(argc, argv); getTrackSystem()->SetFocus(imageName.c_str()); if (!g_heapMonitor.Start()) { printf("Start heap monitor failed\n"); return 1; } heapTraceEXE(imageName.c_str()); printf("All ready! Start your application now ...\n\n"); initSymbol(); userCmdLoop(); termSymbol(); heapUntraceEXE(imageName.c_str()); g_heapMonitor.Stop(); TurnOffLogFile(); #if NDEBUG _exit(0); #endif return 0; }
int loadSymbol(symbolObj *s, char *symbolpath) { int done=MS_FALSE; char szPath[MS_MAXPATHLEN]; initSymbol(s); for(;;) { switch(msyylex()) { case(ANCHORPOINT): if(getDouble(&(s->anchorpoint_x)) == -1) return MS_FAILURE; if(getDouble(&(s->anchorpoint_y)) == -1) return MS_FAILURE; if(s->anchorpoint_x<0 || s->anchorpoint_x>1 || s->anchorpoint_y<0 || s->anchorpoint_y>1) { msSetError(MS_SYMERR, "ANCHORPOINT must be between 0 and 1", "loadSymbol()"); return(-1); } break; case(ANTIALIAS): if((s->antialias = getSymbol(2,MS_TRUE,MS_FALSE)) == -1) return(-1); break; case(CHARACTER): if(getString(&s->character) == MS_FAILURE) return(-1); break; case(END): /* do some error checking */ if((s->type == MS_SYMBOL_SVG) && (s->imagepath == NULL)) { msSetError(MS_SYMERR, "Symbol of type SVG has no file path specified.", "loadSymbol()"); return(-1); } if((s->type == MS_SYMBOL_PIXMAP) && (s->full_pixmap_path == NULL)) { msSetError(MS_SYMERR, "Symbol of type PIXMAP has no image data.", "loadSymbol()"); return(-1); } if(((s->type == MS_SYMBOL_ELLIPSE) || (s->type == MS_SYMBOL_VECTOR)) && (s->numpoints == 0)) { msSetError(MS_SYMERR, "Symbol of type VECTOR or ELLIPSE has no point data.", "loadSymbol()"); return(-1); } if(s->type == MS_SYMBOL_VECTOR) { double minx = s->points[0].x; double miny = s->points[0].y; /* should only negative points be shifted? (#4116)*/ int shiftpositive = ((s->anchorpoint_x!=0.5)||(s->anchorpoint_y!=0.5)); int i; for(i=1; i<s->numpoints; i++) { if(s->points[i].x != -99 && s->points[i].y != -99) { if(s->points[i].x<minx) minx = s->points[i].x; if(s->points[i].y<miny) miny = s->points[i].y; } } if(minx<0 || miny<0 || (shiftpositive && (minx!=0 || miny!=0))) { for(i=0; i<s->numpoints; i++) { if(s->points[i].x != -99 && s->points[i].y != -99) { s->points[i].x -= minx; s->points[i].y -= miny; } } s->sizex -= minx; s->sizey -= miny; } } return(0); break; case(EOF): msSetError(MS_EOFERR, NULL, "loadSymbol()"); return(-1); break; case(FILLED): if((s->filled = getSymbol(2,MS_TRUE,MS_FALSE)) == -1) return(-1); break; case(FONT): if(getString(&s->font) == MS_FAILURE) return(-1); break; case(IMAGE): if(msyylex() != MS_STRING) { /* get image location from next token */ msSetError(MS_TYPEERR, "Parsing error near (%s):(line %d)", "loadSymbol()", msyystring_buffer, msyylineno); return(-1); } s->full_pixmap_path = msStrdup(msBuildPath(szPath, symbolpath, msyystring_buffer)); /* Set imagepath */ s->imagepath = msStrdup(msyystring_buffer); break; case(NAME): if(getString(&s->name) == MS_FAILURE) return(-1); break; case(POINTS): done = MS_FALSE; s->sizex = 0; s->sizey = 0; for(;;) { switch(msyylex()) { case(END): done = MS_TRUE; break; case(MS_NUMBER): s->points[s->numpoints].x = atof(msyystring_buffer); /* grab the x */ if(getDouble(&(s->points[s->numpoints].y)) == -1) return(-1); /* grab the y */ if(s->points[s->numpoints].x!=-99) { s->sizex = MS_MAX(s->sizex, s->points[s->numpoints].x); s->sizey = MS_MAX(s->sizey, s->points[s->numpoints].y); } s->numpoints++; break; default: msSetError(MS_TYPEERR, "Parsing error near (%s):(line %d)", "loadSymbol()", msyystring_buffer, msyylineno); return(-1); } if(done == MS_TRUE) break; } break; case(TRANSPARENT): s->transparent = MS_TRUE; if(getInteger(&(s->transparentcolor)) == -1) return(-1); break; case(TYPE): if((s->type = getSymbol(8,MS_SYMBOL_VECTOR,MS_SYMBOL_ELLIPSE,MS_SYMBOL_PIXMAP,MS_SYMBOL_SIMPLE,MS_TRUETYPE,MS_SYMBOL_HATCH,MS_SYMBOL_SVG)) == -1) return(-1); if(s->type == MS_TRUETYPE) /* TrueType keyword is valid several place in map files and symbol files, this simplifies the lexer */ s->type = MS_SYMBOL_TRUETYPE; break; default: msSetError(MS_IDENTERR, "Parsing error near (%s):(line %d)", "loadSymbol()", msyystring_buffer, msyylineno); return(-1); } /* end switch */ } /* end for */ }