Example #1
0
IntegerSyntax::IntegerSyntax()
{
    SYNTAX("int");

    sign_ = DEFINE("Sign", RANGE("+-"));

    binNumber_ =
        DEFINE("BinNumber",
            GLUE(
                STRING("0b"),
                REPEAT(1, 256, RANGE('0', '1'))
            )
        );

    octNumber_ =
        DEFINE("OctNumber",
            GLUE(
                CHAR('0'),
                REPEAT(1, 24, RANGE('0', '9'))
            )
        );

    hexNumber_ =
        DEFINE("HexNumber",
            GLUE(
                STRING("0x"),
                REPEAT(1, 20,
                    CHOICE(
                        RANGE('0', '9'),
                        RANGE('a', 'f'),
                        RANGE('A', 'F')
                    )
                )
            )
        );

    decNumber_ =
        DEFINE("DecNumber",
            REPEAT(1, 20,
                RANGE('0', '9')
            )
        );

    literal_ =
        DEFINE("Literal",
            GLUE(
                REPEAT(0, 1, REF("Sign")),
                CHOICE(
                    REF("BinNumber"),
                    REF("OctNumber"),
                    REF("HexNumber"),
                    REF("DecNumber")
                ),
                NOT(RANGE(".eE"))
            )
        );

    ENTRY("Literal");
    LINK();
}
Example #2
0
int main()
{
   uint64_t beg, end;
   uint64_t sum[REPNUM];
   double ref = 0;
   double res = timing_res();
#define PARAASSIGN double arg1=double_rand();
#define PARALIST arg1
   REPEAT(sqrt);
   REPEAT(fabs);
   REPEAT(log);
#undef PARAASSIGN
#undef PARALIST
   return 0;
}
Example #3
0
ModelWorld* CreateModelWorld()
{
    ModelWorld* world = new ModelWorld;
    memset(world, 0, sizeof(ModelWorld));
    InitReferenceCounter(&world->refCounter);
    REPEAT(MAX_MODELS, i)
        world->drawEntries[i].generatedVariableSet = CreateShaderVariableSet();
    return world;
}
Example #4
0
EscapeSequenceSyntax::EscapeSequenceSyntax()
{
	number_ = DEFINE("number", REPEAT(1, 4, RANGE('0', '9')));
	title_ = DEFINE("title", REPEAT(1, RANGE(32, 255)));
	
	controlSequence_ =
		DEFINE("controlSequence",
			GLUE(
				CHAR(27),
				CHOICE(
					GLUE(
						// csi sequences
						CHAR('['),
						REPEAT(0, 1, RANGE("?>")),
						REPEAT(0, 15,
							GLUE(
								REF("number"),
								REPEAT(0, 1, CHAR(';'))
							)
						),
						RANGE(32, 255)
					),
					GLUE(
						// osc sequences
						CHAR(']'),
						REF("number"),
						CHAR(';'),
						REF("title"),
						CHAR(7)
					),
					GLUE(
						// two or three byte escape sequences
						REPEAT(0, 1,
							// character set selection, etc.
							RANGE("()%")
						),
						// other
						RANGE(33, 127)
					)
				)
			)
		);
	
	ENTRY("controlSequence");
	LINK();
}
Example #5
0
void drawLine(cv::Mat & image, const cv::Point & lastCentre, const cv::Point & pointOnBranch, const cv::Scalar & colToUse, int nThickness)
{
    const C2dImagePointPx p1=lastCentre;
    const C2dImagePointPx p2=pointOnBranch;
    double dDistLineToOrigin = -1;
    if(p1 != p2) {
        const C2dBoundedLine lineBounded(p1, p2);
        dDistLineToOrigin = lineBounded.closestDistance(C2dImagePointPx::Zero());
    }

    const double dMaxSize=image.rows+image.cols;
    if(fabs(dDistLineToOrigin) > dMaxSize || p1.norm() > 10*dMaxSize || p2.norm() > 10*dMaxSize) {
        return; //Line doesn't pass near origin
    }

    if(nThickness > 255) {
        REPEAT(10, cout << "Warning, line too thick: " << nThickness << " pixels. Object too close to camera. Resetting to 3" << endl);
        nThickness = 3;
    } else if (nThickness<1)
        nThickness = 1;

    cv::line(image, lastCentre, pointOnBranch, colToUse, nThickness);
}
Example #6
0
/**
 * Prepares the log file for writting
 */
