ForthView() { Forth_test_stdwords(false); load_words(&fEnv, &fContext); fBM.setConfig(SkBitmap::kARGB_8888_Config, 640, 480); fBM.allocPixels(); fBM.eraseColor(0); fContext.init(fBM); fEnv.parse(": mycolor ( x. y. -- x. y. ) OVER OVER f< IF #FFFF0000 ELSE #FF0000FF THEN setColor ;"); fEnv.parse(": view.onClick ( x. y. -- ) mycolor 10. drawCircle ;"); fOnClickWord = fEnv.findWord("view.onClick"); #if 0 env.parse( ": draw1 " "10. setStrokeWidth 1 setStyle #FF000000 setColor " "10. 20. 200. 100. drawLine " "0 setStyle #80FF0000 setColor " "50. 50. 250. 150. drawRect " ";"); env.parse("#FF0000FF drawColor " "draw1 " "150. 120. translate " "draw1 " ); #endif }
void Forth_test_stdwords(bool verbose) { ForthEnv env; Reporter reporter; for (size_t i = 0; i < SK_ARRAY_COUNT(gRecs); i++) { ForthEngine engine(NULL); ForthWord* word = env.findWord(gRecs[i].fName); if (NULL == word) { SkString str; str.printf("--- can't find stdword %d", gRecs[i].fName); reporter.reportFailure(str.c_str()); } else { if (verbose) { SkDebugf("--- testing %s %p\n", gRecs[i].fName, word); } gRecs[i].fProc(word, &engine, &reporter); } } if (0 == reporter.fFailureCount) { SkDebugf("--- success!\n"); } else { SkDebugf("--- %d failures\n", reporter.fFailureCount); } }