• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ARRAY_LENGTH函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ARRAY_LENGTH函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRAY_LENGTH函数的具体用法?C++ ARRAY_LENGTH怎么用?C++ ARRAY_LENGTH使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ARRAY_LENGTH函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: output_file

static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file)
{
	const char *comment_start, *comment_end, *comment_inline, *token_chars;
	const char *comment_start_esc, *comment_end_esc, *comment_inline_esc;
	const token_entry *token_table;
	const astring *srcfile_subpath;
	char srcline[4096], *srcptr;
	int in_comment = FALSE;
	UINT8 is_token[256];
	int color_quotes;
	core_file *src;
	core_file *dst;
	int toknum;
	int linenum = 1;

	/* extract a normalized subpath */
	srcfile_subpath = normalized_subpath(srcfile, srcrootlen + 1);
	if (srcfile_subpath == NULL)
		return 1;

	fprintf(stderr, "Processing %s\n", astring_c(srcfile_subpath));

	/* set some defaults */
	color_quotes = FALSE;
	comment_start = comment_start_esc = "";
	comment_end = comment_end_esc = "";
	comment_inline = comment_inline_esc = "";
	token_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#";
	token_table = dummy_token_table;

	/* based on the file type, set the comment info */
	switch (type)
	{
		case FILE_TYPE_C:
			color_quotes = TRUE;
			comment_start = comment_start_esc = "/*";
            comment_end = comment_end_esc = "*/";
			comment_inline = comment_inline_esc = "//";
			token_table = c_token_table;
			break;

		case FILE_TYPE_MAKE:
			color_quotes = TRUE;
			comment_inline = comment_inline_esc = "#";
			break;

		case FILE_TYPE_XML:
			color_quotes = TRUE;
			comment_start = "<!--";
			comment_start_esc = "&lt;!--";
			comment_end = "-->";
			comment_end_esc = "--&gt;";
			break;

		default:
		case FILE_TYPE_TEXT:
			break;
	}

	/* make the token lookup table */
	memset(is_token, 0, sizeof(is_token));
	for (toknum = 0; token_chars[toknum] != 0; toknum++)
		is_token[(UINT8)token_chars[toknum]] = TRUE;

	/* open the source file */
	if (core_fopen(astring_c(srcfile), OPEN_FLAG_READ, &src) != FILERR_NONE)
	{
		fprintf(stderr, "Unable to read file '%s'\n", astring_c(srcfile));
		return 1;
	}

	/* open the output file */
	dst = create_file_and_output_header(dstfile, "MAME Source Code", astring_c(srcfile_subpath));
	if (dst == NULL)
	{
		fprintf(stderr, "Unable to write file '%s'\n", astring_c(dstfile));
		core_fclose(src);
		return 1;
	}

	/* output the directory navigation */
	core_fprintf(dst, "<h3>Viewing File: ");
	output_path_as_links(dst, srcfile_subpath, FALSE, link_to_file);
	core_fprintf(dst, "</h3>");
	astring_free((astring *)srcfile_subpath);

	/* start with some tags */
	core_fprintf(dst, "\t<pre style=\"font-family:'Courier New','Courier',monospace; font-size:12px;\">\n");

	/* iterate over lines in the source file */
	while (core_fgets(srcline, ARRAY_LENGTH(srcline), src) != NULL)
	{
		char dstline[4096], *dstptr = dstline;
		int in_inline_comment = FALSE;
		int last_token_was_include = FALSE;
		int last_was_token = FALSE;
		int quotes_are_linked = FALSE;
		char in_quotes = 0;
		int curcol = 0;

//.........这里部分代码省略.........
开发者ID:cdenix,项目名称:ps3-mame-0125,代码行数:101,代码来源:src2html.c


示例2: main


//.........这里部分代码省略.........
                    fprintf (stderr,
                             "Can't manage screen backlight on this system.\nPlease disable backlight with config option 'workmode='1' or command line switch '-w 1'.\nIf you believe this is an error, open a bug report: https://github.com/poliva/lightum/issues\n");
                    exit (1);
                } else {
                    dbus_backend = 2;
                }
            } else {
                dbus_backend = 1;
            }

        } else {
            dbus_backend = 0;
        }
    }

    if (conf.idleoff != 0 || conf.screenidle != 0) {
        display = XOpenDisplay (NULL);
        if (display == NULL) {
            fprintf (stderr, "Failed to open display\n");
            exit (1);
        }
    }

    signal_installer ();

    if (!conf.ignoresession) {
        connection = get_dbus_connection ();
        proxy_manager = get_dbus_proxy_manager (connection);
        proxy_session = get_dbus_proxy_session (connection, proxy_manager);
    }
    // initialize the light values array
    if (!conf.manualmode) {
        light = get_light_sensor_value ();
        for (i = 0; i < ARRAY_LENGTH (lightvalues); i++)
            lightvalues[i] = light;
        countarray[light] = ARRAY_LENGTH (lightvalues);
    } else {
        for (i = 0; i < ARRAY_LENGTH (lightvalues); i++)
            lightvalues[i] = 0;
    }

    while (1) {

        if (reloadconfig) {
            conf = config_parse ();
            if (verbose)
                printf ("lightum: SIGUSR1 received, configuration reloaded\n");
            check_config_values (conf);
            reloadconfig = 0;
        }

        if (!conf.ignoresession) {
            if (!get_session_active (proxy_session)) {
                if (verbose)
                    printf
                        ("lightum: user session not active, sleeping %d milliseconds.\nIf you believe this is an error, try running lightum with 'ignoresession=1' or '-U' command line switch.\n",
                         conf.polltime);
                usleep (conf.polltime * 1000);
                continue;
            }
        }

        if (!conf.manualmode) {
            light = get_light_sensor_value ();
            if (verbose)
                printf ("light_sensor: %d ", light);
开发者ID:vgeddes,项目名称:lightum,代码行数:67,代码来源:lightum.c


示例3: palette_alloc

void laserdisc_device::init_video()
{
	// register for VBLANK callbacks
	m_screen->register_vblank_callback(vblank_state_delegate(FUNC(laserdisc_device::vblank_state_changed), this));

	// allocate palette for applying brightness/contrast/gamma
	m_videopalette = palette_alloc(256, 1);
	if (m_videopalette == NULL)
		throw emu_fatalerror("Out of memory allocating video palette");
	for (int index = 0; index < 256; index++)
		palette_entry_set_color(m_videopalette, index, MAKE_RGB(index, index, index));

	// allocate video frames
	for (int index = 0; index < ARRAY_LENGTH(m_frame); index++)
	{
		// first allocate a YUY16 bitmap at 2x the height
		frame_data &frame = m_frame[index];
		frame.m_bitmap.allocate(m_width, m_height * 2);
		frame.m_bitmap.set_palette(m_videopalette);
		fillbitmap_yuy16(frame.m_bitmap, 40, 109, 240);

		// make a copy of the bitmap that clips out the VBI and horizontal blanking areas
		frame.m_visbitmap.wrap(&frame.m_bitmap.pix16(44, frame.m_bitmap.width() * 8 / 720),
								frame.m_bitmap.width() - 2 * frame.m_bitmap.width() * 8 / 720,
								frame.m_bitmap.height() - 44,
								frame.m_bitmap.rowpixels());
		frame.m_visbitmap.set_palette(m_videopalette);
	}

	// allocate an empty frame of the same size
	m_emptyframe.allocate(m_width, m_height * 2);
	m_emptyframe.set_palette(m_videopalette);
	fillbitmap_yuy16(m_emptyframe, 0, 128, 128);

	// allocate texture for rendering
	m_videoenable = true;
	m_videotex = machine().render().texture_alloc();
	if (m_videotex == NULL)
		fatalerror("Out of memory allocating video texture\n");

	// allocate overlay
	m_overenable = overlay_configured();
	if (m_overenable)
	{
		// bind our handlers
		m_overupdate_ind16.bind_relative_to(*owner());
		m_overupdate_rgb32.bind_relative_to(*owner());

		// configure bitmap formats
		bitmap_format format = !m_overupdate_ind16.isnull() ? BITMAP_FORMAT_IND16 : BITMAP_FORMAT_RGB32;
		texture_format texformat = !m_overupdate_ind16.isnull() ? TEXFORMAT_PALETTEA16 : TEXFORMAT_ARGB32;

		// allocate overlay bitmaps
		for (int index = 0; index < ARRAY_LENGTH(m_overbitmap); index++)
		{
			m_overbitmap[index].set_format(format, texformat);
			m_overbitmap[index].set_palette(machine().palette);
			m_overbitmap[index].resize(m_overwidth, m_overheight);
		}

		// allocate overlay texture
		m_overtex = machine().render().texture_alloc();
		if (m_overtex == NULL)
			fatalerror("Out of memory allocating overlay texture\n");
	}
}
开发者ID:Ilgrim,项目名称:MAMEHub,代码行数:66,代码来源:laserdsc.c


示例4: if

                  );

            if (!p)
              moves.nMoves++;
            else if (p->whatColor() != color)
              moves.nMoves++;
          }
      }

    return;
  }