void DSEventLogger::init()
{
    if (!m_init) {
        /* Initialize the timer */
        m_init = true;
        m_timer.restart();

        /* Get app info */
        QString appN = qApp->applicationName();
        QString appV = qApp->applicationVersion();
        QString ldsV = DriverStation::libDSVersion();
        QString time = GET_DATE_TIME ("MMM dd yyyy - HH:mm:ss AP");

        /* Get dump directoru */
        QString path = QString ("%1/%2/%3/%4/")
                       .arg (logsPath())
                       .arg (GET_DATE_TIME ("yyyy"))
                       .arg (GET_DATE_TIME ("MMMM"))
                       .arg (GET_DATE_TIME ("ddd dd"));

        /* Create logs directory (if necessesary) */
        QDir dir (path);
        if (!dir.exists())
            dir.mkpath (".");

        /* Get dump file path */
        m_currentLog = QString ("%1/%2.log")
                       .arg (path)
                       .arg (GET_DATE_TIME ("HH_mm_ss AP"));

        /* Open dump file */
        m_dump = fopen (m_currentLog.toStdString().c_str(), "w");
        m_dump = !m_dump ? stderr : m_dump;

        /* Get OS information */
        QString sysV;
#if QT_VERSION >= QT_VERSION_CHECK (5, 4, 0)
        sysV = QSysInfo::prettyProductName();
#else
#if defined Q_OS_WIN
        sysV = "Windows";
#elif defined Q_OS_MAC
        sysV = "Mac OSX";
#elif defined Q_OS_LINUX
        sysV = "GNU/Linux";
#else
        sysV = "Unknown";
#endif
#endif

        /* Format app info */
        time.prepend ("Log created on:      ");
        ldsV.prepend ("LibDS version:       ");
        sysV.prepend ("Operating System:    ");
        appN.prepend ("Application name:    ");
        appV.prepend ("Application version: ");

        /* Append app info */
        fprintf (m_dump, "%s\n",   PRINT (time));
        fprintf (m_dump, "%s\n",   PRINT (ldsV));
        fprintf (m_dump, "%s\n",   PRINT (sysV));
        fprintf (m_dump, "%s\n",   PRINT (appN));
        fprintf (m_dump, "%s\n\n", PRINT (appV));

        /* Start the table header */
        fprintf (m_dump, "%s\n", PRINT (REPEAT ("-", 72)));
        fprintf (m_dump, PRINT_FMT, "ELAPSED TIME", "ERROR LEVEL", "MESSAGE");
        fprintf (m_dump, "%s\n", PRINT (REPEAT ("-", 72)));
    }
}
Example #7
0
#include "config.h"
#include "stm_include/stm32/flash.h"

#ifdef TRACE_FLASH
	#include "usart.h"
#endif
#include "debug.h"

#define REPEAT(value,length) { [0 ... (length - 1)] = value }

/*
 * Configuration values in RAM for access by other modules.
 */

config_entry_t config = {
	.white_correction = REPEAT(0xffff, MODULE_LENGTH),
	.my_address = 0x00fd,
	.heat_limit = REPEAT(0xffff, HEAT_SENSOR_LEN),
	.physical_led = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15},
	.led_color = REPEAT(WHITE, MODULE_LENGTH)
};

