Example #1
0
File: alloc.c Project: FizzyP/julia
jl_tuple_t *jl_alloc_tuple_uninit(size_t n)
{
    if (n == 0) return jl_null;
#ifdef OVERLAP_TUPLE_LEN
    jl_tuple_t *jv = (jl_tuple_t*)newobj((jl_value_t*)jl_tuple_type, n);
#else
    jl_tuple_t *jv = (jl_tuple_t*)newobj((jl_value_t*)jl_tuple_type, n+1);
#endif
    jl_tuple_set_len_unsafe(jv, n);
    return jv;
}
Example #2
0
void
CmOutputDriver(void)
{
  struct objlist *graobj, *g2wobj;
  int id, g2wid, g2woid;
  N_VALUE *g2winst;
  int ret;
  struct savedstdio stdio;

  if (Menulock || Globallock)
    return;

  if (Menulocal.select_data && ! SetFileHidden())
    return;

  FileAutoScale();
  AdjustAxis();

  graobj = chkobject("gra");
  if (graobj == NULL)
    return;

  g2wobj = chkobject("gra2prn");
  if (g2wobj == NULL)
    return;

  g2wid = newobj(g2wobj);
  if (g2wid < 0)
    return;

  DriverDialog(&DlgDriver, g2wobj, g2wid);
  ret = DialogExecute(TopLevel, &DlgDriver);

  if (ret == IDOK) {
    SetStatusBar(_("Spawning external driver."));
    g2winst = chkobjinst(g2wobj, g2wid);
    _getobj(g2wobj, "oid", g2winst, &g2woid);
    id = newobj(graobj);
    init_graobj(graobj, id, "gra2prn", g2woid);
    ignorestdio(&stdio);
    draw_gra(graobj, id, _("Drawing."), TRUE);
    restorestdio(&stdio);
    delobj(graobj, id);
    ResetStatusBar();
  }
  delobj(g2wobj, g2wid);

  if (Menulocal.select_data) {
    FileWinUpdate(NgraphApp.FileWin.data.data, TRUE);
  }
}
Example #3
0
jl_struct_type_t *jl_new_uninitialized_struct_type(size_t nfields)
{
    return (jl_struct_type_t*)
        newobj((jl_type_t*)jl_struct_kind,
               NWORDS(sizeof(jl_struct_type_t) - sizeof(void*) +
                      (nfields-1)*sizeof(jl_fielddesc_t)));
}
Example #4
0
File: alloc.c Project: FizzyP/julia
jl_typector_t *jl_new_type_ctor(jl_tuple_t *params, jl_value_t *body)
{
    jl_typector_t *tc = (jl_typector_t*)newobj((jl_value_t*)jl_typector_type,2);
    tc->parameters = params;
    tc->body = body;
    return (jl_typector_t*)tc;
}
struct obj *
restobjchn(int fd)
{
	struct obj *otmp, *otmp2;
	struct obj *first = NULL;
	int xl;

	/* suppress "used before set" warning from lint */
	otmp2 = NULL;
	for (;;) {
		mread(fd, (char *)&xl, sizeof(xl));
		if (xl == -1)
			break;
		otmp = newobj(xl);
		if (!first)
			first = otmp;
		else
			otmp2->nobj = otmp;
		mread(fd, (char *)otmp, (unsigned)xl + sizeof(struct obj));
		if (!otmp->o_id) otmp->o_id = flags.ident++;
		otmp2 = otmp;
	}
	if (first && otmp2->nobj) {
		impossible("Restobjchn: error reading objchn.");
		otmp2->nobj = 0;
	}
	return (first);
}
Example #6
0
struct obj     *
restobjchn(int fd)
{
	struct obj     *otmp, *otmp2 = NULL;
	struct obj     *first = 0;
	int             xl;
	while (1) {
		mread(fd, &xl, sizeof(xl));
		if (xl == -1)
			break;
		otmp = newobj(xl);
		if (!first)
			first = otmp;
		else
			otmp2->nobj = otmp;
		mread(fd, otmp, (unsigned) xl + sizeof(struct obj));
		if (!otmp->o_id)
			otmp->o_id = flags.ident++;
		otmp2 = otmp;
	}
	if (first && otmp2->nobj) {
		impossible("Restobjchn: error reading objchn.");
		otmp2->nobj = 0;
	}
	return (first);
}
Example #7
0
File: alloc.c Project: Blisse/julia
jl_typector_t *jl_new_type_ctor(jl_svec_t *params, jl_value_t *body)
{
    jl_typector_t *tc = (jl_typector_t*)newobj((jl_value_t*)jl_typector_type,NWORDS(sizeof(jl_typector_t)));
    tc->parameters = params;
    tc->body = body;
    return (jl_typector_t*)tc;
}
Example #8
0
NODE *lkindof(NODE *args) {
    NODE *argcopy = args;
    NODE *val = UNBOUND;

    if (is_list(car(args))) {
        if (cdr(args) != NIL) {
            err_logo(TOO_MUCH, NIL); /* too many inputs */
        }
        args = car(args);
    }
    /* now args is always a list of objects */
    /* make sure they're all really objects */

    for (argcopy = args; (argcopy != NIL && NOT_THROWING); 
			 argcopy = cdr(argcopy)) {
        while (!is_object(car(argcopy)) && NOT_THROWING) {
            setcar(argcopy, err_logo(BAD_DATA, car(argcopy)));
        }
    }

    if (NOT_THROWING) {
        val = newobj();
        setparents(val, args);
    }

    return val;
}
Example #9
0
/* Creates and outputs an object whose parent is the Logo object.
 * @params - none
 */
