Beispiel #1
0
  Object* Class::set_superclass(STATE, Object* obj) {
    if(obj->nil_p()) {
      superclass(state, nil<Class>());
      return cNil;
    }

    Class* sup = try_as<Class>(obj);
    if(!sup) {
      return Primitives::failure();
    }

    if(try_as<SingletonClass>(sup)) {
      Exception::raise_type_error(state, "cannot inherit from a singleton class");
    }

    superclass(state, sup);

    instance_type(state, sup->instance_type());
    if(sup->type_info()->type == PackedObject::type) {
      type_info(state->memory()->type_info[ObjectType]);
    } else {
      type_info(sup->type_info());
    }

    SingletonClass::attach(state, this, sup->singleton_class(state));

    sup->track_subclass(state, this);

    return cNil;
  }
Beispiel #2
0
  Object* Class::allocate(STATE) {
    Object* obj = cNil;
    object_type obj_type = type_info()->type;

    if(obj_type == PackedObject::type) {
      obj = allocate_packed(state, this);
    } else if(!type_info()->allow_user_allocate || kind_of<SingletonClass>(this)) {
      std::ostringstream msg;
      msg << "direct allocation disabled for ";
      if(kind_of<SingletonClass>(this)) {
         msg << to_string(state);
      } else {
         msg << module_name()->debug_str(state);
      }
      Exception::raise_type_error(state, msg.str().c_str());
    } else if(obj_type == Object::type) {
      auto_pack(state);
      obj = allocate_packed(state, this);
    } else {
      // type_info()->type is neither PackedObject nor Object, so use the
      // generic path.
      obj = state->memory()->new_object<Object>(
          state, this, type_info()->instance_size, obj_type);
    }

#ifdef RBX_ALLOC_TRACKING
    if(unlikely(state->vm()->allocation_tracking())) {
      new_obj->setup_allocation_site(state);
    }
#endif

    return obj;
  }
 InOutParameter (Path const& path,
                 unsigned long line,
                 std::string const& name)
     : Node (path, line), Parameter (name)
 {
   type_info (static_type_info ());
 }
Beispiel #4
0
 ReadWriteAttribute (Path const& path, unsigned long line)
     : Node (path, line),
       ReadAttribute (path, line),
       WriteAttribute (path, line)
 {
   type_info (static_type_info ());
 }
Beispiel #5
0
/*
 * Free a type, this 'backs up' the pointer to get back to the p3dc_NODE
 * structure, verifies that we are in fact the correct NODE for this
 * type and then adds the type back into the Pool of free structures.
 */
void
p3dc_free_type(void *payload) {
	p3dc_NODE *n;
	struct tinfo *ti;

	__free_type_called++;
	if (payload == NULL)
		return;

	n = (void *)(((char *)payload) - NODE_SIZE);
	if (n->data.p != payload)
		return;

	/* Can't free "unknown" types */
	if (n->data.t == P3DC_UNKNOWN) 
		return; 

	ti = type_info(n->data.t);
	if (ti == NULL) {
		__free_no_type++;
		return; /* wasn't a recognized type (could be an assert)*/
	}
	ti->stats.frees++;
	/* n->owner != NULL means it is already on the free list! */
	assert(n->owner == NULL); 
	p3dc_add_node(ti->pool, n, P3DC_LIST_HEAD);
}
Beispiel #6
0
 IntOr (Path const& path, unsigned long line)
     : Node (path, line),
       first_pattern_ (0),
       second_pattern_ (0)
 {
   type_info (static_type_info ());
 }
Beispiel #7
0
 IntLiteral (Path const& path,
             unsigned long line,
             unsigned long long value)
     : Node (path, line), value_ (value)
 {
   type_info (static_type_info ());
 }
Beispiel #8
0
 IntSub (Path const& path, unsigned long line)
     : Node (path, line),
       minuend_ (0),
       subtrahend_ (0)
 {
   type_info (static_type_info ());
 }
Beispiel #9
0
 IntLsh (Path const& path, unsigned long line)
     : Node (path, line),
       pattern_ (0),
       factor_ (0)
 {
   type_info (static_type_info ());
 }
Beispiel #10
0
 IntAdd (Path const& path, unsigned long line)
     : Node (path, line),
       first_item_ (0),
       second_item_ (0)
 {
   type_info (static_type_info ());
 }
Beispiel #11
0
 IntMul (Path const& path, unsigned long line)
     : Node (path, line),
       first_factor_ (0),
       second_factor_ (0)
 {
   type_info (static_type_info ());
 }
Beispiel #12
0
 IntRem (Path const& path, unsigned long line)
     : Node (path, line),
       divident_ (0),
       divisor_ (0)
 {
   type_info (static_type_info ());
 }
Beispiel #13
0
/*
 * Allocate a new P3DC Type structure.
 *
 * This code first checks to see if the pool of free structures
 * of this type has any available structures, if so it returns
 * one, else it allocates one.
 */
void *
p3dc_new_type(p3dc_TYPE t) {
	p3dc_NODE	*r;
	struct tinfo *ti = type_info(t);

	__new_type_called++;
	if (ti == NULL)
		return NULL;

	assert(ti->pool->n_type == t);

	ti->stats.allocs++;
	if (ti->pool->head != NULL) {
		r = p3dc_remove_node(ti->pool, P3DC_NODE_FIRST);
	} else {
		__new_forced_malloc++;
		r = (p3dc_NODE *)malloc(NODE_SIZE + ti->size);
		r->data.p = ((char *) r) + NODE_SIZE;
		r->data.t = t;
		r->owner = NULL;
		r->name = NULL;
		r->nxt = r->prv = NULL;
		r->parent = NULL;
	}
	return (r->data.p);
}
 static inline PyTypeObject* get_derived_class_object(boost::python::detail::true_, U const volatile* x)
 {
     converter::registration const* r = converter::registry::query(
         type_info(typeid(*get_pointer(x)))
     );
     return r ? r->m_class_object : 0;
 }
Beispiel #15
0
Var Interpreter::update_Callable( Var callable, Var varargs ) {
    // -> new Callable[ surdef_list, self_type, parm_type ]
    TypeInfo *type = type_info( callable.type_expr() );
    if ( isa_Void( type->parameters[ 2 ] ) ) {
        // -> no previously defined parms
        Expr n_data = concat( callable.expr(), pointer_on( varargs.expr() ) );
        Var varargs_type = type_of( varargs );


        // -> Callable[ surdef_list, self_type, parm_type ]
        Var *parms[ 3 ];
        parms[ 0 ] = &type->parameters[ 0 ];
        parms[ 1 ] = &type->parameters[ 1 ];
        parms[ 2 ] = &varargs_type;

        Var res( type_for( class_info( class_Callable ), parms ), n_data );
        res.add_ref_from( callable );
        res.add_ref( callable.expr().size_in_bits(), varargs );
        return res;
    }
    //
    PRINT( type->parameters[ 2 ] );
    TODO;
    return error_var;
}
 EventTypeFactory (Path const& path, unsigned long line)
     : Node (path, line),
       TwoWayOperation (path, line),
       ValueTypeFactory (path, line)
 {
   type_info (static_type_info ());
 }
Beispiel #17
0
ContentControl::ContentControl ()
{
	SetContentSetsParent (true);
	SetObjectType (Type::CONTENTCONTROL);

	ManagedTypeInfo type_info (GetObjectType (), "System.Windows.Controls.ContentControl");
	SetDefaultStyleKey (&type_info);
}
Beispiel #18
0
void register_type(const std::type_info& Info, const string_t& Name)
{
	if(type_to_name_map.count(type_info(Info)))
	{
		k3d::log() << error << k3d_file_reference << ": attempt to re-register type [" << demangle(Info) << "] with existing name [" << type_to_name_map[type_info(Info)] << "] under new name [" << Name << "]" << std::endl;
		return;
	}

	if(type_to_name_map.count(type_info(Info)) || name_to_type_map.count(Name))
	{
		k3d::log() << error << k3d_file_reference << ": attempt to register new type [" << demangle(Info) << "] using existing name [" << Name << "]" << std::endl;
		return;
	}

	type_to_name_map.insert(std::make_pair(type_info(Info), Name));
	name_to_type_map.insert(std::make_pair(Name, type_info(Info)));
}
Beispiel #19
0
inline type_info type_id()
{
    return type_info(
#  if !defined(_MSC_VER)                                       \
      || !BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700)
        typeid(T)
#  else // strip the decoration which Intel mistakenly leaves in
        python::detail::msvc_typeid((geofeatures_boost::type<T>*)0)
#  endif 
        );
}
Beispiel #20
0
inline type_info type_id(BOOST_EXPLICIT_TEMPLATE_TYPE(T))
{
    return type_info(
#  if !defined(_MSC_VER)                                       \
      || (!BOOST_WORKAROUND(BOOST_MSVC, <= 1300)                \
          && !BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700))
        typeid(T)
#  else // strip the decoration which msvc and Intel mistakenly leave in
        python::detail::msvc_typeid((boost::type<T>*)0)
#  endif 
        );
}
Beispiel #21
0
 virtual void connect(SimObjPtr s, bool) {
     auto portOut = dynamic_cast<SimMemoryTemplate<T> *>(s);
     if (type_info(nullValue) == portOut->getMemoryTypeInfo()) {
         sourcePorts.push_back(new SourcePort(portOut, portOut->getCurrentValuePtr()));
         portOut->incrementFanOut();
     } else {
         std::cout << "*** Source/sink port value type mismatch, "
         << "source: " << s->getFullName()
         << ", sink: " << getFullName()
         << " ***" << std::endl;
     }
 }
Beispiel #22
0
 AnyType ()
 {
   type_info (static_type_info ());
 }
Beispiel #23
0
inline
type_info
type_id() {
    return type_info(typeid(T));
} 
Beispiel #24
0
 AnyUri (void)
 {
   type_info (static_type_info ());
 }
Beispiel #25
0
 NormalizedString ()
 {
   type_info (static_type_info ());
 }
Beispiel #26
0
 AnySimpleType ()
 {
   type_info (static_type_info ());
 }
Beispiel #27
0
 Href ()
 {
   type_info (static_type_info ());
 }
Beispiel #28
0
 QName ()
 {
   type_info (static_type_info ());
 }
Beispiel #29
0
 NMTOKEN ()
 {
   type_info (static_type_info ());
 }
Beispiel #30
0
 Token ()
 {
   type_info (static_type_info ());
 }