const POSITIONOFFSET kingOffset[] =
  { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1}, { 0, 1 },
    { 1, -1 }, { 1, 0 }, { 1, 1 } };
const int nKingOffsets = ARRAY_LENGTH(kingOffset);

const POSITIONOFFSET knightOffset[] =
  { { 1, 2 }, { 2, 1}, { -1, 2 }, { 2, -1 }, { 1, -2}, { -2, 1 },
    { -1, -2 }, { -2, -1 } };
const int nKnightOffsets = ARRAY_LENGTH(knightOffset);

void PAWN::promote(PIECETYPE promoteType)
  {
    switch (promoteType)
      {
      case TYPEQUEEN:
        promotePiece = new QUEEN(whatColor());
        break;

      case TYPEROOK:
开发者ID:wkaras,项目名称:xterm-CUI-Chess,代码行数:31,代码来源:chess.cpp


示例5: memset

void jangou_blitter_device::device_reset()
{
	memset(m_pen_data, 0, ARRAY_LENGTH(m_pen_data));
	m_bltflip = false;
}
开发者ID:RafTacker,项目名称:mame,代码行数:5,代码来源:jangou_blitter.cpp


示例6: recurse_dir

static int recurse_dir(int srcrootlen, const astring *srcdir)
{
	static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE };
	int result = 0;
	int entindex;

	/* iterate first over directories, then over files */
	for (entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
	{
		osd_dir_entry_type entry_type = typelist[entindex];
		const osd_directory_entry *entry;
		list_entry **listarray = NULL;
		list_entry *list = NULL;
		list_entry *curlist;
		osd_directory *dir;
		int found = 0;

		/* open the directory and iterate through it */
		dir = osd_opendir(astring_c(srcdir));
		if (dir == NULL)
		{
			result = 1;
			goto error;
		}

		/* build up the list of files */
		while ((entry = osd_readdir(dir)) != NULL)
			if (entry->type == entry_type && entry->name[0] != '.')
			{
				list_entry *lentry = (list_entry *)malloc(sizeof(*lentry));
				lentry->name = astring_dupc(entry->name);
				lentry->next = list;
				list = lentry;
				found++;
			}

		/* close the directory */
		osd_closedir(dir);

		/* skip if nothing found */
		if (found == 0)
			continue;

		/* allocate memory for sorting */
		listarray = (list_entry **)malloc(sizeof(list_entry *) * found);
		found = 0;
		for (curlist = list; curlist != NULL; curlist = curlist->next)
			listarray[found++] = curlist;

		/* sort the list */
		qsort(listarray, found, sizeof(listarray[0]), compare_list_entries);

		/* rebuild the list */
		list = NULL;
		while (--found >= 0)
		{
			listarray[found]->next = list;
			list = listarray[found];
		}
		free(listarray);

		/* iterate through each file */
		for (curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
		{
			astring *srcfile;

			/* build the source filename */
			srcfile = astring_alloc();
			astring_printf(srcfile, "%s%c%s", astring_c(srcdir), PATH_SEPARATOR[0], astring_c(curlist->name));

			/* if we have a file, output it */
			if (entry_type == ENTTYPE_FILE)
			{
				/* make sure we care, first */
				if (core_filename_ends_with(astring_c(curlist->name), ".c"))
				{
					tagmap *depend_map = tagmap_alloc();
					tagmap_entry *map_entry;
					file_entry *file;
					astring *target;
					int taghash;

					/* find dependencies */
					file = compute_dependencies(srcrootlen, srcfile);
					recurse_dependencies(file, depend_map);

					/* convert the target from source to object (makes assumptions about rules) */
					target = astring_dup(file->name);
					astring_replacec(target, 0, "src/", "$(OBJ)/");
					astring_replacec(target, 0, ".c", ".o");
					printf("\n%s : \\\n", astring_c(target));

					/* iterate over the hashed dependencies and output them as well */
					for (taghash = 0; taghash < TAGMAP_HASH_SIZE; taghash++)
						for (map_entry = depend_map->table[taghash]; map_entry != NULL; map_entry = map_entry->next)
							printf("\t%s \\\n", astring_c((astring *)map_entry->object));

					astring_free(target);
					tagmap_free(depend_map);
				}
//.........这里部分代码省略.........
开发者ID:Luke-Nukem,项目名称:mame-144-vector_mod,代码行数:101,代码来源:makedep.c


示例7: pr8210_execute

static void pr8210_execute(const device_config *laserdisc, int command)
{
	static const UINT8 digits[10] = { 0x01, 0x11, 0x09, 0x19, 0x05, 0x15, 0x0d, 0x1d, 0x03, 0x13 };

	switch (command)
	{
		case CMD_SCAN_REVERSE:
			if (pr8210_command_buffer_in == pr8210_command_buffer_out ||
				pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer))
			{
				pr8210_add_command(0x1c);
				playing = TRUE;
			}
			break;

		case CMD_STEP_REVERSE:
			pr8210_add_command(0x12);
			playing = FALSE;
			break;

		case CMD_SLOW_REVERSE:
			pr8210_add_command(0x02);
			playing = TRUE;
			break;

		case CMD_FAST_REVERSE:
			if (pr8210_command_buffer_in == pr8210_command_buffer_out ||
				pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer))
			{
				pr8210_add_command(0x0c);
				playing = TRUE;
			}
			break;

		case CMD_SCAN_FORWARD:
			if (pr8210_command_buffer_in == pr8210_command_buffer_out ||
				pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer))
			{
				pr8210_add_command(0x08);
				playing = TRUE;
			}
			break;

		case CMD_STEP_FORWARD:
			pr8210_add_command(0x04);
			playing = FALSE;
			break;

		case CMD_SLOW_FORWARD:
			pr8210_add_command(0x18);
			playing = TRUE;
			break;

		case CMD_FAST_FORWARD:
			if (pr8210_command_buffer_in == pr8210_command_buffer_out ||
				pr8210_command_buffer_in == (pr8210_command_buffer_out + 1) % ARRAY_LENGTH(pr8210_command_buffer))
			{
				pr8210_add_command(0x10);
				playing = TRUE;
			}
			break;

		case CMD_PLAY:
			pr8210_add_command(0x14);
			playing = TRUE;
			break;

		case CMD_PAUSE:
			pr8210_add_command(0x0a);
			playing = FALSE;
			break;

		case CMD_FRAME_TOGGLE:
			pr8210_add_command(0x0b);
			break;

		case CMD_CHAPTER_TOGGLE:
			pr8210_add_command(0x06);
			break;

		case CMD_CH1_TOGGLE:
			pr8210_add_command(0x0e);
			break;

		case CMD_CH2_TOGGLE:
			pr8210_add_command(0x16);
			break;

		case CMD_0:
		case CMD_1:
		case CMD_2:
		case CMD_3:
		case CMD_4:
		case CMD_5:
		case CMD_6:
		case CMD_7:
		case CMD_8:
		case CMD_9:
			pr8210_add_command(digits[command - CMD_0]);
			break;
//.........这里部分代码省略.........
开发者ID:nitrologic,项目名称:emu,代码行数:101,代码来源:ldplayer.c


示例8: PIXGetCounterInfo

//==================================================================================================
// PIXGetCounterInfo
//==================================================================================================
BOOL WINAPI PIXGetCounterInfo( DWORD* pdwReturnCounters, PIXCOUNTERINFO** ppCounterInfoList )
{
    *pdwReturnCounters = ARRAY_LENGTH(pixCounterSet);
    *ppCounterInfoList = &pixCounterSet[0];
    return TRUE;
}
开发者ID:KNeal,项目名称:Oculus,代码行数:9,代码来源:PIXWkshpPlugin.cpp


示例9: parse_options

static int parse_options(int argc, char *argv[], options *opts)
{
	int pending_base = FALSE;
	int pending_arch = FALSE;
	int pending_mode = FALSE;
	int curarch;
	int numrows;
	int arg;

	memset(opts, 0, sizeof(*opts));

	// loop through arguments
	for (arg = 1; arg < argc; arg++)
	{
		char *curarg = argv[arg];

		// is it a switch?
		if (curarg[0] == '-')
		{
			if (pending_base || pending_arch || pending_mode)
				goto usage;

			if (tolower((UINT8)curarg[1]) == 'a')
				pending_arch = TRUE;
			else if (tolower((UINT8)curarg[1]) == 'b')
				pending_base = TRUE;
			else if (tolower((UINT8)curarg[1]) == 'f')
				opts->flipped = TRUE;
			else if (tolower((UINT8)curarg[1]) == 'l')
				opts->lower = TRUE;
			else if (tolower((UINT8)curarg[1]) == 'm')
				pending_mode = TRUE;
			else if (tolower((UINT8)curarg[1]) == 'n')
				opts->norawbytes = TRUE;
			else if (tolower((UINT8)curarg[1]) == 'u')
				opts->upper = TRUE;
			else
				goto usage;
		}

		// base PC
		else if (pending_base)
		{
			int result;
			if (curarg[0] == '0' && curarg[1] == 'x')
				result = sscanf(&curarg[2], "%x", &opts->basepc);
			else if (curarg[0] == '$')
				result = sscanf(&curarg[1], "%x", &opts->basepc);
			else
				result = sscanf(&curarg[0], "%x", &opts->basepc);
			if (result != 1)
				goto usage;
			pending_base = FALSE;
		}

		// mode
		else if (pending_mode)
		{
			if (sscanf(curarg, "%d", &opts->mode) != 1)
				goto usage;
			pending_mode = FALSE;
		}

		// architecture
		else if (pending_arch)
		{
			for (curarch = 0; curarch < ARRAY_LENGTH(dasm_table); curarch++)
				if (core_stricmp(curarg, dasm_table[curarch].name) == 0)
					break;
			if (curarch == ARRAY_LENGTH(dasm_table))
				goto usage;
			opts->dasm = &dasm_table[curarch];
			pending_arch = FALSE;
		}

		// filename
		else if (opts->filename == NULL)
			opts->filename = curarg;

		// fail
		else
			goto usage;
	}

	// if we have a dangling option, error
	if (pending_base || pending_arch || pending_mode)
		goto usage;

	// if no file or no architecture, fail
	if (opts->filename == NULL || opts->dasm == NULL)
		goto usage;
	return 0;

usage:
	printf("Usage: %s <filename> -arch <architecture> [-basepc <pc>] \n", argv[0]);
	printf("   [-mode <n>] [-norawbytes] [-flipped] [-upper] [-lower]\n");
	printf("\n");
	printf("Supported architectures:");
	numrows = (ARRAY_LENGTH(dasm_table) + 6) / 7;
	for (curarch = 0; curarch < numrows * 7; curarch++)
//.........这里部分代码省略.........
开发者ID:hstampfl,项目名称:mame2010-libretro,代码行数:101,代码来源:unidasm.c


示例10: pr8210_add_command

INLINE void pr8210_add_command(UINT8 command)
{
	pr8210_command_buffer[pr8210_command_buffer_in++ % ARRAY_LENGTH(pr8210_command_buffer)] = (command & 0x1f) | 0x20;
	pr8210_command_buffer[pr8210_command_buffer_in++ % ARRAY_LENGTH(pr8210_command_buffer)] = 0x00 | 0x20;
}
开发者ID:nitrologic,项目名称:emu,代码行数:5,代码来源:ldplayer.c


示例11: ARRAY_LENGTH

#define OP_NOP    0
#define OP_VIBRATE   1
#define OP_SHOW_NOTCONNECTED 2
#define OP_FIND_ME 3
#define OP_UNREAD_MESSAGE_COUNT 4
#define OP_CURRENT_HR 5

static char unread_sms_buffer[4];
static char current_hr_buffer[4];

static char bt_notification_delay = 0;

static const uint32_t const disconnect_segments[] = { 300, 300, 300, 300, 300 };
VibePattern disconnecte_pat = {
  .durations = disconnect_segments,
  .num_segments = ARRAY_LENGTH(disconnect_segments),
};

static void inbox_received_handler(DictionaryIterator *iterator, void *context) {
  
  // Get the first pair
  Tuple *t = dict_read_first(iterator);

  // Process all pairs present
  while(t != NULL) {
    // Process this pair's key
    APP_LOG(APP_LOG_LEVEL_INFO, "Got opcode: %d, value: %d", (int)t->key, (int)t->value->int32);
    switch(t->key) {
      case OP_VIBRATE:
        // Trigger vibration
        vibes_short_pulse();
开发者ID:garo,项目名称:GaroWatchface,代码行数:31,代码来源:main.c


示例12: progName

void TestDx::testDxCmdLineArgs()
{
    string progName("TestDxCmdLineArgs");
    int defaultMainPort(9999);
    int defaultRemotePort(5555);
    string defaultHost("thisHost");
    string defaultSciDataDir("fooDir");
    string defaultSciDataPrefix("nss.p10");
    bool defaultBroadcast(false);
    bool defaultNoUi(false);
    bool defaultVaryOutputData(false);
    string defaultDxName("dxsim33");
    bool defaultRemoteMode(false);

    DxCmdLineArgs cmdArgs(progName, 
			   defaultMainPort, defaultRemotePort,
			   defaultHost,
			   defaultSciDataDir, defaultSciDataPrefix,
			   defaultBroadcast,
			   defaultNoUi,
			   defaultVaryOutputData,
			   defaultDxName,
			   defaultRemoteMode);


    // test usage message output
    cmdArgs.usage();
    cerr << endl;

    // check the defaults
    cu_assert (cmdArgs.getMainPort() == 9999);
    cu_assert (cmdArgs.getRemotePort() == 5555);
    cu_assert (cmdArgs.getHostName() == "thisHost");
    cu_assert (cmdArgs.getSciDataDir() == "fooDir");
    cu_assert (cmdArgs.getSciDataPrefix() == "nss.p10");
    cu_assert (! cmdArgs.getBroadcast());
    cu_assert (! cmdArgs.getNoUi());
    cu_assert (! cmdArgs.getVaryOutputData());
    cu_assert (cmdArgs.getDxName() == "dxsim33");
    cu_assert (! cmdArgs.getRemoteMode());


    // try setting good parameters
    const char *argv[] = 
    { "ProgName",
      "-host", "matrix",
      "-mainport", "8888",
      "-remport", "9999",
      "-sddir", "../scienceData",
      "-sdprefix", "nss.p6",
      "-broadcast",
      "-name", "dxsim127",
      "-remote",
      "-noui",
      "-vary"
    };
    const int argc = ARRAY_LENGTH(argv);

    // verify that everything parses
    cu_assert(cmdArgs.parseArgs(argc, const_cast<char **>(argv)));

    // check the values
    cu_assert (cmdArgs.getHostName() == "matrix");
    cu_assert (cmdArgs.getMainPort() == 8888);
    cu_assert (cmdArgs.getRemotePort() == 9999);
    cu_assert (cmdArgs.getSciDataDir() == "../scienceData");
    cu_assert (cmdArgs.getSciDataPrefix() == "nss.p6");
    cu_assert (cmdArgs.getBroadcast());
    cu_assert (cmdArgs.getDxName() == "dxsim127");
    cu_assert (cmdArgs.getRemoteMode());
    cu_assert (cmdArgs.getNoUi());
    cu_assert (cmdArgs.getVaryOutputData());

    cout << "Test a bad port number:" << endl;
    const char *argvBadPort[] = 
    { "ProgName",
      "-host",
      "matrix",
      "-mainport",
      "badportnumber",
    };
    const int argcBadPort = ARRAY_LENGTH(argvBadPort);
    cu_assert(cmdArgs.parseArgs(argcBadPort, const_cast<char **>(argvBadPort)) == false);

}
开发者ID:Abhishekpatil,项目名称:SonATA,代码行数:85,代码来源:TestDx.cpp


示例13: core_fgetc


//.........这里部分代码省略.........
                else if (bom[0] == 0x00 && bom[1] == 0x00 && bom[2] == 0xfe && bom[3] == 0xff)
                {
                    file->text_type = TFT_UTF32BE;
                    pos = 4;
                }
                else if (bom[0] == 0xff && bom[1] == 0xfe && bom[2] == 0x00 && bom[3] == 0x00)
                {
                    file->text_type = TFT_UTF32LE;
                    pos = 4;
                }
                else if (bom[0] == 0xfe && bom[1] == 0xff)
                {
                    file->text_type = TFT_UTF16BE;
                    pos = 2;
                }
                else if (bom[0] == 0xff && bom[1] == 0xfe)
                {
                    file->text_type = TFT_UTF16LE;
                    pos = 2;
                }
                else
                {
                    file->text_type = TFT_OSD;
                    pos = 0;
                }
            }
            core_fseek(file, pos, SEEK_SET);
        }

        /* fetch the next character */
        switch (file->text_type)
        {
        default:
        case TFT_OSD:
            readlen = core_fread(file, default_buffer, sizeof(default_buffer));
            if (readlen > 0)
            {
                charlen = osd_uchar_from_osdchar(&uchar, default_buffer, readlen / sizeof(default_buffer[0]));
                core_fseek(file, (INT64) (charlen * sizeof(default_buffer[0])) - readlen, SEEK_CUR);
            }
            break;

        case TFT_UTF8:
            readlen = core_fread(file, utf8_buffer, sizeof(utf8_buffer));
            if (readlen > 0)
            {
                charlen = uchar_from_utf8(&uchar, utf8_buffer, readlen / sizeof(utf8_buffer[0]));
                core_fseek(file, (INT64) (charlen * sizeof(utf8_buffer[0])) - readlen, SEEK_CUR);
            }
            break;

        case TFT_UTF16BE:
            readlen = core_fread(file, utf16_buffer, sizeof(utf16_buffer));
            if (readlen > 0)
            {
                charlen = uchar_from_utf16be(&uchar, utf16_buffer, readlen / sizeof(utf16_buffer[0]));
                core_fseek(file, (INT64) (charlen * sizeof(utf16_buffer[0])) - readlen, SEEK_CUR);
            }
            break;

        case TFT_UTF16LE:
            readlen = core_fread(file, utf16_buffer, sizeof(utf16_buffer));
            if (readlen > 0)
            {
                charlen = uchar_from_utf16le(&uchar, utf16_buffer, readlen / sizeof(utf16_buffer[0]));
                core_fseek(file, (INT64) (charlen * sizeof(utf16_buffer[0])) - readlen, SEEK_CUR);
            }
            break;

        case TFT_UTF32BE:
            if (core_fread(file, &uchar, sizeof(uchar)) == sizeof(uchar))
                uchar = BIG_ENDIANIZE_INT32(uchar);
            break;

        case TFT_UTF32LE:
            if (core_fread(file, &uchar, sizeof(uchar)) == sizeof(uchar))
                uchar = LITTLE_ENDIANIZE_INT32(uchar);
            break;
        }

        if (uchar != ~0)
        {
            /* place the new character in the ring buffer */
            file->back_char_head = 0;
            file->back_char_tail = utf8_from_uchar(file->back_chars, ARRAY_LENGTH(file->back_chars), uchar);
            /*          assert(file->back_char_tail != -1);*/
        }
    }

    /* now read from the ring buffer */
    if (file->back_char_head != file->back_char_tail)
    {
        result = file->back_chars[file->back_char_head++];
        file->back_char_head %= ARRAY_LENGTH(file->back_chars);
    }
    else
        result = EOF;

    return result;
}
开发者ID:Eduardop,项目名称:mame,代码行数:101,代码来源:corefile.c


示例14: output_report

static void output_report(astring &dirname, astring &tempheader, astring &tempfooter, summary_file *filelist)
{
	summary_file *buckethead[BUCKET_COUNT], **buckettailptr[BUCKET_COUNT];
	summary_file *curfile;
	astring title("MAME Regressions");
	astring tempname;
	int listnum, bucknum;
	core_file *indexfile;
	int count = 0, total;

	/* initialize the lists */
	for (bucknum = 0; bucknum < BUCKET_COUNT; bucknum++)
	{
		buckethead[bucknum] = NULL;
		buckettailptr[bucknum] = &buckethead[bucknum];
	}

	/* compute the total number of files */
	total = 0;
	for (curfile = filelist; curfile != NULL; curfile = curfile->next)
		total++;

	/* first bucketize the games */
	for (curfile = filelist; curfile != NULL; curfile = curfile->next)
	{
		int statcount[STATUS_COUNT] = { 0 };
		int bucket = BUCKET_UNKNOWN;
		int unique_codes = 0;
		int first_valid;

		/* print status */
		if (++count % 100 == 0)
			fprintf(stderr, "Processing file %d/%d\n", count, total);

		/* find the first valid entry */
		for (first_valid = 0; curfile->status[first_valid] == STATUS_NOT_PRESENT; first_valid++) ;

		/* do we need to output anything? */
		for (listnum = first_valid; listnum < list_count; listnum++)
			if (statcount[curfile->status[listnum]]++ == 0)
				unique_codes++;

		/* were we consistent? */
		if (unique_codes == 1)
		{
			/* were we consistently ok? */
			if (curfile->status[first_valid] == STATUS_SUCCESS)
				bucket = compare_screenshots(curfile);

			/* must have been consistently erroring */
			else
				bucket = BUCKET_CONSISTENT_ERROR;
		}

		/* ok, we're not consistent; could be a number of things */
		else
		{
			/* were we ok at the start and end but not in the middle? */
			if (curfile->status[first_valid] == STATUS_SUCCESS && curfile->status[list_count - 1] == STATUS_SUCCESS)
				bucket = BUCKET_GOOD_BUT_CHANGED;

			/* did we go from good to bad? */
			else if (curfile->status[first_valid] == STATUS_SUCCESS)
				bucket = BUCKET_REGRESSED;

			/* did we go from bad to good? */
			else if (curfile->status[list_count - 1] == STATUS_SUCCESS)
				bucket = BUCKET_IMPROVED;

			/* must have had multiple errors */
			else
				bucket = BUCKET_MULTI_ERROR;
		}

		/* add us to the appropriate list */
		*buckettailptr[bucket] = curfile;
		buckettailptr[bucket] = &curfile->next;
	}

	/* terminate all the lists */
	for (bucknum = 0; bucknum < BUCKET_COUNT; bucknum++)
		*buckettailptr[bucknum] = NULL;

	/* output header */
	tempname.printf("%s" PATH_SEPARATOR "%s", dirname.cstr(), "index.html");
	indexfile = create_file_and_output_header(tempname, tempheader, title);
	if (indexfile == NULL)
	{
		fprintf(stderr, "Error creating file '%s'\n", tempname.cstr());
		return;
	}

	/* iterate over buckets and output them */
	for (bucknum = 0; bucknum < ARRAY_LENGTH(bucket_output_order); bucknum++)
	{
		int curbucket = bucket_output_order[bucknum];

		if (buckethead[curbucket] != NULL)
		{
			fprintf(stderr, "Outputting bucket: %s\n", bucket_name[curbucket]);
//.........这里部分代码省略.........
开发者ID:Archlogic,项目名称:libretro-mame,代码行数:101,代码来源:regrep.c


示例15: core_ungetc

int core_ungetc(int c, core_file *file)
{
    file->back_chars[file->back_char_tail++] = (char) c;
    file->back_char_tail %= ARRAY_LENGTH(file->back_chars);
    return c;
}
开发者ID:Eduardop,项目名称:mame,代码行数:6,代码来源:corefile.c


示例16: MCFG_QUANTUM_TIME

	MCFG_QUANTUM_TIME(attotime::from_hz(60))

	MCFG_MACHINE_START( c64 )
	MCFG_MACHINE_RESET( c64 )

	/* video hardware */
	MCFG_SCREEN_ADD("screen", RASTER)
	MCFG_SCREEN_REFRESH_RATE(VIC6567_VRETRACERATE)
	MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) /* not accurate */
	MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
	MCFG_SCREEN_SIZE(VIC6567_COLUMNS, VIC6567_LINES)
	MCFG_SCREEN_VISIBLE_AREA(0, VIC6567_VISIBLECOLUMNS - 1, 0, VIC6567_VISIBLELINES - 1)
	MCFG_SCREEN_UPDATE( c64 )

	MCFG_PALETTE_INIT( c64 )
	MCFG_PALETTE_LENGTH(ARRAY_LENGTH(c64_palette) / 3)

	MCFG_VIC2_ADD("vic2", c64_vic2_ntsc_intf)

	/* sound hardware */
	MCFG_SPEAKER_STANDARD_MONO("mono")
	MCFG_SOUND_ADD("sid6581", SID6581, VIC6567_CLOCK)
	MCFG_SOUND_CONFIG(c64_sound_interface)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
	MCFG_SOUND_ADD("dac", DAC, 0)
	MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)

	/* quickload */
	MCFG_QUICKLOAD_ADD("quickload", cbm_c64, "p00,prg,t64", CBM_QUICKLOAD_DELAY_SECONDS)

	/* cassette */
开发者ID:cdenix,项目名称:psmame,代码行数:31,代码来源:c64.c


示例17: handle_init

void handle_init(void) {
  window = window_create();
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, GColorBlack);

  Layer *window_layer = window_get_root_layer(window);

  // Setup weather bar
  Layer *weather_holder = layer_create(GRect(0, 0, 144, 50));
  layer_add_child(window_layer, weather_holder);

  icon_layer = bitmap_layer_create(GRect(8, 0, 40, 40));
  layer_add_child(weather_holder, bitmap_layer_get_layer(icon_layer));

  temp_layer = text_layer_create(GRect(32, 3, 144 - 40, 28));
  text_layer_set_text_color(temp_layer, GColorWhite);
  text_layer_set_background_color(temp_layer, GColorClear);
  text_layer_set_font(temp_layer,
      fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_text_alignment(temp_layer, GTextAlignmentRight);
  layer_add_child(weather_holder, text_layer_get_layer(temp_layer));

  // Initialize date & time text
  Layer *date_holder = layer_create(GRect(0, 52, 144, 94));
  layer_add_child(window_layer, date_holder);

  ResHandle roboto_21 = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21);
  text_day_layer = text_layer_create(GRect(8, 0, 144-8, 25));
  text_layer_set_text_color(text_day_layer, GColorWhite);
  text_layer_set_background_color(text_day_layer, GColorClear);
  text_layer_set_font(text_day_layer, fonts_load_custom_font(roboto_21));
  layer_add_child(date_holder, text_layer_get_layer(text_day_layer));

  text_date_layer = text_layer_create(GRect(8, 21, 144-8, 25));
  text_layer_set_text_color(text_date_layer, GColorWhite);
  text_layer_set_background_color(text_date_layer, GColorClear);
  text_layer_set_font(text_date_layer, fonts_load_custom_font(roboto_21));
  layer_add_child(date_holder, text_layer_get_layer(text_date_layer));

  line_layer = layer_create(GRect(8, 51, 144-16, 2));
  layer_set_update_proc(line_layer, line_layer_update_callback);
  layer_add_child(date_holder, line_layer);

  ResHandle roboto_49 = resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49);
  text_time_layer = text_layer_create(GRect(7, 45, 144-7, 49));
  text_layer_set_text_color(text_time_layer, GColorWhite);
  text_layer_set_background_color(text_time_layer, GColorClear);
  text_layer_set_font(text_time_layer, fonts_load_custom_font(roboto_49));
  layer_add_child(date_holder, text_layer_get_layer(text_time_layer));

  // Setup messaging
  const int inbound_size = 64;
  const int outbound_size = 64;
  app_message_open(inbound_size, outbound_size);

  Tuplet initial_values[] = {
    TupletInteger(WEATHER_ICON_KEY, (uint8_t) 13),
    TupletCString(WEATHER_TEMPERATURE_KEY, ""),
    TupletInteger(INVERT_COLOR_KEY, persist_read_bool(INVERT_COLOR_KEY)),
  };

  app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values,
                ARRAY_LENGTH(initial_values), sync_tuple_changed_callback,
                NULL, NULL);

  // FIXME testing code
  battery_text_layer = text_layer_create(GRect(0, 75, 144-8, 30));
  text_layer_set_text_color(battery_text_layer, GColorWhite);
  text_layer_set_background_color(battery_text_layer, GColorClear);
  text_layer_set_font(battery_text_layer, fonts_load_custom_font(roboto_21));
  text_layer_set_text_alignment(battery_text_layer, GTextAlignmentRight);
  layer_add_child(window_layer, text_layer_get_layer(battery_text_layer));

  // Subscribe to notifications
  bluetooth_connection_service_subscribe(bluetooth_connection_changed);
  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
  battery_state_service_subscribe(update_battery_state);

  // Update the battery on launch
  update_battery_state(battery_state_service_peek());

  // TODO: Update display here to avoid blank display on launch?
}
开发者ID:nabdallah,项目名称:simpleweather,代码行数:83,代码来源:simplicity.c


示例18: fix_properties

static void
fix_properties(const bt_bdaddr_t* remote_addr,
               int num_properties, bt_property_t* properties)
{
  static const bt_uuid_t uuid_zero; /* filled with zeros */

  int i;

  for (i = 0; i < num_properties; ++i) {
    if (properties[i].type == BT_PROPERTY_SERVICE_RECORD) {

      /* Bug 1142007: BT_PROPERTY_SERVICE_RECORD returns
       *
       *  {
       *    .uuid = 0,
       *    .channel = SCN,
       *    .name = "\0"
       *  }
       *
       * for every remote service. We replace the UUID with
       * the one we asked for in |get_remote_service_record|.
       */

      struct get_remote_service_record_params* params;
      bt_service_record_t* rec;

      params = fetch_get_remote_service_record_params(remote_addr);
      if (!params) {
        ALOGW("no parameters for BT_PROPERTY_SERVICE_RECORD stored");
        continue; /* no params stored; send record as-is */
      }

      rec = properties[i].val;

      if (memcmp(&uuid_zero, &rec->uuid, sizeof(uuid_zero))) {
        free_get_remote_service_record_params(params);
        continue; /* record contains non-zero UUID; nothing to fix */
      }

      /* We replace the property's UUID with the one we stored
       * for |get_remote_service_record|. That will make Gecko
       * recognize the notification correctly. The channel is
       * left as it is. We can set an arbitrary string for the
       * name.
       *
       * Remote devices can create their own names for services
       * they provide. We have no way of knowing them, so we set
       * the service's name as defined by the SDP spec and use
       * "\0" for any other service. Applications can at least
       * detect this case easily and use a generic string.
       */

      memcpy(&rec->uuid, &params->uuid, sizeof(rec->uuid));
      strncpy(rec->name,
              lookup_service_name_by_uuid16(
                UUID16(rec->uuid.uu[2], rec->uuid.uu[3]), ""),
              sizeof(rec->name));
      rec->name[ARRAY_LENGTH(rec->name) - 1] = '\0'; /* always terminate */

      free_get_remote_service_record_params(params);
    }
  }
}
开发者ID:shes050117,项目名称:platform_system_bluetoothd,代码行数:63,代码来源:bt-core-io.c


示例19: handle_init

/*
  Initialization
*/
void handle_init( void ) {
  window = window_create();
  window_stack_push( window, true );
  Layer *window_layer = window_get_root_layer( window );

  // Read persistent data
  if ( persist_exists( SETTING_STATUS_KEY ) ) {
    current_status = persist_read_int( SETTING_STATUS_KEY );
  } else {
    current_status = STATUS_ON;
  }  
  if ( persist_exists( SETTING_WEATHERSTATUS_KEY ) ) {
    weather_status = persist_read_int( SETTING_WEATHERSTATUS_KEY );
  } else {
    weather_status = WEATHER_ON;
  }
  if ( persist_exists( SETTING_LANGUAGE_KEY ) ) {
    current_language = persist_read_int( SETTING_LANGUAGE_KEY );
  } else {
    current_language = LANG_EN;
  }
  if ( persist_exists( SETTING_FORMAT_KEY ) ) {
    current_format = persist_read_int( SETTING_FORMAT_KEY );
  } else {
    current_format = FORMAT_WEEK;
  }
  if ( persist_exists( SETTING_INVERT_KEY ) ) {
    invert_format = persist_read_int( SETTING_INVERT_KEY );
  } else {
    invert_format = INVERT_ON;
  }
  if ( persist_exists( BLUETOOTHVIBE_KEY ) ) {
    bluetoothvibe_status = persist_read_int( BLUETOOTHVIBE_KEY );
  } else {
    bluetoothvibe_status = BLUETOOTHVIBE_ON;
  }
  if ( persist_exists( HOURLYVIBE_KEY ) ) {
    hourlyvibe_status = persist_read_int( HOURLYVIBE_KEY );
  } else {
    hourlyvibe_status = HOURLYVIBE_ON;
  }
  if ( persist_exists( SECS_KEY ) ) {
    secs_status = persist_read_int( SECS_KEY );
  } else {
    secs_status = SECS_ON;
  }
	
	
  // Read watchface settings from persistent data or use default values
  current_status = persist_exists( SETTING_STATUS_KEY ) ? persist_read_int( SETTING_STATUS_KEY ) : STATUS_ON;
  weather_status = persist_exists( SETTING_WEATHERSTATUS_KEY ) ? persist_read_int( SETTING_WEATHERSTATUS_KEY ) : WEATHER_ON;
  current_language = persist_exists( SETTING_LANGUAGE_KEY ) ? persist_read_int( SETTING_LANGUAGE_KEY ) : LANG_EN;
  current_format = persist_exists( SETTING_FORMAT_KEY ) ? persist_read_int( SETTING_FORMAT_KEY ) : FORMAT_WEEK;
  invert_format = persist_exists( SETTING_INVERT_KEY ) ? persist_read_int( SETTING_INVERT_KEY ) : INVERT_ON;
  bluetoothvibe_status = persist_exists( BLUETOOTHVIBE_KEY ) ? persist_read_int( BLUETOOTHVIBE_KEY ) : BLUETOOTHVIBE_ON;
  hourlyvibe_status = persist_exists( HOURLYVIBE_KEY ) ? persist_read_int( HOURLYVIBE_KEY ) : HOURLYVIBE_ON;
  secs_status = persist_exists( SECS_KEY ) ? persist_read_int( SECS_KEY ) : SECS_ON;

  // Background image
  background_image = gbitmap_create_with_resource( RESOURCE_ID_IMAGE_BACKGROUND );
  backgro 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ARRAY_SIZE函数代码示例发布时间:2022-05-30
下一篇:
C++ ARRAY_LEN函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap