static awk_value_t * var_test(int nargs, awk_value_t *result) { awk_value_t value, value2; awk_value_t *valp; assert(result != NULL); make_number(0.0, result); if (nargs != 1) { printf("var_test: nargs not right (%d should be 1)\n", nargs); goto out; } /* look up PROCINFO - should fail */ if (sym_lookup("PROCINFO", AWK_ARRAY, & value)) printf("var_test: sym_lookup of PROCINFO failed - got a value!\n"); else printf("var_test: sym_lookup of PROCINFO passed - did not get a value\n"); /* look up a reserved variable - should pass */ if (sym_lookup("ARGC", AWK_NUMBER, & value)) printf("var_test: sym_lookup of ARGC passed - got a value!\n"); else printf("var_test: sym_lookup of ARGC failed - did not get a value\n"); /* now try to set it - should fail */ value.num_value++; if (sym_update("ARGC", & value)) printf("var_test: sym_update of ARGC passed and should not have!\n"); else printf("var_test: sym_update of ARGC failed - correctly\n"); /* look up variable whose name is passed in, should pass */ if (get_argument(0, AWK_STRING, & value)) { if (sym_lookup(value.str_value.str, AWK_STRING, & value2)) { /* change the value, should be reflected in awk script */ valp = make_number(42.0, & value2); if (sym_update(value.str_value.str, valp)) { printf("var_test: sym_update(\"%s\") succeeded\n", value.str_value.str); } else { printf("var_test: sym_update(\"%s\") failed\n", value.str_value.str); goto out; } } else { printf("var_test: sym_lookup(\"%s\") failed\n", value.str_value.str); goto out; } } else { printf("var_test: get_argument() failed\n"); goto out; } make_number(1.0, result); out: return result; }
static Lisp_Object render_all (Lisp_Object ignore) { ONTRACE (fprintf (stderr, "render_all\n")); /* According to the docs we should not call OpenClipboard() here, but testing on W2K and working code in other projects shows that it is actually necessary. */ OpenClipboard (NULL); /* There is no useful means to report errors here, there are none expected anyway, and even if there were errors, they wouldn't do any harm. So we just go ahead and do what has to be done without bothering with error handling. */ ++modifying_clipboard; EmptyClipboard (); --modifying_clipboard; /* For text formats that we don't render here, the OS can use its own translation rules instead, so we don't really need to offer everything. To minimize memory consumption we cover three possible situations based on our primary format as detected from selection-coding-system (see setup_config()): - Post CF_TEXT only. Let the OS convert to CF_OEMTEXT and the OS (on NT) or the application (on 9x/Me) convert to CF_UNICODETEXT. - Post CF_OEMTEXT only. Similar automatic conversions happen as for CF_TEXT. - Post CF_UNICODETEXT + CF_TEXT. 9x itself ignores CF_UNICODETEXT, even though some applications can still handle it. Note 1: We render the less capable CF_TEXT *before* the more capable CF_UNICODETEXT, to prevent clobbering through automatic conversions, just in case. Note 2: We could check os_subtype here and only render the additional CF_TEXT on 9x/Me. But OTOH with current_clipboard_type == CF_UNICODETEXT we don't involve the automatic conversions anywhere else, so to get consistent results, we probably don't want to rely on it here either. */ render_locale (); if (current_clipboard_type == CF_UNICODETEXT) render (make_number (CF_TEXT)); render (make_number (current_clipboard_type)); CloseClipboard (); return Qnil; }
/* This is the callback function for arriving input on kqueuefd. It shall create a Lisp event, and put it into the Emacs input queue. */ static void kqueue_callback (int fd, void *data) { for (;;) { struct kevent kev; static const struct timespec nullts = { 0, 0 }; Lisp_Object descriptor, watch_object, file, actions; /* Read one event. */ int ret = kevent (kqueuefd, NULL, 0, &kev, 1, &nullts); if (ret < 1) { /* All events read. */ return; } /* Determine descriptor and file name. */ descriptor = make_number (kev.ident); watch_object = assq_no_quit (descriptor, watch_list); if (CONSP (watch_object)) file = XCAR (XCDR (watch_object)); else continue; /* Determine event actions. */ actions = Qnil; if (kev.fflags & NOTE_DELETE) actions = Fcons (Qdelete, actions); if (kev.fflags & NOTE_WRITE) { /* Check, whether this is a directory event. */ if (NILP (Fnth (make_number (4), watch_object))) actions = Fcons (Qwrite, actions); else kqueue_compare_dir_list (watch_object); } if (kev.fflags & NOTE_EXTEND) actions = Fcons (Qextend, actions); if (kev.fflags & NOTE_ATTRIB) actions = Fcons (Qattrib, actions); if (kev.fflags & NOTE_LINK) actions = Fcons (Qlink, actions); /* It would be useful to know the target of the rename operation. At this point, it is not possible. Happens only when the upper directory is monitored. */ if (kev.fflags & NOTE_RENAME) actions = Fcons (Qrename, actions); /* Create the event. */ if (! NILP (actions)) kqueue_generate_event (watch_object, actions, file, Qnil); /* Cancel monitor if file or directory is deleted or renamed. */ if (kev.fflags & (NOTE_DELETE | NOTE_RENAME)) Fkqueue_rm_watch (descriptor); } return; }
static void record_backtrace (log_t *log, EMACS_INT count) { Lisp_Object backtrace; ptrdiff_t index; if (!INTEGERP (log->next_free)) /* FIXME: transfer the evicted counts to a special entry rather than dropping them on the floor. */ evict_lower_half (log); index = XINT (log->next_free); /* Get a "working memory" vector. */ backtrace = HASH_KEY (log, index); get_backtrace (backtrace); { /* We basically do a `gethash+puthash' here, except that we have to be careful to avoid memory allocation since we're in a signal handler, and we optimize the code to try and avoid computing the hash+lookup twice. See fns.c:Fputhash for reference. */ EMACS_UINT hash; ptrdiff_t j = hash_lookup (log, backtrace, &hash); if (j >= 0) { EMACS_INT old_val = XINT (HASH_VALUE (log, j)); EMACS_INT new_val = saturated_add (old_val, count); set_hash_value_slot (log, j, make_number (new_val)); } else { /* BEWARE! hash_put in general can allocate memory. But currently it only does that if log->next_free is nil. */ int j; eassert (!NILP (log->next_free)); j = hash_put (log, backtrace, make_number (count), hash); /* Let's make sure we've put `backtrace' right where it already was to start with. */ eassert (index == j); /* FIXME: If the hash-table is almost full, we should set some global flag so that some Elisp code can offload its data elsewhere, so as to avoid the eviction code. There are 2 ways to do that, AFAICT: - Set a flag checked in QUIT, such that QUIT can then call Fprofiler_cpu_log and stash the full log for later use. - Set a flag check in post-gc-hook, so that Elisp code can call profiler-cpu-log. That gives us more flexibility since that Elisp code can then do all kinds of fun stuff like write the log to disk. Or turn it right away into a call tree. Of course, using Elisp is generally preferable, but it may take longer until we get a chance to run the Elisp code, so there's more risk that the table will get full before we get there. */ } } }
void save_menu_items (void) { Lisp_Object saved = list4 (!NILP (menu_items_inuse) ? menu_items : Qnil, make_number (menu_items_used), make_number (menu_items_n_panes), make_number (menu_items_submenu_depth)); record_unwind_protect (restore_menu_items, saved); menu_items_inuse = Qnil; menu_items = Qnil; }
static SkPaint make_paint() { SkPaint paint; if (fuzz->exhausted()) { return paint; } paint.setHinting(make_paint_hinting()); paint.setAntiAlias(make_bool()); paint.setDither(make_bool()); paint.setLinearText(make_bool()); paint.setSubpixelText(make_bool()); paint.setLCDRenderText(make_bool()); paint.setEmbeddedBitmapText(make_bool()); paint.setAutohinted(make_bool()); paint.setVerticalText(make_bool()); paint.setFakeBoldText(make_bool()); paint.setDevKernText(make_bool()); paint.setFilterQuality(make_filter_quality()); paint.setStyle(make_paint_style()); paint.setColor(make_color()); paint.setStrokeWidth(make_number(false)); paint.setStrokeMiter(make_number(false)); paint.setStrokeCap(make_paint_cap()); paint.setStrokeJoin(make_paint_join()); paint.setColorFilter(make_color_filter()); paint.setBlendMode(make_blendmode()); paint.setPathEffect(make_path_effect()); paint.setMaskFilter(make_mask_filter()); if (false) { // our validating buffer does not support typefaces yet, so skip this for now paint.setTypeface(SkTypeface::MakeFromName(make_font_name().c_str(),make_typeface_style())); } SkLayerRasterizer::Builder rasterizerBuilder; SkPaint paintForRasterizer; if (make_bool()) { paintForRasterizer = make_paint(); } rasterizerBuilder.addLayer(paintForRasterizer); paint.setRasterizer(rasterizerBuilder.detach()); paint.setImageFilter(make_image_filter()); bool a, b, c; fuzz->next(&a, &b, &c); sk_sp<SkData> data(make_3Dlut(nullptr, a, b, c)); paint.setTextAlign(make_paint_align()); SkScalar d, e, f; fuzz->next(&d, &e, &f); paint.setTextSize(d); paint.setTextScaleX(e); paint.setTextSkewX(f); paint.setTextEncoding(make_paint_text_encoding()); return paint; }
static void store_function_docstring (Lisp_Object obj, ptrdiff_t offset) { /* Don't use indirect_function here, or defaliases will apply their docstrings to the base functions (Bug#2603). */ Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj; /* The type determines where the docstring is stored. */ /* Lisp_Subrs have a slot for it. */ if (SUBRP (fun)) { intptr_t negative_offset = - offset; XSUBR (fun)->doc = (char *) negative_offset; } /* If it's a lisp form, stick it in the form. */ else if (CONSP (fun)) { Lisp_Object tem; tem = XCAR (fun); if (EQ (tem, Qlambda) || EQ (tem, Qautoload) || (EQ (tem, Qclosure) && (fun = XCDR (fun), 1))) { tem = Fcdr (Fcdr (fun)); if (CONSP (tem) && INTEGERP (XCAR (tem))) /* FIXME: This modifies typically pure hash-cons'd data, so its correctness is quite delicate. */ XSETCAR (tem, make_number (offset)); } else if (EQ (tem, Qmacro)) store_function_docstring (XCDR (fun), offset); } /* Bytecode objects sometimes have slots for it. */ else if (COMPILEDP (fun)) { /* This bytecode object must have a slot for the docstring, since we've found a docstring for it. */ if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING) ASET (fun, COMPILED_DOC_STRING, make_number (offset)); else { AUTO_STRING (format, "No docstring slot for %s"); CALLN (Fmessage, format, (SYMBOLP (obj) ? SYMBOL_NAME (obj) : build_string ("<anonymous>"))); } } }
void fz_default_css_style(fz_context *ctx, fz_css_style *style) { memset(style, 0, sizeof *style); style->visibility = V_VISIBLE; style->text_align = TA_LEFT; style->vertical_align = VA_BASELINE; style->white_space = WS_NORMAL; style->list_style_type = LST_DISC; style->font_size = make_number(1, N_SCALE); style->width = make_number(0, N_AUTO); style->height = make_number(0, N_AUTO); }
static awk_value_t * do_pg_fieldsbyname(int nargs, awk_value_t *result) { PGresult *res; awk_value_t array; int nf; int col; if (do_lint && (nargs > 2)) lintwarn(ext_id, _("pg_fieldsbyname: called with too many arguments")); if (!(res = find_handle(results, 0))) { set_ERRNO(_("pg_fieldsbyname called with unknown result handle")); RET_NUM(-1); } if (!get_argument(1, AWK_ARRAY, &array)) { set_ERRNO(_("pg_fieldsbyname 2nd argument must be an array")); RET_NUM(-1); } clear_array(array.array_cookie); nf = PQnfields(res); for (col = 0; col < nf; col++) { char *fname; awk_value_t idx, val; fname = PQfname(res, col); set_array_element(array.array_cookie, make_string_malloc(fname, strlen(fname), &idx), make_number(col, &val)); } RET_NUM(nf); }
/* Record point, if necessary, as it was at beginning of this command. BEG is the position of point that will naturally occur as a result of the undo record that will be added just after this command terminates. */ static void record_point (ptrdiff_t beg) { /* Don't record position of pt when undo_inhibit_record_point holds. */ if (undo_inhibit_record_point) return; bool at_boundary; /* Check whether we are at a boundary now, in case we record the first change. FIXME: This check is currently dependent on being called before record_first_change, but could be made not to by ignoring timestamp undo entries */ at_boundary = ! CONSP (BVAR (current_buffer, undo_list)) || NILP (XCAR (BVAR (current_buffer, undo_list))); /* If this is the first change since save, then record this.*/ if (MODIFF <= SAVE_MODIFF) record_first_change (); /* We may need to record point if we are immediately after a boundary, so that this will be restored correctly after undo. We do not need to do this if point is at the start of a change region since it will be restored there anyway, and we must not do this if the buffer has changed since the last command, since the value of point that we have will be for that buffer, not this.*/ if (at_boundary && point_before_last_command_or_undo != beg && buffer_before_last_command_or_undo == current_buffer ) bset_undo_list (current_buffer, Fcons (make_number (point_before_last_command_or_undo), BVAR (current_buffer, undo_list))); }
static void fill_in_array(awk_value_t *new_array) { awk_array_t a_cookie; awk_value_t index, value; a_cookie = create_array(); (void) make_const_string("hello", 5, & index); (void) make_const_string("world", 5, & value); if (! set_array_element(a_cookie, & index, & value)) { printf("fill_in_array:%d: set_array_element failed\n", __LINE__); return; } (void) make_const_string("answer", 6, & index); (void) make_number(42.0, & value); if (! set_array_element(a_cookie, & index, & value)) { printf("fill_in_array:%d: set_array_element failed\n", __LINE__); return; } new_array->val_type = AWK_ARRAY; new_array->array_cookie = a_cookie; }
NODE * dlload(NODE *tree, void *dl) { make_builtin("kill", do_kill, 2); make_builtin("killpg", do_killpg, 2); make_builtin("raise", do_raise, 1); make_builtin("signal", do_signal, 4); //make_builtin("sigaddset", do_sigaddset, 2); //make_builtin("sigdelset", do_sigdelset, 2); //make_builtin("sigismember", do_ismember, 2); //make_builtin("sigfillset", do_sigfillset, 1); //make_builtin("sigemptyset", do_sigemptyset, 1); make_builtin("sigprocmask", do_sigprocmask, 3); make_builtin("sigpending", do_sigpending, 1); make_builtin("pause", do_pause, 0); make_builtin("sigsuspend", do_sigsuspend, 1); make_builtin("alarm", do_alarm, 1); return make_number((AWKNUM) 0); }
static void handler(int signo) { SigTable *sig_tbl; AWKNUM ret; static INSTRUCTION *code; extern int exiting; sig_tbl = sig2ptr(signo); /* make function call instructions */ code = bcalloc(Op_func_call, 2, 0); code->func_name = NULL; /* not needed, func_body will assign */ code->nexti = bcalloc(Op_stop, 1, 0); code->func_body = sig_tbl->user_handler; (code + 1)->expr_count = 1; /* function takes one argument */ PUSH(make_number((AWKNUM) signo)); interpret(code); if (exiting) /* do not assume anything about the user-defined function! */ gawk_exit(exit_val); POP_NUMBER(ret); bcfree(code->nexti); /* Op_stop */ bcfree(code); /* Op_func_call */ return; }
static NODE * do_fork(int nargs) { int ret = -1; NODE **aptr; NODE *tmp; if (do_lint && get_curfunc_arg_count() > 0) lintwarn("fork: called with too many arguments"); ret = fork(); if (ret < 0) update_ERRNO(); else if (ret == 0) { /* update PROCINFO in the child */ aptr = assoc_lookup(PROCINFO_node, tmp = make_string("pid", 3), FALSE); (*aptr)->numbr = (AWKNUM) getpid(); unref(tmp); aptr = assoc_lookup(PROCINFO_node, tmp = make_string("ppid", 4), FALSE); (*aptr)->numbr = (AWKNUM) getppid(); unref(tmp); } /* Set the return value */ return make_number((AWKNUM) ret); }
static awk_bool_t init_filefuncs(void) { int errors = 0; int i; awk_value_t value; /* at least right now, only FTS needs initializing */ static struct flagtab { const char *name; int value; } opentab[] = { #define ENTRY(x) { #x, x } ENTRY(FTS_COMFOLLOW), ENTRY(FTS_LOGICAL), ENTRY(FTS_NOCHDIR), ENTRY(FTS_PHYSICAL), ENTRY(FTS_SEEDOT), ENTRY(FTS_XDEV), { NULL, 0 } }; for (i = 0; opentab[i].name != NULL; i++) { (void) make_number(opentab[i].value, & value); if (! sym_constant(opentab[i].name, & value)) { warning(ext_id, "fts init: could not create constant %s", opentab[i].name); errors++; } } return errors == 0; }
static void array_set_numeric(awk_array_t array, const char *sub, double num) { awk_value_t tmp; array_set(array, sub, make_number(num, & tmp)); }
static fz_css_number border_width_from_property(fz_css_match *match, const char *property) { fz_css_value *value = value_from_property(match, property); if (value) { if (!strcmp(value->data, "thin")) return make_number(1, N_LENGTH); if (!strcmp(value->data, "medium")) return make_number(2, N_LENGTH); if (!strcmp(value->data, "thick")) return make_number(4, N_LENGTH); return number_from_value(value, 0, N_LENGTH); } return make_number(2, N_LENGTH); /* initial: 'medium' */ }
static NODE * do_waitpid(int nargs) { NODE *pidnode; int ret = -1; double pidval; pid_t pid; int options = 0; if (do_lint && get_curfunc_arg_count() > 1) lintwarn("waitpid: called with too many arguments"); pidnode = get_scalar_argument(0, FALSE); if (pidnode != NULL) { pidval = force_number(pidnode); pid = (int) pidval; options = WNOHANG|WUNTRACED; ret = waitpid(pid, NULL, options); if (ret < 0) update_ERRNO(); } else if (do_lint) lintwarn("wait: called with no arguments"); /* Set the return value */ return make_number((AWKNUM) ret); }
static void evict_lower_half (log_t *log) { ptrdiff_t size = ASIZE (log->key_and_value) / 2; EMACS_INT median = approximate_median (log, 0, size); ptrdiff_t i; for (i = 0; i < size; i++) /* Evict not only values smaller but also values equal to the median, so as to make sure we evict something no matter what. */ if (XINT (HASH_VALUE (log, i)) <= median) { Lisp_Object key = HASH_KEY (log, i); { /* FIXME: we could make this more efficient. */ Lisp_Object tmp; XSET_HASH_TABLE (tmp, log); /* FIXME: Use make_lisp_ptr. */ Fremhash (key, tmp); } eassert (EQ (log->next_free, make_number (i))); { int j; eassert (VECTORP (key)); for (j = 0; j < ASIZE (key); j++) ASET (key, j, Qnil); } set_hash_key_slot (log, i, key); } }
void record_insert (ptrdiff_t beg, ptrdiff_t length) { Lisp_Object lbeg, lend; if (EQ (BVAR (current_buffer, undo_list), Qt)) return; record_point (beg); /* If this is following another insertion and consecutive with it in the buffer, combine the two. */ if (CONSP (BVAR (current_buffer, undo_list))) { Lisp_Object elt; elt = XCAR (BVAR (current_buffer, undo_list)); if (CONSP (elt) && INTEGERP (XCAR (elt)) && INTEGERP (XCDR (elt)) && XINT (XCDR (elt)) == beg) { XSETCDR (elt, make_number (beg + length)); return; } } XSETFASTINT (lbeg, beg); XSETINT (lend, beg + length); bset_undo_list (current_buffer, Fcons (Fcons (lbeg, lend), BVAR (current_buffer, undo_list))); }
int main(){ int i; for(i = 0; i < 3; i ++){ printf("%*d",8,(make_number(i) & MAX_NUM-1)); } }
static Lisp_Object validate_coding_system (Lisp_Object coding_system) { Lisp_Object eol_type; /* Make sure the input is valid. */ if (NILP (Fcoding_system_p (coding_system))) return Qnil; /* Make sure we use a DOS coding system as mandated by the system specs. */ eol_type = Fcoding_system_eol_type (coding_system); /* Already a DOS coding system? */ if (EQ (eol_type, make_number (1))) return coding_system; /* Get EOL_TYPE vector of the base of CODING_SYSTEM. */ if (!VECTORP (eol_type)) { eol_type = Fcoding_system_eol_type (Fcoding_system_base (coding_system)); if (!VECTORP (eol_type)) return Qnil; } return AREF (eol_type, 1); }
static void record_point (ptrdiff_t pt) { bool at_boundary; /* Don't record position of pt when undo_inhibit_record_point holds. */ if (undo_inhibit_record_point) return; /* Allocate a cons cell to be the undo boundary after this command. */ if (NILP (pending_boundary)) pending_boundary = Fcons (Qnil, Qnil); run_undoable_change (); at_boundary = ! CONSP (BVAR (current_buffer, undo_list)) || NILP (XCAR (BVAR (current_buffer, undo_list))); if (MODIFF <= SAVE_MODIFF) record_first_change (); /* If we are just after an undo boundary, and point wasn't at start of deleted range, record where it was. */ if (at_boundary && current_buffer == last_boundary_buffer && last_boundary_position != pt) bset_undo_list (current_buffer, Fcons (make_number (last_boundary_position), BVAR (current_buffer, undo_list))); }
/* BEGIN { ERRNO = "" ret = test_errno() printf("test_errno() returned %d, ERRNO = %s\n", ret, ERRNO) print "" } */ static awk_value_t * test_errno(int nargs, awk_value_t *result) { assert(result != NULL); make_number(0.0, result); if (nargs != 0) { printf("test_errno: nargs not right (%d should be 0)\n", nargs); goto out; } update_ERRNO_int(ECHILD); make_number(1.0, result); out: return result; }
static void add_number(ac_uint4 code, short num, short denom) { ac_uint4 i, j; /* * Insert the code in order. */ for (i = 0; i < ncodes_used && code > ncodes[i].code; i++) ; /* * Handle the case of the codes matching and simply replace the number * that was there before. */ if (i < ncodes_used && code == ncodes[i].code) { ncodes[i].idx = make_number(num, denom); return; } /* * Resize the array if necessary. */ if (ncodes_used == ncodes_size) { if (ncodes_size == 0) ncodes = (_codeidx_t *) malloc(sizeof(_codeidx_t) << 3); else ncodes = (_codeidx_t *) realloc((char *) ncodes, sizeof(_codeidx_t) * (ncodes_size + 8)); ncodes_size += 8; } /* * Shift things around to insert the code if necessary. */ if (i < ncodes_used) { for (j = ncodes_used; j > i; j--) { ncodes[j].code = ncodes[j - 1].code; ncodes[j].idx = ncodes[j - 1].idx; } } ncodes[i].code = code; ncodes[i].idx = make_number(num, denom); ncodes_used++; }
static emacs_value module_make_integer (emacs_env *env, intmax_t n) { MODULE_FUNCTION_BEGIN (module_nil); if (FIXNUM_OVERFLOW_P (n)) xsignal0 (Qoverflow_error); return lisp_to_value (make_number (n)); }
static NODE * do_pause(int nargs) { if (do_lint && get_curfunc_arg_count() > 0) lintwarn("pause: called with too many arguments"); return make_number((AWKNUM) pause()); }
// 材質 NODE * do_Material(int nargs) { NODE *tmp; GLenum face; GLenum pname; float params[8]; int param_num; int i; tmp = (NODE*) get_actual_argument(0, FALSE, FALSE); force_string(tmp); face = material_face(tmp->stptr); tmp = (NODE*) get_actual_argument(1, FALSE, FALSE); force_string(tmp); pname = material_pname(tmp->stptr); switch (pname) { case GL_SHININESS: param_num = 1; break; case GL_COLOR_INDEXES: param_num = 3; break; case GL_AMBIENT_AND_DIFFUSE: param_num = 8; break; default: param_num = 4; break; } for (i = 0; i < param_num; i++) { tmp = (NODE*) get_actual_argument(i + 2, FALSE, FALSE); params[i] = (GLfloat) force_number(tmp); } // OpenGLで質感を設定するときは、通常glMaterialfv()を使います。 // いままで使ってきた、glColor3fv()と同様に、図形を描く前に質感を設定するという手順をとります。 // OpenGLのポリゴンには、表と裏という概念があって、faceはそのどちらの面の質感を設定するかを指定する。 // GL_FRONT(表)、GL_BACK(裏)、GL_FRONT_AND_BACK(両方)のうちのいずれか。 // 今回は、ひとまずGL_FRONT_AND_BACKを指定しておいた。 // ポリゴンの表裏に関しては、他の機会に説明する。 // pnameは、質感のどのパラメタを設定するかを指定する。 // GL_AMBIENT、GL_DIFFUSE、GL_SPECULAR、GL_EMISSION、GL_SHININESSなどがあり、このうちの1つを選んで設定する。 // それぞれ、質感についてで解説した通り。 // paramsには、実際に設定する値の入った配列を渡す。 // GL_AMBIENT、GL_DIFFUSE、GL_SPECULAR、GL_EMISSIONの場合は、RGBA形式である。 // それぞれ、─1から1の範囲の値を入れる。 // GL_SHININESSの場合は、渡す値は1つで、0から128の範囲の値である。 // GL_SHINESSを設定するだけなら、glMaterialf()を使うこともできる。 // //void glMaterialfv(GLenum face, GLenum pname, const GLfloat *params) glMaterialfv(face, pname, params); return make_number((AWKNUM) 0); }
static void load_READLINE(NODE *symbol, void *data) { sdata_t *sd = (sdata_t *) data; NODE *file, *tmp; FILE *fp; static char linebuf[BUFSIZ]; int i; bool long_line = false; if (! sd->load_file) /* non-existent SYS["readline"] or already loaded */ return; file = sd->filename; force_string(file); if (file->stlen == 0) return; assoc_clear(symbol); if ((fp = fopen(file->stptr, "r" )) == NULL) { warning(_("READLINE (%s): %s"), file->stptr, strerror(errno)); return; } for (i = 1; fgets(linebuf, sizeof(linebuf), fp ) != NULL; i++) { NODE **lhs; size_t sz; sz = strlen(linebuf); if (sz > 0 && linebuf[sz - 1] == '\n') { linebuf[sz - 1] = '\0'; sz--; if (long_line) { long_line = false; i--; continue; } } else if (long_line) { i--; continue; } else { if (do_lint) lintwarn(_("file `%s' does not end in newline or line # `%d' is too long"), file->stptr, i); long_line = true; } tmp = make_number(i); lhs = assoc_lookup(symbol, tmp); unref(tmp); unref(*lhs); *lhs = make_string(linebuf, sz); } fclose(fp); sd->load_file = false; /* don't load this file again */ }
static emacs_value module_vec_get (emacs_env *env, emacs_value vec, ptrdiff_t i) { MODULE_FUNCTION_BEGIN (module_nil); Lisp_Object lvec = value_to_lisp (vec); CHECK_VECTOR (lvec); CHECK_RANGED_INTEGER (make_number (i), 0, ASIZE (lvec) - 1); return lisp_to_value (AREF (lvec, i)); }