Example #1
0
File: sltest.c Project: parke/slang
static int test_type_sput (SLtype type, SLFUTURE_CONST char *name)
{
   Test_Type *t;
   int status;

   (void) type;
   if (-1 == pop_test_type (&t))
     return -1;

   status = -1;
   if (0 == strcmp (name, "field1"))
     status = SLang_pop_int (&t->field1);
   else if (0 == strcmp (name, "field2"))
     status = SLang_pop_int (&t->field2);
   else if (0 == strcmp (name, "any"))
     {
	SLang_Any_Type *any;
	if (0 == (status = SLang_pop_anytype (&any)))
	  {
	     SLang_free_anytype (t->any);
	     t->any = any;
	  }
     }
   else
     SLang_verror (SL_INVALID_PARM,
		   "Test_Type.%s is invalid", name);

   free_test_type (t);
   return status;
}
Example #2
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;
}
Example #3
0
/* AnyType */
int _pSLanytype_typecast (SLtype a_type, VOID_STAR ap, unsigned int na,
			 SLtype b_type, VOID_STAR bp)
{
   SLang_Class_Type *cl;
   SLang_Any_Type **any;
   unsigned int i;
   unsigned int sizeof_type;

   (void) b_type;

   any = (SLang_Any_Type **) bp;
   
   cl = _pSLclass_get_class (a_type);
   sizeof_type = cl->cl_sizeof_type;

   for (i = 0; i < na; i++)
     {
	if ((-1 == (*cl->cl_apush) (a_type, ap))
	    || (-1 == SLang_pop_anytype (&any[i])))
	  {
	     while (i != 0)
	       {
		  i--;
		  SLang_free_anytype (any[i]);
		  any[i] = NULL;
	       }
	     return -1;
	  }
	ap = (VOID_STAR)((char *)ap + sizeof_type);
     }

   return 1;
}
Example #4
0
static void free_csv_type (CSV_Type *csv)
{
   if (csv == NULL)
     return;
   if (csv->callback_data != NULL) SLang_free_anytype (csv->callback_data);
   if (csv->read_callback != NULL) SLang_free_function (csv->read_callback);
   SLfree ((char *)csv);
}
Example #5
0
static void free_cb_info (Rline_CB_Type *cb)
{
    if (cb == NULL)
        return;
    if (cb->mmt != NULL) SLang_free_mmt (cb->mmt);
    if (cb->update_hook != NULL) SLang_free_function (cb->update_hook);
    if (cb->clear_cb != NULL) SLang_free_function (cb->clear_cb);
    if (cb->preread_cb != NULL) SLang_free_function (cb->preread_cb);
    if (cb->postread_cb != NULL) SLang_free_function (cb->postread_cb);
    if (cb->width_cb != NULL) SLang_free_function (cb->width_cb);
    if (cb->cd != NULL) SLang_free_anytype (cb->cd);
    SLfree ((char *)cb);
}
Example #6
0
File: blocal.c Project: hankem/jed
void jed_set_blocal_var (char *name) /*{{{*/
{
   Jed_BLocal_Type *lv;

   lv = find_blocal_var (name, 1);
   if (lv == NULL)
     return;

   SLang_free_anytype (lv->value);
   lv->value = NULL;

   (void) SLang_pop_anytype (&lv->value);
}
Example #7
0
File: sltest.c Project: parke/slang
static void free_test_type (Test_Type *t)
{
   if (t == NULL)
     return;

   if (t->num_refs > 1)
     {
	t->num_refs -= 1;
	return;
     }
   if (t->any != NULL)
     SLang_free_anytype (t->any);
   SLfree ((char *)t);
}
Example #8
0
File: blocal.c Project: hankem/jed
void jed_delete_blocal_vars (Jed_BLocal_Table_Type *table) /*{{{*/
{
   Jed_BLocal_Type *lv, *lv_max;
   Jed_BLocal_Table_Type *next;

   while (table != NULL)
     {
	lv = table->local_vars;
	lv_max = lv + table->num;

	while (lv < lv_max)
	  {
	     SLang_free_anytype (lv->value);
	     SLang_free_slstring (lv->name);
	     lv++;
	  }

	next = table->next;
	SLfree ((char *) table);
	table = next;
     }
}