extern CAMLprim value kc_abort_tran(value caml_db) { CAMLparam1(caml_db); KCDB* db = get_db(caml_db); if (! kcdbendtran(db, 0)) { const char *error = kcdbemsg(db); RAISE(error); } CAMLreturn(Val_unit); }
T MP_muli(T z, T x, long y) { assert(x); assert(z); if (-BASE < y && y < BASE) { int sx = sign(x), sy = y < 0; if (sx) { XP_neg(nbytes, tmp[0], x, 1); x = tmp[0]; x[nbytes-1] &= msb; } XP_product(nbytes, z, x, sy ? -y : y); if (sx != sy) XP_neg(nbytes, z, x, 1); z[nbytes-1] &= msb; if (sx == sy && sign(z)) RAISE(MP_Overflow); if (nbits < 8 && (y < -(1<<(nbits-1)) || y >= (1<<(nbits-1)))) RAISE(MP_Overflow); } else if (apply(MP_mul, z, x, y)) RAISE(MP_Overflow); return z; }
extern CAMLprim value kc_begin_tran_sync(value caml_db) { CAMLparam1(caml_db); KCDB* db = get_db(caml_db); if (! kcdbbegintran(db, 1)) { const char *error = kcdbemsg(db); RAISE(error); } CAMLreturn(Val_unit); }
void ImageAPI::setBrightness(double n) { if (!checkHaveDocument()) RAISE("No document open"); if (item == nullptr) return ; if (! item->asImageFrame()) { RAISE("Specified item not an image frame."); return; } ImageEffect ef; ef.effectCode = ScImage::EF_BRIGHTNESS; ScTextStream fp(&ef.effectParameters, QIODevice::WriteOnly); fp << n; item->effectsInUse.append(ef); item->pixm.applyEffect(item->effectsInUse, ScCore->primaryMainWindow()->doc->PageColors, false); ScCore->primaryMainWindow()->doc->updatePic(); }
// Instantiate a File with a filename iridium_method(File, initialize) { object self = local(self); object filename = local(filename); object mode = local(mode); FILE * f = fopen(C_STRING(context, filename), C_STRING(context, mode)); send(self, "__set__", L_ATOM(filename), filename); send(self, "__set__", L_ATOM(mode), mode); if (NULL == f) { RAISE(send(CLASS(FileNotFoundError), "new", filename)); } internal_set_attribute(self, L_ATOM(FILE), f); return NIL; }
static void read_map(JSONSource* self, rich_Sink* to) { Input* in = self->in; call(to, sink, RICH_MAP, NULL); bool first = true; for (;;) { int ch = skip_whitespace(in); if (ch == '}') break; if (first) { first = false; } else { if (ch != ',') RAISE(MALFORMED); ch = skip_whitespace(in); } if (ch != '"') RAISE(MALFORMED); read_string(self); call(to, sink, RICH_KEY, &self->sval); ch = skip_whitespace(in); if (ch != ':') RAISE(MALFORMED); read_value(self, to); } call(to, sink, RICH_ENDMAP, NULL); }
/********************************************************** * Resets the target CPU by using the AIRCR register. * The target will be halted immediately when coming * out of reset. Does not reset the debug interface. **********************************************************/ void resetAndHaltTarget(void) { uint32_t dhcsr; int timeout = DEBUG_EVENT_TIMEOUT; /* Halt target first. This is necessary before setting * the VECTRESET bit */ haltTarget(); /* Set halt-on-reset bit */ writeMem((uint32_t)&(CoreDebug->DEMCR), CoreDebug_DEMCR_VC_CORERESET_Msk); /* Clear exception state and reset target */ writeAP(AP_TAR, (uint32_t)&(SCB->AIRCR)); writeAP(AP_DRW, (0x05FA << SCB_AIRCR_VECTKEY_Pos) | SCB_AIRCR_VECTCLRACTIVE_Msk | SCB_AIRCR_VECTRESET_Msk); /* Wait for target to reset */ do { delayUs(10); timeout--; dhcsr = readMem((uint32_t)&(CoreDebug->DHCSR)); } while ( dhcsr & CoreDebug_DHCSR_S_RESET_ST_Msk ); /* Check if we timed out */ dhcsr = readMem((uint32_t)&(CoreDebug->DHCSR)); if ( dhcsr & CoreDebug_DHCSR_S_RESET_ST_Msk ) { RAISE(SWD_ERROR_TIMEOUT_WAITING_RESET); } /* Verify that target is halted */ if ( !(dhcsr & CoreDebug_DHCSR_S_HALT_Msk) ) { RAISE(SWD_ERROR_TARGET_NOT_HALTED); } }
static PyObject* movie_get_busy (PyObject* self) { SMPEG* movie; if (!SDL_WasInit (SDL_INIT_VIDEO)) return RAISE (PyExc_SDLError, "cannot convert without pygame.display initialized"); movie = PyMovie_AsSMPEG (self); return PyInt_FromLong (SMPEG_status (movie) == SMPEG_PLAYING); }
void *Mem_alloc(long nbytes, const char *file, int line) { void *ptr; if (nbytes <= 0) { if (file == NULL) RAISE(Mem_Failed); else Except_raise(&Mem_Failed, file, line); } ptr = malloc(nbytes); if (ptr == NULL) { if (file == NULL) { RAISE(Mem_Failed); } else { Except_raise(&Mem_Failed, file, line); } } alt++; return ptr; }
void *Mem_alloc(long nbytes, const char *file, int line) { void *ptr; assert(nbytes > 0); ptr = malloc(nbytes); if (ptr == NULL) { if (file == NULL) RAISE(Mem_Failed); else Except_raise(&Mem_Failed, file, line); } return ptr; }
static PyObject* cd_get_track_audio (PyObject* self, PyObject* args) { int cd_id = PyCD_AsID (self); SDL_CD* cdrom = cdrom_drivedata[cd_id]; int track; if (!PyArg_ParseTuple (args, "i", &track)) { return NULL; } CDROM_INIT_CHECK (); if (!cdrom) { return RAISE (PyExc_SDLError, "CD drive not initialized"); } SDL_CDStatus (cdrom); if (track < 0 || track >= cdrom->numtracks) { return RAISE (PyExc_IndexError, "Invalid track number"); } return PyInt_FromLong (cdrom->track[track].type == SDL_AUDIO_TRACK); }
static PyObject* cd_get_track_start (PyObject* self, PyObject* args) { int cd_id = PyCD_AsID (self); SDL_CD* cdrom = cdrom_drivedata[cd_id]; int track; if (!PyArg_ParseTuple (args, "i", &track)) { return NULL; } CDROM_INIT_CHECK (); if (!cdrom) { return RAISE (PyExc_SDLError, "CD drive not initialized"); } SDL_CDStatus (cdrom); if (track < 0 || track >= cdrom->numtracks) { return RAISE (PyExc_IndexError, "Invalid track number"); } return PyFloat_FromDouble (cdrom->track[track].offset / (double) CD_FPS); }
void DocumentAPI::editMasterPage(QString name) { if (!check()) return; const QMap<QString,int>& masterNames(ScCore->primaryMainWindow()->doc->MasterNames); const QMap<QString,int>::const_iterator it(masterNames.find(name)); if (it == masterNames.constEnd()) { RAISE("Master page not found"); return; } ScCore->primaryMainWindow()->view->showMasterPage(*it); }
/* 04/07/10 returns selection if is not name specified pv */ PageItem* GetUniqueItem(QString name) { if (name.length()==0) if (ScCore->primaryMainWindow()->doc->m_Selection->count() != 0) return ScCore->primaryMainWindow()->doc->m_Selection->itemAt(0); else { RAISE("Cannot use empty string for object name when there is no selection"); return NULL; } else return getPageItemByName(name); }
static PyObject* joy_get_numballs (PyObject* self) { int joy_id = PyJoystick_AsID (self); SDL_Joystick* joy = joystick_stickdata[joy_id]; JOYSTICK_INIT_CHECK (); if (!joy) { return RAISE (PyExc_SDLError, "Joystick not initialized"); } return PyInt_FromLong (SDL_JoystickNumBalls (joy)); }
/* * Known issues: since moving in the playlist using playlist_Next * or playlist_Prev implies starting to play items, the a_position * argument will be only honored for the 1st item in the list. * * XXX:FIXME split moving in the playlist and playing items two * different actions or make playlist_<Next|Prev> accept a time * value to start to play from. */ void mediacontrol_start( mediacontrol_Instance *self, const mediacontrol_Position * a_position, mediacontrol_Exception *exception ) { libvlc_media_t * p_media; char * psz_name; libvlc_exception_t ex; mediacontrol_exception_init( exception ); libvlc_exception_init( &ex ); p_media = libvlc_media_player_get_media( self->p_media_player, &ex ); HANDLE_LIBVLC_EXCEPTION_VOID( &ex ); if ( ! p_media ) { /* No media was defined. */ RAISE( mediacontrol_PlaylistException, "No defined media." ); } else { /* A media was defined. Get its mrl to reuse it, but reset the options (because start-time may have been set on the previous invocation */ psz_name = libvlc_media_get_mrl( p_media, &ex ); HANDLE_LIBVLC_EXCEPTION_VOID( &ex ); /* Create a new media */ p_media = libvlc_media_new( self->p_instance, psz_name, &ex ); HANDLE_LIBVLC_EXCEPTION_VOID( &ex ); if( a_position->value ) { char * psz_from; libvlc_time_t i_from; /* A start position was specified. Add it to media options */ psz_from = ( char * )malloc( 20 * sizeof( char ) ); i_from = private_mediacontrol_position2microsecond( self->p_media_player, a_position ) / 1000000; snprintf( psz_from, 20, "start-time=%"PRId64, i_from ); libvlc_media_add_option( p_media, psz_from, &ex ); HANDLE_LIBVLC_EXCEPTION_VOID( &ex ); } libvlc_media_player_set_media( self->p_media_player, p_media, &ex ); HANDLE_LIBVLC_EXCEPTION_VOID( &ex ); libvlc_media_player_play( self->p_media_player, &ex ); HANDLE_LIBVLC_EXCEPTION_VOID( &ex ); } }
obj_t *apply_procedure(obj_t *proc, obj_t *args) { PUSH_ROOT(proc); PUSH_ROOT(args); AUTO_ROOT(body, procedure_body(proc)); if (procedure_is_C(proc)) { obj_t *env = F_ENV; if (!procedure_is_special_form(proc)) env = procedure_env(proc); GOTO_FRAME(make_short_frame, (C_procedure_t *)body, args, env); } AUTO_ROOT(new_env, make_env(procedure_env(proc))); AUTO_ROOT(formals, procedure_args(proc)); AUTO_ROOT(actuals, args); while (!is_null(formals) || !is_null(actuals)) { if (is_null(formals)) { printf_unchecked("calling %O\n", proc); RAISE("too many args"); } obj_t *formal, *actual; if (is_pair(formals)) { if (is_null(actuals)) { printf_unchecked("proc=%O\n", proc); RAISE("not enough args"); } formal = pair_car(formals); formals = pair_cdr(formals); actual = pair_car(actuals); actuals = pair_cdr(actuals); } else { formal = formals; actual = actuals; formals = actuals = NIL; } env_bind(new_env, formal, BT_LEXICAL, M_MUTABLE, actual); } GOTO(b_eval_sequence, body, new_env); }
PyObject * cpu_set_gpreg(JitCpu *self, PyObject *args) { PyObject *dict; PyObject *d_key, *d_value = NULL; Py_ssize_t pos = 0; uint64_t val; unsigned int i; if (!PyArg_ParseTuple(args, "O", &dict)) return NULL; if(!PyDict_Check(dict)) RAISE(PyExc_TypeError, "arg must be dict"); while(PyDict_Next(dict, &pos, &d_key, &d_value)) { int found = 0; if(!PyString_Check(d_key)) RAISE(PyExc_TypeError, "key must be str"); PyGetInt(d_value, val); for (i=0; i < sizeof(gpreg_dict)/sizeof(reg_dict); i++){ if (strcmp(PyString_AsString(d_key), gpreg_dict[i].name)) continue; *((uint32_t*)(((char*)(self->cpu)) + gpreg_dict[i].offset)) = val; found = 1; break; } if (found) continue; fprintf(stderr, "unknown key: %s\n", PyString_AsString(d_key)); RAISE(PyExc_ValueError, "unknown reg"); } Py_INCREF(Py_None); return Py_None; }
void PrinterAPI::setPages(QList<QVariant> list) { this->pages.clear(); for(int i=0; i<list.count(); ++i) { if(list[i].toInt() > ScCore->primaryMainWindow()->doc->Pages->count()) { qDebug()<<"trying to raise an exception"; RAISE("pages value out of range."); } else this->pages.append(list[i].toInt()); } }
void *Mem_copy( void* destination, void* source, long nbytes, const char *file, int line ) { assert(nbytes > 0); void *ptr; ptr = memcpy( destination, source, nbytes ); if (ptr == NULL) { if (file == NULL) RAISE(Mem_Failed); else Except_raise(&Mem_Failed, file, line); } return ptr; }
void *Mem_resize(void *ptr, long nbytes, const char *file, int line) { assert( ptr ); assert( nbytes > 0 ); ptr = realloc( ptr, nbytes ); if( ptr == NULL ) { if (file == NULL) RAISE(Mem_Failed); else Except_raise(&Mem_Failed, file, line); } return ptr; }
int pthd4exc_cancel( pthread_t thread ) { int e; if ( pthread_once( &pthd4exc_is_initialized, pthd4exc_lib_init ) != SUCCESS ) RAISE(pthread_use_error_e); e = pthd4_cancel(thread); if (e != SUCCESS) { pthd4_map_errno_to_exc(errno); } return e; }
static PyObject* movie_rewind (PyObject* self) { SMPEG* movie = PyMovie_AsSMPEG (self); if (!SDL_WasInit (SDL_INIT_VIDEO)) return RAISE (PyExc_SDLError, "cannot convert without pygame.display initialized"); Py_BEGIN_ALLOW_THREADS; SMPEG_rewind (movie); Py_END_ALLOW_THREADS; Py_RETURN_NONE; }
/* * raises: EOF_ERROR */ static void cmpdi_read_i(InStream *is, uchar *b, int len) { CompoundInStream *cis = is->d.cis; off_t start = is_pos(is); if ((start + len) > cis->length) { RAISE(EOF_ERROR, "Tried to read past end of file. File length is " "<%"F_OFF_T_PFX"d> and tried to read to <%"F_OFF_T_PFX"d>", cis->length, start + len); } is_seek(cis->sub, cis->offset + start); is_read_bytes(cis->sub, b, len); }
static void cmpd_close_i(Store *store) { CompoundStore *cmpd = store->dir.cmpd; if (cmpd->stream == NULL) { RAISE(IO_ERROR, "Tried to close already closed compound store"); } h_destroy(cmpd->entries); is_close(cmpd->stream); cmpd->stream = NULL; free(store->dir.cmpd); store_destroy(store); }
int pthd4exc_setprio( pthread_t thread, int priority) { int e; if ( pthread_once( &pthd4exc_is_initialized, pthd4exc_lib_init ) != SUCCESS ) RAISE(pthread_use_error_e); e = pthd4_setprio( thread, priority ); if (e == -1) { pthd4_map_errno_to_exc(errno); } return e; }
int pthd4exc_signal_to_cancel_np(sigset_t * sigset, pthread_t * thread) { int e; if ( pthread_once( &pthd4exc_is_initialized, pthd4exc_lib_init ) != SUCCESS ) RAISE(pthread_use_error_e); e = pthd4_signal_to_cancel_np(sigset, thread); if (e != SUCCESS) { pthd4_map_errno_to_exc(errno); } return e; }
int pthd4exc_get_expiration_np(struct timespec * delta, struct timespec * abstime) { int e; if ( pthread_once( &pthd4exc_is_initialized, pthd4exc_lib_init ) != SUCCESS ) RAISE(pthread_use_error_e); e = pthd4_get_expiration_np(delta, abstime); if (e != SUCCESS) { pthd4_map_errno_to_exc(errno); } return e; }
int pthd4exc_delay_np(struct timespec * delay) { int e; if ( pthread_once( &pthd4exc_is_initialized, pthd4exc_lib_init ) != SUCCESS ) RAISE(pthread_use_error_e); e = pthd4_delay_np(delay); if (e != SUCCESS) { pthd4_map_errno_to_exc(errno); } return e; }
int pthd4exc_getscheduler( pthread_t thread ) { int e; if ( pthread_once( &pthd4exc_is_initialized, pthd4exc_lib_init ) != SUCCESS ) RAISE(pthread_use_error_e); e = pthd4_getscheduler( thread ); if (e == -1) { pthd4_map_errno_to_exc(errno); } return e; }