int SLang_pop_complex (double *r, double *i) { double *c; switch (SLang_peek_at_stack ()) { case SLANG_COMPLEX_TYPE: if (-1 == SLclass_pop_ptr_obj (SLANG_COMPLEX_TYPE, VOID_STAR_STAR(&c))) return -1; *r = c[0]; *i = c[1]; SLfree ((char *) c); break; default: *i = 0.0; if (-1 == SLang_pop_double (r)) return -1; break; case -1: return -1; } return 0; }
static int pop_index (unsigned int num_indices, SLang_MMT_Type **mmt, SLang_Assoc_Array_Type **a, SLstr_Type **str, unsigned long *hashp) { /* if (NULL == (*mmt = SLang_pop_mmt (SLANG_ASSOC_TYPE))) */ if (-1 == SLclass_pop_ptr_obj (SLANG_ASSOC_TYPE, (VOID_STAR *) mmt)) { *a = NULL; *str = NULL; return -1; } if ((num_indices != 1) || (-1 == SLang_pop_slstring (str))) { _pSLang_verror (SL_NOT_IMPLEMENTED, "Assoc_Type arrays require a single string index"); SLang_free_mmt (*mmt); *mmt = NULL; *a = NULL; *str = NULL; return -1; } /* *a = (SLang_Assoc_Array_Type *) SLang_object_from_mmt (*mmt); */ *a = (SLang_Assoc_Array_Type *) (*mmt)->user_data; *hashp = _pSLstring_get_hash (*str); return 0; }
static int pop_list (SLang_List_Type **list) { if (-1 == SLclass_pop_ptr_obj (SLANG_LIST_TYPE, (VOID_STAR *) list)) { *list = NULL; return -1; } return 0; }
static SLang_IStruct_Field_Type *istruct_pop_field (char *name, int no_readonly, VOID_STAR *addr) { _SLang_IStruct_Type *s; SLang_IStruct_Field_Type *f; char *struct_addr; /* Note: There is no need to free this object */ if (-1 == SLclass_pop_ptr_obj (SLANG_ISTRUCT_TYPE, (VOID_STAR *) &s)) return NULL; if (NULL == (struct_addr = *(char **)s->addr)) { SLang_verror (SL_INTRINSIC_ERROR, "%s is NULL. Unable to access field", s->name); return NULL; } f = s->fields; while (f->field_name != NULL) { /* Since both these are slstrings, just test pointers */ if (f->field_name != name) { f++; continue; } if (no_readonly && f->read_only) { SLang_verror (SL_READONLY_ERROR, "%s.%s is read-only", s->name, name); return NULL; } *addr = (VOID_STAR) (struct_addr + f->offset); return f; } SLang_verror (SL_TYPE_MISMATCH, "%s has no field called %s", s->name, name); return NULL; }
static int istruct_pop (unsigned char type, VOID_STAR ptr) { return SLclass_pop_ptr_obj (type, (VOID_STAR *)ptr); }
int SLang_pop_bstring (SLang_BString_Type **b) { return SLclass_pop_ptr_obj (SLANG_BSTRING_TYPE, (VOID_STAR *)b); }
static int pop_test_type (Test_Type **tp) { return SLclass_pop_ptr_obj (Test_Type_Id, (VOID_STAR *)tp); }
static int istruct_pop (SLtype type, VOID_STAR ptr) { return SLclass_pop_ptr_obj (type, (VOID_STAR *)ptr); }
int SLfile_pop_fd (SLFile_FD_Type **f) { return SLclass_pop_ptr_obj (SLANG_FILE_FD_TYPE, (VOID_STAR *) f); }
int SLang_pop_ref (SLang_Ref_Type **ref) { return SLclass_pop_ptr_obj (SLANG_REF_TYPE, (VOID_STAR *)ref); }
int SLang_pop_slstring (char **s) /*{{{*/ { return SLclass_pop_ptr_obj (SLANG_STRING_TYPE, (VOID_STAR *)s); }