コード例 #1
0
// Check all the formats of native implementation name to see if there is one
// for the specified method.
address NativeLookup::lookup_entry(methodHandle method, bool& in_base_library, TRAPS) {
  address entry = NULL;
  in_base_library = false;

  // Compute pure name
  char* pure_name = pure_jni_name(method);

  //计算指定本地方法的参数数量
  int args_size = 1                             // JNIEnv
                + (method->is_static() ? 1 : 0) // class for static methods
                + method->size_of_parameters(); // actual parameters


  // 1) Try JNI short style
  entry = lookup_style(method, pure_name, "",        args_size, true,  in_base_library, CHECK_NULL);
  if (entry != NULL) return entry;

  // Compute long name
  char* long_name = long_jni_name(method);

  // 2) Try JNI long style
  entry = lookup_style(method, pure_name, long_name, args_size, true,  in_base_library, CHECK_NULL);
  if (entry != NULL) return entry;

  // 3) Try JNI short style without os prefix/suffix
  entry = lookup_style(method, pure_name, "",        args_size, false, in_base_library, CHECK_NULL);
  if (entry != NULL) return entry;

  // 4) Try JNI long style without os prefix/suffix
  entry = lookup_style(method, pure_name, long_name, args_size, false, in_base_library, CHECK_NULL);

  return entry; // NULL indicates not found
}
コード例 #2
0
ファイル: fileio_siag.c プロジェクト: UlricE/SiagOffice
static int load_flat(char *fn, buffer *buf)
{
	int i, j, intp;
	char *texti;
	FILE *fp;
	int *fmts = NULL;
	int nfmt = -1;
	char instring[256], *p, *coords, *contents, *comma;
	int sw = 80, sh = 20, sf = 0, f;
	int s = 0;
	int *styles = NULL;
	int nsty = 0;
	int n;
	MwFmt fmt;
	int lastph = -1;
	cval value;
	char *endp;
	int type;
	value.number = 0;

	if ((fp = fopen(fn, "r")) == NULL)
		return 1;

	for (s = 0; s < buf->nsht; s++) {
		for (i = line_last_used(buf, s); i > 0; i--) {
			for (j = col_last_changed(buf, s, i, sf); j > 0; j--) {
				ins_data(buf, siod_interpreter, NULL,
					value, EMPTY, s, i, j);
				ins_format(buf, s, i, j, sf);
			}
		}
	}

	buf->a1_refs = a1_refs;

	s = 0;	/* old files have no .sheet tags, so start at first sheet */
	while (fgets(instring, 250, fp) != NULL) {
		char b[1024];
		b[0] = '\0';	/* make sure we don't keep stuff between loops */

		/* strip off \r\n */
/*
   if ((p = strpbrk(instring, "\r\n")) != NULL) *p = '\0';
 */

		switch (instring[0]) {
		case '\0':
		case '#':
			break;
		case '.':
                        if (!strncmp(instring, ".margins ", 9)) {
                                sscanf(instring, ".margins %d %d %d %d %d %d",
                                       &(buf->top_margin),
                                       &(buf->bottom_margin),
                                       &(buf->left_margin),
                                       &(buf->right_margin),
                                       &(buf->header_margin),
                                       &(buf->footer_margin));
			} else if (!strncmp(instring, ".a1_refs ", 9)) {
				sscanf(instring, ".a1_refs %d",
					&(buf->a1_refs));
                        } else if (!strncmp(instring, ".paper ", 7)) {
                                sscanf(instring, ".paper %s %d %d %d",
                                       b,
                                       &(buf->paper_width),
                                       &(buf->paper_height),
                                       &(buf->orientation));
                                buf->paper_name = MwStrdup(b);
                        } else if (!strncmp(instring, ".header ", 8)) {
                                sscanf(instring, ".header %[^\n]", b);
                                buf->header = MwStrdup(b);
                        } else if (!strncmp(instring, ".footer ", 8)) {
                                sscanf(instring, ".footer %[^\n]", b);
                                buf->footer = MwStrdup(b);
                        } else if (!strncmp(instring, ".header_on_first ", 17)) {
                                sscanf(instring, ".header_on_first %d",
                                       &(buf->header_on_first));
                        } else if (!strncmp(instring, ".first_page ", 12)) {
                                sscanf(instring, ".first_page %d",
                                       &(buf->first_page_number));
                        } else if (!strncmp(instring, ".sw ", 4)) {
				sscanf(instring, ".sw %d", &sw);
				buf->sw = sw;
			} else if (!strncmp(instring, ".sh ", 4)) {
				sscanf(instring, ".sh %d", &sh);
				buf->sh = sh;
/* The old "standard format" used the .sf tag, which was bitmapped and
must no longer be used. Thus .nsf (new standard format)
*/
			} else if (!strncmp(instring, ".nsf ", 5)) {
				sscanf(instring, ".nsf %d", &sf);
				std_fmt_set(buf, sf);
			} else if (!strncmp(instring, ".cw ", 4)) {
				int w;
				sscanf(instring, ".cw %d %d", &i, &w);
				set_width(buf, s, i, w);
			} else if (!strncmp(instring, ".rh ", 4)) {
				int h;
				sscanf(instring, ".rh %d %d", &i, &h);
				set_height(buf, s, i, h);
			} else if (!strncmp(instring, ".ft", 3)) {
				sscanf(instring, ".ft%d", &n);
				if (n > nfmt) {
					nfmt = n;
					fmts = MwRealloc(fmts,
							(nfmt+1)*sizeof *fmts);
				}
				fmts[n] = MwLoadFormats(fp);
				/* now replace style with the real one */
				MwDecodeFormat(fmts[n], ~0, &fmt);
				/* Careful now. Some versions of Siag
				   produced bogus styles
				*/
				if (fmt.style < nsty
					&& styles[fmt.style] < nstyle) {
					fmt.style = styles[fmt.style];
					fmts[n] = MwEncodeFormat(~0, &fmt);
				} else {
					fmt.style = 0;
				}
			} else if (!strncmp(instring, ".style ", 7)) {
				int n;
				sscanf(instring, ".style %d", &n);
				if (n >= nsty) {
					nsty = n;
					styles = MwRealloc(styles,
							(nsty+1)*sizeof *styles);
				}
				styles[n] = load_styles(fp);
			} else if (!strncmp(instring, ".sheet ", 7)) {
				char name[1000];
				sscanf(instring, ".sheet %d %[^\n]", &s, name);
				if (s >= buf->nsht)
					buffer_add_sheet(buf, s);
				buffer_rename_sheet(buf, s, name);
			} else if (!strncmp(instring, ".fmt", 4)) {
				int h;
				char b[256];
				sscanf(instring, ".fmt%d %[^\n]", &h, b);
				h >>= MW_FMT_SHIFT;	/* 0 <= h <= 15 */
				lookup_style(style2name(h), b,
						style_table[h].type);
			} else if (!strncmp(instring, ".plugin-geometry ", 17)) {
				int n, width, height;
				n = sscanf(instring, ".plugin-geometry %d %d",
						&width, &height);
				if (lastph >= 0 && n >= 2) {
					plugin_size_set(lastph,
						width, height);
				}
			} else if (!strncmp(instring, ".plugin ", 8)) {
				int n;
				int row, col;
				char name[1024];
				plugin_t plugin;
				sscanf(instring, ".plugin %d %d %s",
					&row, &col, name);
				plugin.row = row;
				plugin.col = col;
				plugin.name = MwStrdup(name);
				p = file_name(buf, name);
				lastph = plugin.ph = plugin_start(p);
				MwFree(p);
				plugin.displayed = 0;
				if (plugin.ph != -1) {
					n = buf->sht[s].nplugin++;
					buf->sht[s].plugin = MwRealloc(buf->sht[s].plugin,
						buf->sht[s].nplugin*sizeof(plugin_t));
					buf->sht[s].plugin[n] = plugin;
				}
			} else if (!strncmp(instring, ".p", 2)) {
				int n;
				char key[256], *value;
				sscanf(instring, ".p%d %s", &n, key);
				value = MwMalloc(n+1);
				fread(value, n, 1, fp);
				value[n] = '\0';
				put_property(buf, key, value);
				MwFree(value);
			}
			break;
		default:	/* cell definition */
			if ((coords = strtok(instring, "\t")) == NULL)
				break;
			if ((contents = strtok((char *) 0, "\t\n\r")) == NULL)
				break;
			if ((p = strtok(coords, " ")) == NULL)
				break;
			i = atoi(p);
			if ((p = strtok(NULL, " ")) == NULL)
				break;
			j = atoi(p);
			if ((p = strtok(NULL, " ")) == NULL)
				break;
			f = atoi(p);
			if (nfmt == -1 || f > nfmt) {	/* old */
				f = MwFmtOldToNew(f);
			} else {
				f = fmts[f];
			}
			switch (contents[0]) {
			case '$':	/* string expression */
				if ((texti = (contents+1)) == 0)
					return 1;
				ins_data(buf, siod_interpreter, texti,
					value, STRING, s, i, j);
				ins_format(buf, s, i, j, f);
				break;
			case '=':	/* old style expression */
	/* Special case SIOD and C for backward compatibility. */
				if (contents[1] == '=') {	/* C */
					intp = C_interpreter;
					texti = (contents+2);
				} else {	/* SIOD */
					intp = siod_interpreter;
					texti = (contents+1);
				}
				value.number = strtod(texti, &endp);
				if (texti != endp && only_space(endp)) {
					type = CONSTANT;
				} else {
					type = EXPRESSION;
				}
				if (texti == 0) return 1;
				ins_data(buf, intp, texti,
					value, type, s, i, j);
				ins_format(buf, s, i, j, f);
				break;
			case '+':	/* new style expression */
				if ((comma = strchr(contents, ',')) == NULL)
					return 1;
				*comma = '\0';
				intp = name2interpreter(contents+1);
				if (intp < 0) return 1;
				if (intp == siod_interpreter &&
						comma[1] == '=') {
			/* C expression masquerading as SIOD */
					intp = C_interpreter;
					texti = (comma+2);
				} else {
					texti = (comma+1);
				}
				if (texti == 0) return 1;
				ins_data(buf, intp,
					texti, value, EXPRESSION, s, i, j);
				ins_format(buf, s, i, j, f);
				break;
			case '\"':	/* label */
				if ((texti = (contents + 1)) == 0)
					return 1;
				ins_data(buf, siod_interpreter, texti,
					value, LABEL, s, i, j);
				ins_format(buf, s, i, j, f);
				break;
			case 'm':	/* embedded */
				if ((texti = (contents + 1)) == 0)
					return 1;
				embed_load(contents+1);
				ins_data(buf, siod_interpreter, texti,
					value, EMBED, s, i, j);
				ins_format(buf, s, i, j, f);
				break;
			default:	/* anything else means empty */
				ins_format(buf, s, i, j, f);
				break;
			}
			break;
		}