NODE *lsomething(NODE *args) {
    NODE *val;

    val = newobj();
    setparents(val, cons(logo_object, NIL));
    return val;
}
Example #10
0
File: alloc.c Project: FizzyP/julia
jl_datatype_t *jl_new_uninitialized_datatype(size_t nfields)
{
    return (jl_datatype_t*)
        newobj((jl_value_t*)jl_datatype_type,
               NWORDS(sizeof(jl_datatype_t) - sizeof(void*) +
                      (nfields-1)*sizeof(jl_fielddesc_t)));
}
Example #11
0
// Note that this function updates len
static jl_value_t *jl_new_bits_internal(jl_value_t *dt, void *data, size_t *len)
{
    assert(jl_is_datatype(dt));
    jl_datatype_t *bt = (jl_datatype_t*)dt;
    size_t nb = jl_datatype_size(bt);
    if (nb == 0)
        return jl_new_struct_uninit(bt);
    *len = LLT_ALIGN(*len, bt->alignment);
    data = (char*)data + (*len);
    *len += nb;
    if (bt == jl_uint8_type)   return jl_box_uint8(*(uint8_t*)data);
    if (bt == jl_int64_type)   return jl_box_int64(*(int64_t*)data);
    if (bt == jl_bool_type)    return (*(int8_t*)data) ? jl_true:jl_false;
    if (bt == jl_int32_type)   return jl_box_int32(*(int32_t*)data);
    if (bt == jl_float64_type) return jl_box_float64(*(double*)data);

    jl_value_t *v = (jl_value_t*)newobj((jl_value_t*)bt, NWORDS(nb));
    switch (nb) {
    case  1: *(int8_t*)   jl_data_ptr(v) = *(int8_t*)data;    break;
    case  2: *(int16_t*)  jl_data_ptr(v) = *(int16_t*)data;   break;
    case  4: *(int32_t*)  jl_data_ptr(v) = *(int32_t*)data;   break;
    case  8: *(int64_t*)  jl_data_ptr(v) = *(int64_t*)data;   break;
    case 16: *(bits128_t*)jl_data_ptr(v) = *(bits128_t*)data; break;
    default: memcpy(jl_data_ptr(v), data, nb);
    }
    return v;
}
Example #12
0
jl_tuple_t *jl_alloc_tuple_uninit(size_t n)
{
    if (n == 0) return jl_null;
    jl_tuple_t *jv = (jl_tuple_t*)newobj((jl_type_t*)jl_tuple_type, n+1);
    jl_tuple_set_len_unsafe(jv, n);
    return jv;
}
Example #13
0
void
CmMergeOpen(void *w, gpointer client_data)
{
  struct objlist *obj;
  char *name = NULL;
  int id, ret;

  if (Menulock || Globallock)
    return;

  if ((obj = chkobject("merge")) == NULL)
    return;

  if (nGetOpenFileName(TopLevel, _("Add Merge file"), "gra", NULL, NULL, &name,
		       TRUE, Menulocal.changedirectory) != IDOK || ! name)
    return;

  id = newobj(obj);
  if (id >= 0) {
    changefilename(name);
    putobj(obj, "file", id, name);
    MergeDialog(NgraphApp.MergeWin.data.data, id, -1);
    ret = DialogExecute(TopLevel, &DlgMerge);
    if ((ret == IDDELETE) || (ret == IDCANCEL)) {
      delobj(obj, id);
    } else {
      set_graph_modified();
    }
  } else {
    g_free(name);
  }
  MergeWinUpdate(NgraphApp.MergeWin.data.data, TRUE);
}
Example #14
0
jl_tuple_t *jl_alloc_tuple_uninit(size_t n)
{
    if (n == 0) return jl_null;
    jl_tuple_t *jv = (jl_tuple_t*)newobj((jl_type_t*)jl_tuple_type, n+1);
    jv->length = n;
    return jv;
}
Example #15
0
NODE *loneof(NODE *args) {
    NODE *val = UNBOUND, *argcopy;

    if (!is_list(car(args))) {
        setcar(args, cons(car(args), NIL));
    }
    /* now the first arg is always a list of objects */

    /* make sure they're really objects */
    argcopy = car(args);
    while (argcopy != NIL && NOT_THROWING) {
        while (!is_object(car(argcopy)) && NOT_THROWING) {
            setcar(argcopy, err_logo(BAD_DATA, car(argcopy)));
        }
        argcopy = cdr(argcopy);
    }

    if (NOT_THROWING) {
        val = newobj();
        setparents(val, car(args));

        /* apply [[InitList] [Exist Output Self]] cdr(args) */
	return make_cont(withobject_continuation,
			 cons(val,
			      make_cont(begin_apply,
					cons(askexist,
					     cons(cons(cdr(args), NIL),
						  NIL)))));
    }

    return val;
}
Example #16
0
jl_struct_type_t *jl_new_struct_type(jl_sym_t *name, jl_tag_type_t *super,
                                     jl_tuple_t *parameters,
                                     jl_tuple_t *fnames, jl_tuple_t *ftypes)
{
    jl_typename_t *tn = jl_new_typename(name);
    JL_GC_PUSH(&tn);
    jl_struct_type_t *t = (jl_struct_type_t*)newobj((jl_type_t*)jl_struct_kind,
                                                    STRUCT_TYPE_NW);
    t->name = tn;
    t->name->primary = (jl_value_t*)t;
    t->super = super;
    t->parameters = parameters;
    t->names = fnames;
    t->types = ftypes;
    t->fptr = jl_f_ctor_trampoline;
    t->env = (jl_value_t*)t;
    t->linfo = NULL;
    t->ctor_factory = (jl_value_t*)jl_null;
    t->instance = NULL;
    if (!jl_is_leaf_type((jl_value_t*)t))
        t->uid = 0;
    else
        t->uid = jl_assign_type_uid();
    JL_GC_POP();
    return t;
}
Example #17
0
/*
 * Split obj so that it gets size gets reduced by num. The quantity num is
 * put in the object structure delivered by this call.  The returned object
 * has its wornmask cleared and is positioned just following the original
 * in the nobj chain (and nexthere chain when on the floor).
 */