/*
 * The configuration page. This is laid out in the following way:
 * There is a number of configuration slots, used one after the other
 * for storing a configuration. The state of each slot is kept in
 * entry_status, where 0xffff (the flash default value) stands for a free
 * slot, 0x5555 for the slot currently in use and 0x0000 for an old slot.
 * When all slots are used, the config page is erased and the process
 * starts again.
 *
Example #8
0
/* 1 byte bitmap decompress */
static RD_BOOL
bitmap_decompress1(uint8 * output, int width, int height, uint8 * input, int size)
{
	uint8 *end = input + size;
	uint8 *prevline = NULL, *line = NULL;
	int opcode, count, offset, isfillormix, x = width;
	int lastopcode = -1, insertmix = False, bicolour = False;
	uint8 code;
	uint8 colour1 = 0, colour2 = 0;
	uint8 mixmask, mask = 0;
	uint8 mix = 0xff;
	int fom_mask = 0;

	while (input < end)
	{
		fom_mask = 0;
		code = CVAL(input);
		opcode = code >> 4;
		/* Handle different opcode forms */
		switch (opcode)
		{
			case 0xc:
			case 0xd:
			case 0xe:
				opcode -= 6;
				count = code & 0xf;
				offset = 16;
				break;
			case 0xf:
				opcode = code & 0xf;
				if (opcode < 9)
				{
					count = CVAL(input);
					count |= CVAL(input) << 8;
				}
				else
				{
					count = (opcode < 0xb) ? 8 : 1;
				}
				offset = 0;
				break;
			default:
				opcode >>= 1;
				count = code & 0x1f;
				offset = 32;
				break;
		}
		/* Handle strange cases for counts */
		if (offset != 0)
		{
			isfillormix = ((opcode == 2) || (opcode == 7));
			if (count == 0)
			{
				if (isfillormix)
					count = CVAL(input) + 1;
				else
					count = CVAL(input) + offset;
			}
			else if (isfillormix)
			{
				count <<= 3;
			}
		}
		/* Read preliminary data */
		switch (opcode)
		{
			case 0:	/* Fill */
				if ((lastopcode == opcode) && !((x == width) && (prevline == NULL)))
					insertmix = True;
				break;
			case 8:	/* Bicolour */
				colour1 = CVAL(input);
			case 3:	/* Colour */
				colour2 = CVAL(input);
				break;
			case 6:	/* SetMix/Mix */
			case 7:	/* SetMix/FillOrMix */
				mix = CVAL(input);
				opcode -= 5;
				break;
			case 9:	/* FillOrMix_1 */
				mask = 0x03;
				opcode = 0x02;
				fom_mask = 3;
				break;
			case 0x0a:	/* FillOrMix_2 */
				mask = 0x05;
				opcode = 0x02;
				fom_mask = 5;
				break;
		}
		lastopcode = opcode;
		mixmask = 0;
		/* Output body */
		while (count > 0)
		{
			if (x >= width)
			{
				if (height <= 0)
					return False;
				x = 0;
				height--;
				prevline = line;
				line = output + height * width;
			}
			switch (opcode)
			{
				case 0:	/* Fill */
					if (insertmix)
					{
						if (prevline == NULL)
							line[x] = mix;
						else
							line[x] = prevline[x] ^ mix;
						insertmix = False;
						count--;
						x++;
					}
					if (prevline == NULL)
					{
						REPEAT(line[x] = 0)
					}
					else
					{
						REPEAT(line[x] = prevline[x])
					}
					break;
				case 1:	/* Mix */
					if (prevline == NULL)
					{
						REPEAT(line[x] = mix)
					}
					else
					{
						REPEAT(line[x] = prevline[x] ^ mix)
					}
					break;
				case 2:	/* Fill or Mix */
					if (prevline == NULL)
					{
						REPEAT
						(
							MASK_UPDATE();
							if (mask & mixmask)
								line[x] = mix;
							else
								line[x] = 0;
						)
					}
					else
					{
						REPEAT
						(
							MASK_UPDATE();
							if (mask & mixmask)
								line[x] = prevline[x] ^ mix;
							else
								line[x] = prevline[x];
						)
					}
					break;
				case 3:	/* Colour */
					REPEAT(line[x] = colour2)
					break;
				case 4:	/* Copy */
					REPEAT(line[x] = CVAL(input))
					break;
				case 8:	/* Bicolour */
					REPEAT
					(
						if (bicolour)
						{
							line[x] = colour2;
							bicolour = False;
						}
						else
						{
							line[x] = colour1;
							bicolour = True; count++;
						}
					)
					break;
				case 0xd:	/* White */
					REPEAT(line[x] = 0xff)
					break;
				case 0xe:	/* Black */
					REPEAT(line[x] = 0)
					break;
				default:
					unimpl("bitmap opcode 0x%x\n", opcode);
					return False;
			}
Example #9
0
WireSyntax::WireSyntax()
{
    SYNTAX("Wire");

    DEFINE_VOID("Comment",
                CHOICE(
                    GLUE(
                        STRING("//"),
                        CHOICE(
                            FIND(AHEAD(CHAR('\n'))),
                            FIND(EOI())
                        )
                    ),
                    GLUE(
                        STRING("/*"),
                        REPEAT(
                            CHOICE(
                                INLINE("Comment"),
                                GLUE(
                                    NOT(STRING("*/")),
                                    ANY()
                                )
                            )
                        ),
                        STRING("*/")
                    )
                )
               );

    DEFINE_VOID("Whitespace",
                REPEAT(
                    CHOICE(
                        RANGE(" \t\n"),
                        INLINE("Comment")
                    )
                )
               );

    DEFINE("Name",
           REPEAT(1, EXCEPT(" \t\n:;"))
          );

    DEFINE("Value",
           CHOICE(
               REF("Atom"),
               REF("Properties"),
               REF("Items")
           )
          );

    DEFINE("Object",
           GLUE(
               REPEAT(0, 1,
                      GLUE(
                          REF("Name"),
                          INLINE("Whitespace"),
                          CHAR(':'),
                          INLINE("Whitespace")
                      )
                     ),
               INLINE("Value")
           )
          );

    DEFINE("Atom",
           REPEAT(
               GLUE(
                   NOT(
                       CHOICE(
                           GLUE(
                               REPEAT(RANGE(" \t")),
                               INLINE("Name"),
                               REPEAT(RANGE(" \t")),
                               CHAR(':')
                           ),
                           GLUE(
                               REPEAT(RANGE(" \t")),
                               RANGE("};,")
                           ),
                           STRING("\n\n")
                       )
                   ),
                   ANY()
               )
           )
          );

    DEFINE("Properties",
           GLUE(
               CHAR('{'),
               INLINE("Whitespace"),
               REPEAT(
                   GLUE(
                       REF("Object"),
                       INLINE("Whitespace"),
                       RANGE(";,"),
                       INLINE("Whitespace")
                   )
               ),
               CHAR('}')
           )
          );

    DEFINE("Items",
           GLUE(
               CHAR('['),
               INLINE("Whitespace"),
               REPEAT(
                   GLUE(
                       REF("Value"),
                       INLINE("Whitespace"),
                       RANGE(";,"),
                       INLINE("Whitespace")
                   )
               ),
               CHAR(']')
           )
          );

    ENTRY("Object");
}
Example #10
0
/* returns boolean */
static int APP_CC
bitmap_decompress1(char* output, int width, int height, char* input, int size)
{
  char* prevline;
  char* line;
  char* end;
  char color1;
  char color2;
  char mix;
  int code;
  int mixmask;
  int mask;
  int opcode;
  int count;
  int offset;
  int isfillormix;
  int x;
  int lastopcode;
  int insertmix;
  int bicolor;
  int fom_mask;

  end = input + size;
  prevline = 0;
  line = 0;
  x = width;
  lastopcode = -1;
  insertmix = 0;
  bicolor = 0;
  color1 = 0;
  color2 = 0;
  mix = 0xff;
  mask = 0;
  fom_mask = 0;

  while (input < end)
  {
    fom_mask = 0;
    code = CVAL(input);
    opcode = code >> 4;
    /* Handle different opcode forms */
    switch (opcode)
    {
      case 0xc:
      case 0xd:
      case 0xe:
        opcode -= 6;
        count = code & 0xf;
        offset = 16;
        break;
      case 0xf:
        opcode = code & 0xf;
        if (opcode < 9)
        {
          count = CVAL(input);
          count |= CVAL(input) << 8;
        }
        else
        {
          count = (opcode < 0xb) ? 8 : 1;
        }
        offset = 0;
        break;
      default:
        opcode >>= 1;
        count = code & 0x1f;
        offset = 32;
        break;
    }
    /* Handle strange cases for counts */
    if (offset != 0)
    {
      isfillormix = ((opcode == 2) || (opcode == 7));
      if (count == 0)
      {
        if (isfillormix)
        {
          count = CVAL(input) + 1;
        }
        else
        {
          count = CVAL(input) + offset;
        }
      }
      else if (isfillormix)
      {
        count <<= 3;
      }
    }
    /* Read preliminary data */
    switch (opcode)
    {
      case 0: /* Fill */
        if ((lastopcode == opcode) && !((x == width) && (prevline == 0)))
        {
          insertmix = 1;
        }
        break;
      case 8: /* Bicolor */
        color1 = CVAL(input);
      case 3: /* Color */
        color2 = CVAL(input);
        break;
      case 6: /* SetMix/Mix */
      case 7: /* SetMix/FillOrMix */
        mix = CVAL(input);
        opcode -= 5;
        break;
      case 9: /* FillOrMix_1 */
        mask = 0x03;
        opcode = 0x02;
        fom_mask = 3;
        break;
      case 0x0a: /* FillOrMix_2 */
        mask = 0x05;
        opcode = 0x02;
        fom_mask = 5;
        break;
    }
    lastopcode = opcode;
    mixmask = 0;
    /* Output body */
    while (count > 0)
    {
      if (x >= width)
      {
        if (height <= 0)
        {
          return 0;
        }
        x = 0;
        height--;
        prevline = line;
        line = output + height * width;
      }
      switch (opcode)
      {
        case 0: /* Fill */
          if (insertmix)
          {
            if (prevline == 0)
            {
              line[x] = mix;
            }
            else
            {
              line[x] = prevline[x] ^ mix;
            }
            insertmix = 0;
            count--;
            x++;
          }
          if (prevline == 0)
          {
            REPEAT(line[x] = 0)
          }
          else
          {
            REPEAT(line[x] = prevline[x])
          }
          break;
        case 1: /* Mix */
          if (prevline == 0)
          {
            REPEAT(line[x] = mix)
          }
          else
          {
            REPEAT(line[x] = prevline[x] ^ mix)
          }
          break;
        case 2: /* Fill or Mix */
          if (prevline == 0)
          {
            REPEAT
            (
              MASK_UPDATE;
              if (mask & mixmask)
              {
                line[x] = mix;
              }
              else
              {
                line[x] = 0;
              }
            )
          }
          else
          {
            REPEAT
            (
              MASK_UPDATE;
              if (mask & mixmask)
              {
                line[x] = prevline[x] ^ mix;
              }
              else
              {
                line[x] = prevline[x];
              }
            )
          }
          break;
        case 3: /* Color */
          REPEAT(line[x] = color2)
          break;
        case 4: /* Copy */
          REPEAT(line[x] = CVAL(input))
          break;
        case 8: /* Bicolor */
          REPEAT
          (
            if (bicolor)
            {
              line[x] = color2;
              bicolor = 0;
            }
            else
            {
              line[x] = color1;
              bicolor = 1;
              count++;
            }
          )
          break;
        case 0xd: /* White */
          REPEAT(line[x] = 0xff)
          break;
        case 0xe: /* Black */
          REPEAT(line[x] = 0)
          break;
        default:
          return 0;
          break;
      }
Example #11
0
char *
simple_date_format(const char *format, const struct timeval *tv)
{
  const char *p;
  char *q;
  struct xobs pool;
  char span[2] = { 0, };
  int repeat;
  struct tm tmbuf;

  localtime_r(&tv->tv_sec, &tmbuf);

  xobs_init(&pool);

  for (p = format; *p != '\0'; p++) {
    switch (*p) {
    case 'G':
      REPEAT(p, span, repeat);
      if (tmbuf.tm_year + 1900 < 0) { /* not possible */
        xobs_1grow(&pool, 'B');
        xobs_1grow(&pool, 'C');
      }
      else {
        xobs_1grow(&pool, 'A');
        xobs_1grow(&pool, 'D');
      }
      break;

    case 'y':
      REPEAT(p, span, repeat);
      if (repeat == 2)
        xobs_sprintf(&pool, "%d", tmbuf.tm_year % 100);
      else
        xobs_sprintf(&pool, "%d", tmbuf.tm_year + 1900);
      break;

    case 'M':                   /* month */
      REPEAT(p, span, repeat);
      if (repeat >= 3)
        xobs_sprintf(&pool, "%*s", repeat, months[tmbuf.tm_mon % 12]);
      else
        xobs_sprintf(&pool, "%*d", repeat, tmbuf.tm_mon % 12);
      break;

    case 'w':                   /* week in year */
      REPEAT(p, span, repeat);
      // not implemented yet.
      break;

    case 'W':                   /* week in month */
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%*d", repeat, tmbuf.tm_mday / 7 + 1);
      break;

    case 'D':                   /* day of year */
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%*d", repeat, tmbuf.tm_yday);
      break;

    case 'd':                   /* day in month */
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%*d", repeat, tmbuf.tm_mday);
      break;

    case 'F':                   /* day of week in month */
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%*d", repeat, tmbuf.tm_wday);
      break;

    case 'E':                   /* day in week */
      REPEAT(p, span, repeat);
      if (repeat > 3)
        xobs_sprintf(&pool, "%*s", repeat, weekday[tmbuf.tm_wday % 7]);
      else
        xobs_sprintf(&pool, "%*s", repeat, short_weekday[tmbuf.tm_wday % 7]);
      break;

    case 'a':
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%*s", repeat,
                   (tmbuf.tm_hour >= 12) ? "PM" : "AM");
      break;

    case 'H':
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%0*d", repeat, tmbuf.tm_hour);
      break;

    case 'k':
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%0*d", repeat, tmbuf.tm_hour + 1);
      break;

    case 'K':
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%0*d", repeat, tmbuf.tm_hour % 12);
      break;
    case 'h':
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%0*d", repeat, tmbuf.tm_hour % 12 + 1);
      break;
    case 'm':
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%0*d", repeat, tmbuf.tm_min);
      break;
    case 's':
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%0*d", repeat, tmbuf.tm_sec);
      break;
    case 'S':                   /* millisecond */
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%0*d", repeat, tv->tv_usec / 1000);
      break;
    case 'z':
      REPEAT(p, span, repeat);
      if (tmbuf.tm_zone)
        xobs_sprintf(&pool, "%*s", repeat, tmbuf.tm_zone);
      else {
        xobs_sprintf(&pool, "%c%02d:%02d",
                     (tmbuf.tm_gmtoff < 0) ? '-' : '+',
                     tmbuf.tm_gmtoff % (60 * 60),
                     tmbuf.tm_gmtoff % 60);
      }
      break;
    case 'Z':
      REPEAT(p, span, repeat);
      xobs_sprintf(&pool, "%c%02d%02d",
                   (tmbuf.tm_gmtoff < 0) ? '-' : '+',
                   tmbuf.tm_gmtoff % (60 * 60),
                   tmbuf.tm_gmtoff % 60);
      break;
    case '\'':
      q = strchr(p + 1, '\'');
      if (!q)
        goto err;
      if (q == p + 1)
        xobs_1grow(&pool, '\'');
      else {
        for (p = p + 1; p < q; p++)
          xobs_1grow(&pool, *p);
      }
      p = q;
      break;
    default:
      xobs_1grow(&pool, *p);
      break;
    }
  }

  xobs_1grow(&pool, '\0');
  q = strdup(xobs_finish(&pool));
  xobs_free(&pool, NULL);
  return q;

 err:
  xobs_free(&pool, NULL);
  return NULL;
}
HaxeMessageSyntax::HaxeMessageSyntax()
{
	DEFINE_VOID("SpaceChar", RANGE(" \n\r\t"));
	DEFINE_VOID("Whitespace", REPEAT(INLINE("SpaceChar")));
	
	specialChar_ =
		DEFINE("SpecialChar",
			GLUE(
				CHAR('&'),
				KEYWORD("gt lt"),
				CHAR(';')
			)
		);
	gt_ = keywordByName("gt");
	lt_ = keywordByName("lt");
	
	value_ =
		DEFINE("Value",
			REPEAT(1,
				CHOICE(
					REF("SpecialChar"),
					GLUE(
						NOT(
							GLUE(
								INLINE("Whitespace"),
								CHAR('<')
							)
						),
						ANY()
					)
				)
			)
		);
	
	typeTip_ =
		DEFINE("TypeTip",
			GLUE(
				STRING("<type>"),
				INLINE("Whitespace"),
				REF("Value"),
				INLINE("Whitespace"),
				STRING("</type>")
			)
		);
	
	memberName_ = DEFINE("MemberName", REPEAT(1, OTHER('\"')));
	memberType_ = DEFINE("MemberType", REPEAT(0, 1, INLINE("Value")));
	memberDescription_ = DEFINE("MemberDescription", REPEAT(0, 1, INLINE("Value")));
	
	member_ =
		DEFINE("Member",
			GLUE(
				STRING("<i n=\""),
				REF("MemberName"),
				STRING("\"><t>"),
				REF("MemberType"),
				STRING("</t><d>"),
				REF("MemberDescription"),
				STRING("</d></i>")
			)
		);
	
	membersTip_ =
		DEFINE("MembersTip",
			GLUE(
				STRING("<list>"),
				REPEAT(1,
					GLUE(
						INLINE("Whitespace"),
						REF("Member")
					)
				),
				INLINE("Whitespace"),
				STRING("</list>")
			)
		);
	
	haxeTip_ =
		DEFINE("HaxeTip",
			FIND(
				GLUE(
					INLINE("Whitespace"),
					CHOICE(
						REF("TypeTip"),
						REF("MembersTip")
					),
					INLINE("Whitespace")
				)
			)
		);
	
	ENTRY("HaxeTip");
}
Example #13
0
#define SQUARE 1

const struct logoInstructionDef instructions[] = {
	
	SET_ALT(100)
	
	// Go Home and point North
	HOME
	
	REPEAT_FOREVER
		DO_ARG(SQUARE, 100)
	END
	
	
	TO (SQUARE)
		REPEAT(4)
			FD_PARAM
			RT(90)
		END
	END
} ;


////////////////////////////////////////////////////////////////////////////////
// RTL Flight Plan
// 
// On entering RTL mode, turn off the engine, fly home, and circle indefinitely until touching down

const struct logoInstructionDef rtlInstructions[] = {
	
	// Use cross-tracking for navigation
Example #14
0
BOOL
bitmap_decompress(unsigned char *output, int width, int height, unsigned char *input, int size,
		  int Bpp)
{
	unsigned char *end = input + size;
	unsigned char *prevline = NULL, *line = NULL;
	int opcode, count, offset, isfillormix, x = width;
	int lastopcode = -1, insertmix = False, bicolour = False;
	uint8 code;
	uint32 colour1 = 0, colour2 = 0;
	uint8 mixmask, mask = 0;
	uint32 mix = 0xffffffff;
	int fom_mask = 0;

	while (input < end)
	{
		fom_mask = 0;
		code = CVAL(input);
		opcode = code >> 4;

		/* Handle different opcode forms */
		switch (opcode)
		{
			case 0xc:
			case 0xd:
			case 0xe:
				opcode -= 6;
				count = code & 0xf;
				offset = 16;
				break;

			case 0xf:
				opcode = code & 0xf;
				if (opcode < 9)
				{
					count = CVAL(input);
					count |= CVAL(input) << 8;
				}
				else
				{
					count = (opcode < 0xb) ? 8 : 1;
				}
				offset = 0;
				break;

			default:
				opcode >>= 1;
				count = code & 0x1f;
				offset = 32;
				break;
		}

		/* Handle strange cases for counts */
		if (offset != 0)
		{
			isfillormix = ((opcode == 2) || (opcode == 7));

			if (count == 0)
			{
				if (isfillormix)
					count = CVAL(input) + 1;
				else
					count = CVAL(input) + offset;
			}
			else if (isfillormix)
			{
				count <<= 3;
			}
		}

		/* Read preliminary data */
		switch (opcode)
		{
			case 0:	/* Fill */
				if ((lastopcode == opcode) && !((x == width) && (prevline == NULL)))
					insertmix = True;
				break;
			case 8:	/* Bicolour */
				colour1 = cvalx(&input, Bpp);
			case 3:	/* Colour */
				colour2 = cvalx(&input, Bpp);
				break;
			case 6:	/* SetMix/Mix */
			case 7:	/* SetMix/FillOrMix */
				mix = cvalx(&input, Bpp);
				opcode -= 5;
				break;
			case 9:	/* FillOrMix_1 */
				mask = 0x03;
				opcode = 0x02;
				fom_mask = 3;
				break;
			case 0x0a:	/* FillOrMix_2 */
				mask = 0x05;
				opcode = 0x02;
				fom_mask = 5;
				break;

		}

		lastopcode = opcode;
		mixmask = 0;

		/* Output body */
		while (count > 0)
		{
			if (x >= width)
			{
				if (height <= 0)
					return False;

				x = 0;
				height--;

				prevline = line;
				line = output + height * width * Bpp;
			}

			switch (opcode)
			{
				case 0:	/* Fill */
					if (insertmix)
					{
						if (prevline == NULL)
							setli(line, x, mix, Bpp);
						else
							setli(line, x,
							      getli(prevline, x, Bpp) ^ mix, Bpp);

						insertmix = False;
						count--;
						x++;
					}

					if (prevline == NULL)
					{
					REPEAT(setli(line, x, 0, Bpp))}
					else
					{
						REPEAT(setli
						       (line, x, getli(prevline, x, Bpp), Bpp));
					}
					break;

				case 1:	/* Mix */
					if (prevline == NULL)
					{
						REPEAT(setli(line, x, mix, Bpp));
					}
					else
					{
						REPEAT(setli
						       (line, x, getli(prevline, x, Bpp) ^ mix,
							Bpp));
					}
					break;

				case 2:	/* Fill or Mix */
					if (prevline == NULL)
					{
						REPEAT(MASK_UPDATE();
						       if (mask & mixmask) setli(line, x, mix, Bpp);
						       else
						       setli(line, x, 0, Bpp););
					}
					else
					{
						REPEAT(MASK_UPDATE();
						       if (mask & mixmask)
						       setli(line, x, getli(prevline, x, Bpp) ^ mix,
							     Bpp);
						       else
						       setli(line, x, getli(prevline, x, Bpp),
							     Bpp););
					}