本文整理汇总了C++中scm_from_int函数的典型用法代码示例。如果您正苦于以下问题:C++ scm_from_int函数的具体用法?C++ scm_from_int怎么用?C++ scm_from_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了scm_from_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: status_list
SCM status_list (SCM board_smob) {
struct board *board;
struct cell *cell;
int i;
int j;
SCM cell_smob;
SCM list;
SCM row;
scm_assert_smob_type(board_tag, board_smob);
board = (struct board *) SCM_SMOB_DATA(board_smob);
list = SCM_EOL;
for (i = board->height - 1; i >= 0; i--) {
row = SCM_EOL;
for (j = board->width - 1; j >= 0; j--) {
cell_smob = scm_list_ref(scm_list_ref(board->cell_list, scm_from_int(j)), scm_from_int(i));
cell = (struct cell *) SCM_SMOB_DATA(cell_smob);
row = scm_cons(get_status(cell_smob), row);
}
list = scm_cons(row, list);
}
return list;
}
示例2: g_rc_component_dialog_attributes
/*! \brief read the configuration string list for the component dialog
* \par Function Description
* This function reads the string list from the component-dialog-attributes
* configuration parameter and converts the list into a GList.
* The GList is stored in the global default_component_select_attrlist variable.
*/
SCM g_rc_component_dialog_attributes(SCM stringlist)
{
int length, i;
GList *list=NULL;
gchar *attr;
SCM_ASSERT(scm_list_p(stringlist), stringlist, SCM_ARG1, "scm_is_list failed");
length = scm_ilength(stringlist);
/* If the command is called multiple times, remove the old list before
recreating it */
g_list_foreach(default_component_select_attrlist, (GFunc)g_free, NULL);
g_list_free(default_component_select_attrlist);
/* convert the scm list into a GList */
for (i=0; i < length; i++) {
SCM_ASSERT(scm_is_string(scm_list_ref(stringlist, scm_from_int(i))),
scm_list_ref(stringlist, scm_from_int(i)), SCM_ARG1,
"list element is not a string");
attr = g_strdup(SCM_STRING_CHARS(scm_list_ref(stringlist, scm_from_int(i))));
list = g_list_prepend(list, attr);
}
default_component_select_attrlist = g_list_reverse(list);
return SCM_BOOL_T;
}
示例3: gdbscm_memory_port_end_input
static void
gdbscm_memory_port_end_input (SCM port, int offset)
{
scm_t_port *pt = SCM_PTAB_ENTRY (port);
ioscm_memory_port *iomem = (ioscm_memory_port *) SCM_STREAM (port);
size_t remaining = pt->read_end - pt->read_pos;
/* Note: Use of "int offset" is specified by Guile ports API. */
if ((offset < 0 && remaining + offset > remaining)
|| (offset > 0 && remaining + offset < remaining))
{
gdbscm_out_of_range_error (FUNC_NAME, 0, scm_from_int (offset),
_("overflow in offset calculation"));
}
offset += remaining;
if (offset > 0)
{
pt->read_pos = pt->read_end;
/* Throw error if unread-char used at beginning of file
then attempting to write. Seems correct. */
if (!ioscm_lseek_address (iomem, -offset, SEEK_CUR))
{
gdbscm_out_of_range_error (FUNC_NAME, 0, scm_from_int (offset),
_("bad offset"));
}
}
pt->rw_active = SCM_PORT_NEITHER;
}
示例4: weechat_guile_alist_to_hashtable
struct t_hashtable *
weechat_guile_alist_to_hashtable (SCM alist, int hashtable_size)
{
struct t_hashtable *hashtable;
int length, i;
SCM pair;
hashtable = weechat_hashtable_new (hashtable_size,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (!hashtable)
return NULL;
length = scm_to_int (scm_length (alist));
for (i = 0; i < length; i++)
{
pair = scm_list_ref (alist, scm_from_int (i));
weechat_hashtable_set (hashtable,
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (0))),
scm_i_string_chars (scm_list_ref (pair,
scm_from_int (1))));
}
return hashtable;
}
示例5: is
/*
* Returns a list with coords of the ends of the given pin <B>object</B>.
The list is ( (x0 y0) (x1 y1) ), where the beginning is at (x0,y0) and the end at (x1,y1).
The active connection end of the pin is the beginning, so this function cares about the whichend property of the pin object. If whichend is 1, then it has to reverse the ends.
*/
SCM g_get_pin_ends(SCM object)
{
TOPLEVEL *toplevel;
OBJECT *o_current;
SCM coord1 = SCM_EOL;
SCM coord2 = SCM_EOL;
SCM coords = SCM_EOL;
/* Get toplevel and o_current */
SCM_ASSERT (g_get_data_from_object_smob (object, &toplevel, &o_current),
object, SCM_ARG1, "get-pin-ends");
/* Check that it is a pin object */
SCM_ASSERT (o_current != NULL,
object, SCM_ARG1, "get-pin-ends");
SCM_ASSERT (o_current->type == OBJ_PIN,
object, SCM_ARG1, "get-pin-ends");
SCM_ASSERT (o_current->line != NULL,
object, SCM_ARG1, "get-pin-ends");
coord1 = scm_cons(scm_from_int(o_current->line->x[0]),
scm_from_int(o_current->line->y[0]));
coord2 = scm_cons(scm_from_int(o_current->line->x[1]),
scm_from_int(o_current->line->y[1]));
if (o_current->whichend == 0) {
coords = scm_cons(coord1, scm_list(coord2));
} else {
coords = scm_cons(coord2, scm_list(coord1));
}
return coords;
}
示例6: test_can_convert_to_slist__list_of_integers
int test_can_convert_to_slist__list_of_integers (void)
{
SCM str_list = scm_list_2(scm_from_int(1), scm_from_int(2));
int ret = _scm_can_convert_to_slist (str_list);
printf("test that _scm_can_convert_to_slist returns 0 when passed a list of integers: %d\n", ret == 0);
return ret == 0;
}
示例7: test_scm_convert_to_slist__list_of_integers
int test_scm_convert_to_slist__list_of_integers (void)
{
SCM str_list = scm_list_2(scm_from_int(1), scm_from_int(2));
struct curl_slist *ret = _scm_convert_to_slist (str_list);
printf("test that _scm_convert_to_slist returns NULL when passed a list of integers: %d\n", ret == NULL);
return ret == NULL;
}
示例8: game_process_event
static void
game_process_event (Game *game)
{
static ALLEGRO_EVENT event;
al_wait_for_event(game->event_queue, &event);
if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
{
game->running = false;
}
else if (event.type == ALLEGRO_EVENT_TIMER)
{
game_update (game);
}
else if (event.type == ALLEGRO_EVENT_KEY_UP)
{
if (scm_is_true (game->on_key_released))
{
scm_call_1 (game->on_key_released, scm_from_int (event.keyboard.keycode));
}
}
else if (event.type == ALLEGRO_EVENT_KEY_DOWN)
{
if (scm_is_true (game->on_key_pressed))
{
scm_call_1 (game->on_key_pressed, scm_from_int (event.keyboard.keycode));
}
}
}
示例9: get_neighbors
SCM get_neighbors (SCM board_smob, SCM cell_smob) {
struct board *board;
struct cell *cell;
SCM list;
SCM neighbor;
int i;
int j;
int x;
int y;
scm_assert_smob_type(board_tag, board_smob);
scm_assert_smob_type(cell_tag, cell_smob);
board = (struct board *) SCM_SMOB_DATA(board_smob);
cell = (struct cell *) SCM_SMOB_DATA(cell_smob);
list = SCM_EOL;
for (i = -1; i < 2; i++) {
for (j = -1; j < 2; j++) {
if (i == 0 && j == 0) {
continue;
}
x = cell->x + i;
y = cell->y + j;
if (x >= 0 && x < board->width && y >= 0 && y < board->height) {
neighbor = scm_list_ref(scm_list_ref(board->cell_list, scm_from_int(y)), scm_from_int(x));
list = scm_cons(neighbor, list);
}
}
}
return list;
}
示例10: make_board
static SCM make_board (SCM s_width, SCM s_height) {
int i;
int j;
SCM smob;
struct board *board;
int width = scm_to_int(s_width);
int height = scm_to_int(s_height);
board = (struct board *) scm_gc_malloc(sizeof(struct board), "board");
board->width = width;
board->height = height;
board->update_func = SCM_BOOL_F;
board->cell_list = SCM_EOL;
for (i = height - 1; i >= 0; i--) {
SCM row = SCM_EOL;
for (j = width - 1; j >= 0; j--) {
SCM y_offset = scm_from_int(i);
SCM x_offset = scm_from_int(j);
row = scm_cons(make_cell(x_offset, y_offset, scm_from_int(0)), row);
}
board->cell_list = scm_cons(row, board->cell_list);
}
SCM_NEWSMOB(smob, board_tag, board);
return smob;
}
示例11: scm_ragnarok_epoll_wait
SCM scm_ragnarok_epoll_wait(SCM event_set ,SCM second ,SCM msecond)
#define FUNC_NAME "ragnarok-epoll-wait"
{
scm_rag_epoll_event_set *es = NULL;
int fd;
int op;
int count;
long s = 0L;
long ms = 0L;
SCM cons;
int nfds;
SCM ret = SCM_EOL;
SCM_ASSERT_EPOLL_EVENT_SET(event_set);
es = (scm_rag_epoll_event_set*)SCM_SMOB_DATA(event_set);
if(!SCM_UNBNDP(second))
{
SCM_VALIDATE_NUMBER(3 ,second);
s = (long)scm_to_long(second);
if(!SCM_UNBNDP(msecond))
{
SCM_VALIDATE_NUMBER(4 ,msecond);
ms = (long)scm_to_long(msecond);
}
ms += s*1000; // convert to mseconds since epoll_wait only accept msecond;
}
ms = ms ? ms : -1;
count = es->count;
if(!count)
goto end;
nfds = epoll_wait(es->epfd ,es->ee_set ,count ,ms);
if(nfds < 0)
{
RAG_ERROR1("epoll_wait" ,"epoll_wait error! errno shows %a~%",
RAG_ERR2STR(errno));
}
while(nfds > 0)
{
nfds--;
fd = es->ee_set[nfds].data.fd;
op = es->ee_set[nfds].events;
cons = scm_cons(scm_from_int(fd) ,scm_from_int(op));
ret = scm_cons(cons ,ret);
}
return ret;
end:
return SCM_EOL;
}
示例12: gucu_getyx
SCM
gucu_getyx (SCM win)
{
int y, x;
getyx (_scm_to_window (win), y, x);
return (scm_list_2 (scm_from_int (y), scm_from_int (x)));
}
示例13: gucu_getsyx
/* Get the location of the virtual screen cursor */
SCM
gucu_getsyx ()
{
int y = 0, x = 0;
getsyx (y, x);
return (scm_list_2 (scm_from_int (y), scm_from_int (x)));
}
示例14: gucu_getscrreg
/* Return the range of the lines in the scroll region */
SCM
gucu_getscrreg (SCM win)
{
int top, bottom;
wgetscrreg (_scm_to_window (win), &top, &bottom);
return (scm_list_2 (scm_from_int (top), scm_from_int (bottom)));
}
示例15: call_guile_buttonpress
bool call_guile_buttonpress(unsigned int button, bool ctrl, int x, int y) {
return scm_to_bool (scm_eval (scm_list_n (scm_from_locale_symbol ("on-button-press"),
scm_from_int(button),
scm_from_bool(ctrl),
scm_from_int(x),
scm_from_int(y),
SCM_UNDEFINED
), scm_interaction_environment()));
}