struct obj *
splitobj(struct obj *obj, long int num)
{
    struct obj *otmp;

    if (obj->cobj || num <= 0L || obj->quan <= num)
        panic("splitobj");	/* can't split containers */
    otmp = newobj(obj->oxlth + obj->onamelth);
    *otmp = *obj;		/* copies whole structure */
    otmp->o_id = flags.ident++;
    if (!otmp->o_id) otmp->o_id = flags.ident++;	/* ident overflowed */
    otmp->timed = 0;	/* not timed, yet */
    otmp->lamplit = 0;	/* ditto */
    otmp->owornmask = 0L;	/* new object isn't worn */
    obj->quan -= num;
    obj->owt = weight(obj);
    otmp->quan = num;
    otmp->owt = weight(otmp);	/* -= obj->owt ? */
    obj->nobj = otmp;
    /* Only set nexthere when on the floor, nexthere is also used */
    /* as a back pointer to the container object when contained. */
    if (obj->where == OBJ_FLOOR)
        obj->nexthere = otmp;
    if (obj->oxlth)
        (void)memcpy((genericptr_t)otmp->oextra, (genericptr_t)obj->oextra,
                     obj->oxlth);
    if (obj->onamelth)
        (void)strncpy(ONAME(otmp), ONAME(obj), (int)obj->onamelth);
    if (obj->unpaid) splitbill(obj,otmp);
    if (obj->timed) obj_split_timers(obj, otmp);
    if (obj_sheds_light(obj)) obj_split_light_source(obj, otmp);
    return otmp;
}
Example #18
0
File: alloc.c Project: FizzyP/julia
DLLEXPORT
jl_lambda_info_t *jl_new_lambda_info(jl_value_t *ast, jl_tuple_t *sparams)
{
    jl_lambda_info_t *li =
        (jl_lambda_info_t*)newobj((jl_value_t*)jl_lambda_info_type,
                                  LAMBDA_INFO_NW);
    li->ast = ast;
    li->file = null_sym;
    li->line = 0;
    if (ast != NULL && jl_is_expr(ast)) {
        jl_expr_t *body1 = (jl_expr_t*)jl_exprarg(jl_lam_body((jl_expr_t*)ast),0);
        if (jl_is_expr(body1) && ((jl_expr_t*)body1)->head == line_sym) {
            li->file = (jl_sym_t*)jl_exprarg(body1, 1);
            li->line = jl_unbox_long(jl_exprarg(body1, 0));
        }
    }
    li->module = jl_current_module;
    li->sparams = sparams;
    li->tfunc = (jl_value_t*)jl_null;
    li->fptr = &jl_trampoline;
    li->roots = NULL;
    li->functionObject = NULL;
    li->cFunctionObject = NULL;
    li->specTypes = NULL;
    li->inferred = 0;
    li->inInference = 0;
    li->inCompile = 0;
    li->unspecialized = NULL;
    li->specializations = NULL;
    li->name = anonymous_sym;
    li->def = li;
    li->capt = NULL;
    return li;
}
Example #19
0
JL_DLLEXPORT jl_lambda_info_t *jl_new_lambda_info_uninit(void)
{
    jl_lambda_info_t *li =
        (jl_lambda_info_t*)newobj((jl_value_t*)jl_lambda_info_type,
                                  NWORDS(sizeof(jl_lambda_info_t)));
    li->code = NULL;
    li->slotnames = li->slotflags = NULL;
    li->slottypes = li->ssavaluetypes = NULL;
    li->rettype = (jl_value_t*)jl_any_type;
    li->sparam_syms = jl_emptysvec;
    li->sparam_vals = jl_emptysvec;
    li->fptr = NULL;
    li->jlcall_api = 0;
    li->compile_traced = 0;
    li->functionObjectsDecls.functionObject = NULL;
    li->functionObjectsDecls.specFunctionObject = NULL;
    li->functionID = 0;
    li->specFunctionID = 0;
    li->specTypes = NULL;
    li->unspecialized_ducttape = NULL;
    li->inferred = 0;
    li->inInference = 0;
    li->inCompile = 0;
    li->def = NULL;
    li->pure = 0;
    li->inlineable = 0;
    return li;
}
Example #20
0
jl_uniontype_t *jl_new_uniontype(jl_tuple_t *types)
{
    jl_uniontype_t *t = (jl_uniontype_t*)newobj((jl_type_t*)jl_union_kind, 1);
    // don't make unions of 1 type; Union(T)==T
    assert(types->length != 1);
    t->types = types;
    return t;
}
Example #21
0
jl_typename_t *jl_new_typename(jl_sym_t *name)
{
    jl_typename_t *tn=(jl_typename_t*)newobj((jl_type_t*)jl_typename_type, 3);
    tn->name = name;
    tn->primary = NULL;
    tn->cache = jl_null;
    return tn;
}
Example #22
0
void
Value::assign ( const Value& v )
{
	if ( this == &v ) return;

	Value newobj(v);
	swap(newobj);
}
Example #23
0
jl_uniontype_t *jl_new_uniontype(jl_svec_t *types)
{
    jl_uniontype_t *t = (jl_uniontype_t*)newobj((jl_value_t*)jl_uniontype_type,NWORDS(sizeof(jl_uniontype_t)));
    // don't make unions of 1 type; Union(T)==T
    assert(jl_svec_len(types) != 1);
    t->types = types;
    return t;
}
Example #24
0
jl_datatype_t *jl_new_uninitialized_datatype(size_t nfields)
{
    jl_datatype_t *t = (jl_datatype_t*)
        newobj((jl_value_t*)jl_datatype_type,
               NWORDS(sizeof(jl_datatype_t) + nfields*sizeof(jl_fielddesc_t)));
    t->nfields = nfields;
    return t;
}
Example #25
0
File: alloc.c Project: FizzyP/julia
jl_uniontype_t *jl_new_uniontype(jl_tuple_t *types)
{
    jl_uniontype_t *t = (jl_uniontype_t*)newobj((jl_value_t*)jl_uniontype_type,1);
    // don't make unions of 1 type; Union(T)==T
    assert(jl_tuple_len(types) != 1);
    t->types = types;
    return t;
}
Example #26
0
File: alloc.c Project: FizzyP/julia
jl_tuple_t *jl_tuple(size_t n, ...)
{
    va_list args;
    if (n == 0) return jl_null;
    va_start(args, n);
#ifdef OVERLAP_TUPLE_LEN
    jl_tuple_t *jv = (jl_tuple_t*)newobj((jl_value_t*)jl_tuple_type, n);
#else
    jl_tuple_t *jv = (jl_tuple_t*)newobj((jl_value_t*)jl_tuple_type, n+1);
#endif
    jl_tuple_set_len_unsafe(jv, n);
    for(size_t i=0; i < n; i++) {
        jl_tupleset(jv, i, va_arg(args, jl_value_t*));
    }
    va_end(args);
    return jv;
}
Example #27
0
File: lbind.c Project: ifzz/nui
LB_API void *lbind_wrap(lua_State *L, void *p, const lbind_Type *t) {
  lbind_Object *obj = newobj(L, 0, t->flags);
  obj->o.instance = p;
  if ((obj->o.flags & LBIND_INTERN) != 0)
    lbind_intern(L, p);
  if (lbind_getmetatable(L, t))
    lua_setmetatable(L, -2);
  return p;
}
Example #28
0
File: alloc.c Project: FizzyP/julia
jl_typename_t *jl_new_typename(jl_sym_t *name)
{
    jl_typename_t *tn=(jl_typename_t*)newobj((jl_value_t*)jl_typename_type, 4);
    tn->name = name;
    tn->module = jl_current_module;
    tn->primary = NULL;
    tn->cache = (jl_value_t*)jl_null;
    return tn;
}
Example #29
0
Value&
Value::operator = (Value&& v)
{
	if ( this == &v ) return *this;

	Value newobj(v);
	swap(newobj);
	return *this;
}
Example #30
0
Event* UIElement::get_RoutedEvent(RoutedEvent* routedEvent)
{
	if (m_events[routedEvent->GetIndex()] == nullptr)
	{
		m_events[routedEvent->GetIndex()] = dynamic_cast<Event*>(newobj(routedEvent->get_HandlerType()));
		ASSERT(m_events[routedEvent->GetIndex()]);
	}

	return m_events[routedEvent->GetIndex()];
}