Пример #1
0
/* After this call, the stack will contain an Any_Type object */
static int anytype_push (SLtype type, VOID_STAR ptr)
{
   SLang_Any_Type *obj;

   /* Push the object onto the stack, then pop it back off into our anytype
    * container.  That way, any memory managing associated with the type
    * will be performed automatically.  Another way to think of it is that
    * pushing an Any_Type onto the stack will create another copy of the
    * object represented by it.
    */
   if (-1 == _pSLpush_slang_obj (*(SLang_Object_Type **)ptr))
     return -1;

   if (-1 == SLang_pop_anytype (&obj))
     return -1;

   /* There is no need to reference count the anytype objects since every
    * push results in a new anytype container.
    */
   if (-1 == SLclass_push_ptr_obj (type, (VOID_STAR) obj))
     {
	SLang_free_anytype (obj);
	return -1;
     }

   return 0;
}
Пример #2
0
static int push_test_type (Test_Type *t)
{
   t->num_refs++;
   if (0 == SLclass_push_ptr_obj (Test_Type_Id, (VOID_STAR) t))
     return 0;
   t->num_refs--;
   return -1;
}
Пример #3
0
int _pSLang_push_slstring (char *s)
{
   if (0 == SLclass_push_ptr_obj (SLANG_STRING_TYPE, (VOID_STAR)s))
     return 0;

   SLang_free_slstring (s);
   return -1;
}
Пример #4
0
int SLang_push_ref (SLang_Ref_Type *ref)
{
   ref->num_refs++;
   if (0 == SLclass_push_ptr_obj (SLANG_REF_TYPE, (VOID_STAR) ref))
     return 0;
   ref->num_refs--;
   return -1;
}
Пример #5
0
static int chksum_push (Chksum_Object_Type *obj)
{
   obj->numrefs++;

   if (0 == SLclass_push_ptr_obj (Chksum_Type_Id, (VOID_STAR)obj))
     return 0;

   obj->numrefs--;
   return -1;
}
Пример #6
0
static int istruct_push (unsigned char type, VOID_STAR ptr)
{
   _SLang_IStruct_Type *s;

   s = *(_SLang_IStruct_Type **) ptr;
   if ((s == NULL) 
       || (s->addr == NULL)
       || (*(char **) s->addr == NULL))
     return SLang_push_null ();

   return SLclass_push_ptr_obj (type, (VOID_STAR) s);
}
Пример #7
0
int SLang_push_bstring (SLang_BString_Type *b)
{
   if (b == NULL)
     return SLang_push_null ();

   b->num_refs += 1;

   if (0 == SLclass_push_ptr_obj (SLANG_BSTRING_TYPE, (VOID_STAR)b))
     return 0;

   b->num_refs -= 1;
   return -1;
}
Пример #8
0
int SLfile_push_fd (SLFile_FD_Type *f)
{
   if (f == NULL)
     return SLang_push_null ();

   f->num_refs += 1;

   if (0 == SLclass_push_ptr_obj (SLANG_FILE_FD_TYPE, (VOID_STAR) f))
     return 0;

   f->num_refs -= 1;

   return -1;
}
Пример #9
0
static int push_list (SLang_List_Type *list, int free_flag)
{
   /* SLclass_push_ptr_obj does not do memory management */
   if (-1 == SLclass_push_ptr_obj (SLANG_LIST_TYPE, (VOID_STAR)list))
     {
	if (free_flag) free_list (list);
	return -1;
     }

   if (free_flag == 0)
     list->ref_count++;

   return 0;
}
Пример #10
0
int SLang_push_complex (double r, double i)
{
   double *c;

   c = (double *) SLmalloc (2 * sizeof (double));
   if (c == NULL)
     return -1;

   c[0] = r;
   c[1] = i;

   if (-1 == SLclass_push_ptr_obj (SLANG_COMPLEX_TYPE, (VOID_STAR) c))
     {
	SLfree ((char *) c);
	return -1;
     }
   return 0;
}
Пример #11
0
/* NULL type */
int SLang_push_null (void)
{
   return SLclass_push_ptr_obj (SLANG_NULL_TYPE, NULL);
}