本文整理汇总了C++中PMC_IS_NULL函数的典型用法代码示例。如果您正苦于以下问题:C++ PMC_IS_NULL函数的具体用法?C++ PMC_IS_NULL怎么用?C++ PMC_IS_NULL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMC_IS_NULL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: try_get_slot
/* Helper for finding a slot number. */
static INTVAL try_get_slot(PARROT_INTERP, P6opaqueREPRData *repr_data, PMC *class_key, STRING *name) {
INTVAL slot = -1;
if (repr_data->name_to_index_mapping) {
P6opaqueNameMap *cur_map_entry = repr_data->name_to_index_mapping;
while (cur_map_entry->class_key != NULL) {
if (cur_map_entry->class_key == class_key) {
if (!PMC_IS_NULL(cur_map_entry->name_map)) {
PMC *slot_pmc = VTABLE_get_pmc_keyed_str(interp, cur_map_entry->name_map, name);
if (!PMC_IS_NULL(slot_pmc))
slot = VTABLE_get_integer(interp, slot_pmc);
break;
}
else {
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"Null attribute map for P6opaque in class '%Ss'",
VTABLE_get_string(interp, introspection_call(interp,
class_key, STABLE(class_key)->HOW,
Parrot_str_new_constant(interp, "name"), 0)));
}
}
cur_map_entry++;
}
}
return slot;
}
示例2: gc_mark
/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, PMC *obj) {
UninstantiableInstance *instance = (UninstantiableInstance *)PMC_data(obj);
if (!PMC_IS_NULL(instance->common.stable))
Parrot_gc_mark_PMC_alive(interp, instance->common.stable);
if (!PMC_IS_NULL(instance->common.sc))
Parrot_gc_mark_PMC_alive(interp, instance->common.sc);
}
示例3: Parrot_oo_get_class
PARROT_EXPORT
PARROT_CAN_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
PMC *
Parrot_oo_get_class(PARROT_INTERP, ARGIN(PMC *key))
{
ASSERT_ARGS(Parrot_oo_get_class)
PMC *classobj = PMCNULL;
if (PMC_IS_NULL(key))
return PMCNULL;
if (PObj_is_class_TEST(key))
classobj = key;
else {
/* Fast select of behavior based on type of the lookup key */
switch (key->vtable->base_type) {
case enum_class_NameSpace:
classobj = VTABLE_get_class(interp, key);
break;
case enum_class_String:
case enum_class_Key:
case enum_class_ResizableStringArray:
{
PMC * const hll_ns = VTABLE_get_pmc_keyed_int(interp,
interp->HLL_namespace,
Parrot_pcc_get_HLL(interp, CURRENT_CONTEXT(interp)));
PMC * const ns = Parrot_ns_get_namespace_keyed(interp,
hll_ns, key);
if (!PMC_IS_NULL(ns))
classobj = VTABLE_get_class(interp, ns);
}
default:
break;
}
}
/* If the PMCProxy doesn't exist yet for the given key, we look up the
type ID here and create a new one */
if (PMC_IS_NULL(classobj)) {
INTVAL type;
const INTVAL base_type = key->vtable->base_type;
/* This is a hack! All PMCs should be able to be handled through
a single codepath, and all of them should be able to avoid
stringification because it's so imprecise. */
if (base_type == enum_class_Key
|| base_type == enum_class_ResizableStringArray
|| base_type == enum_class_String)
type = Parrot_pmc_get_type(interp, key);
else
type = Parrot_pmc_get_type_str(interp, VTABLE_get_string(interp, key));
classobj = get_pmc_proxy(interp, type);
}
return classobj;
}
示例4: gc_mark
/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, PMC *obj) {
P6strInstance *instance = (P6strInstance *)PMC_data(obj);
if (!PMC_IS_NULL(instance->common.stable))
Parrot_gc_mark_PMC_alive(interp, instance->common.stable);
if (!PMC_IS_NULL(instance->common.sc))
Parrot_gc_mark_PMC_alive(interp, instance->common.sc);
if (!STRING_IS_NULL(instance->value))
Parrot_gc_mark_STRING_alive(interp, instance->value);
}
示例5: gc_mark
/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, STable *st, void *data) {
KnowHOWREPRBody *body = (KnowHOWREPRBody *)data;
UNUSED(st);
if (!STRING_IS_NULL(body->name))
Parrot_gc_mark_STRING_alive(interp, body->name);
if (!PMC_IS_NULL(body->methods))
Parrot_gc_mark_PMC_alive(interp, body->methods);
if (!PMC_IS_NULL(body->attributes))
Parrot_gc_mark_PMC_alive(interp, body->attributes);
}
示例6: is_narrower_type
/* Compares two types to see if the first is narrower than the second. */
static INTVAL is_narrower_type(PARROT_INTERP, PMC *a, PMC *b) {
/* If one of the types is null, then we know that's automatically
* wider than anything. Even wider than your mom! */
if (PMC_IS_NULL(b) && !PMC_IS_NULL(a))
return 1;
else if (PMC_IS_NULL(a) || PMC_IS_NULL(b))
return 0;
/* Otherwise, check with the type system. */
return STABLE(a)->type_check(interp, a, b) != 0;
}
示例7: gc_mark
/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, PMC *obj) {
KnowHOWREPRInstance *instance = (KnowHOWREPRInstance *)PMC_data(obj);
if (!PMC_IS_NULL(instance->common.stable))
Parrot_gc_mark_PMC_alive(interp, instance->common.stable);
if (!PMC_IS_NULL(instance->common.sc))
Parrot_gc_mark_PMC_alive(interp, instance->common.sc);
if (!PMC_IS_NULL(instance->methods))
Parrot_gc_mark_PMC_alive(interp, instance->methods);
if (!PMC_IS_NULL(instance->attributes))
Parrot_gc_mark_PMC_alive(interp, instance->attributes);
}
示例8: gc_mark
/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, PMC *obj) {
HashAttrStoreInstance *instance = (HashAttrStoreInstance *)PMC_data(obj);
/* Mark STable. */
if (!PMC_IS_NULL(instance->common.stable))
Parrot_gc_mark_PMC_alive(interp, instance->common.stable);
/* Mark store */
if (!PMC_IS_NULL(instance->store))
Parrot_gc_mark_PMC_alive(interp, instance->store);
}
示例9: gc_mark
/* This Parrot-specific addition to the API is used to mark an object. */
static void gc_mark(PARROT_INTERP, PMC *obj) {
P6opaqueInstance *instance = (P6opaqueInstance *)PMC_data(obj);
/* Mark STable and SC. */
if (!PMC_IS_NULL(instance->common.stable))
Parrot_gc_mark_PMC_alive(interp, instance->common.stable);
if (!PMC_IS_NULL(instance->common.sc))
Parrot_gc_mark_PMC_alive(interp, instance->common.sc);
/* If there's spill storage, mark that. */
if (!PMC_IS_NULL(instance->spill))
Parrot_gc_mark_PMC_alive(interp, instance->spill);
/* Mark contained PMC and string attributes, provided this is a
* real object. */
if (instance->spill) {
P6opaqueREPRData *repr_data = (P6opaqueREPRData *)STABLE(obj)->REPR_data;
INTVAL i;
/* Mark PMCs. */
if (repr_data->gc_pmc_mark_offsets) {
for (i = 0; i < repr_data->num_attributes; i++) {
INTVAL offset = repr_data->gc_pmc_mark_offsets[i];
if (offset) {
PMC *to_mark = get_pmc_at_offset(instance, offset);
if (!PMC_IS_NULL(to_mark))
Parrot_gc_mark_PMC_alive(interp, to_mark);
}
else {
break;
}
}
}
/* Mark strings. */
if (repr_data->gc_str_mark_offsets) {
for (i = 0; i < repr_data->num_attributes; i++) {
INTVAL offset = repr_data->gc_str_mark_offsets[i];
if (offset) {
STRING *to_mark = get_str_at_offset(instance, offset);
if (to_mark)
Parrot_gc_mark_STRING_alive(interp, to_mark);
}
else {
break;
}
}
}
}
}
示例10: Rakudo_binding_assign_attributive
/* Assigns an attributive parameter to the desired attribute. */
static INTVAL
Rakudo_binding_assign_attributive(PARROT_INTERP, PMC *lexpad, Rakudo_Parameter *param,
Rakudo_BindVal value, PMC *decont_value, STRING **error) {
PMC *assignee = PMCNULL;
PMC *assigner;
/* Find self. */
PMC *self = VTABLE_get_pmc_keyed_str(interp, lexpad,
Parrot_str_new(interp, "self", 0));
if (PMC_IS_NULL(self)) {
if (error)
*error = Parrot_sprintf_c(interp,
"Unable to bind attributive parameter '%S' - could not find self",
param->variable_name);
return BIND_RESULT_FAIL;
}
/* Ensure it's not native; NYI. */
if (value.type != BIND_VAL_OBJ) {
*error = Parrot_sprintf_c(interp,
"Binding to natively typed attributive parameter '%S' not supported",
param->variable_name);
return BIND_RESULT_FAIL;
}
/* If it's private, just need to fetch the attribute. */
if (param->flags & SIG_ELEM_BIND_PRIVATE_ATTR) {
assignee = VTABLE_get_attr_keyed(interp, self, param->attr_package,
param->variable_name);
}
/* Otherwise if it's public, do a method call to get the assignee. */
else {
PMC *meth = VTABLE_find_method(interp, self, param->variable_name);
if (PMC_IS_NULL(meth)) {
if (error)
*error = Parrot_sprintf_c(interp,
"Unable to bind attributive parameter '$.%S' - could not find method '%S'",
param->variable_name,
param->variable_name);
return BIND_RESULT_FAIL;
}
Parrot_ext_call(interp, meth, "Pi->P", self, &assignee);
}
Rakudo_cont_store(interp, assignee, decont_value, 1, 1);
return BIND_RESULT_OK;
}
示例11: return
static STRING *get_str(PARROT_INTERP, STable *st, void *data) {
CStrBody *body = (CStrBody *) data;
PMC *old_ctx, *cappy, *meth, *enc_pmc;
STRING *enc;
STR_VTABLE *encoding;
if (!body->cstr)
return (STRING *) NULL;
/* Look up "encoding" method. */
meth = VTABLE_find_method(interp, st->WHAT,
Parrot_str_new_constant(interp, "encoding"));
if (PMC_IS_NULL(meth))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_INVALID_OPERATION,
"CStr representation expects an 'encoding' method, specifying the encoding");
old_ctx = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
cappy = Parrot_pmc_new(interp, enum_class_CallContext);
VTABLE_push_pmc(interp, cappy, st->WHAT);
Parrot_pcc_invoke_from_sig_object(interp, meth, cappy);
cappy = Parrot_pcc_get_signature(interp, CURRENT_CONTEXT(interp));
Parrot_pcc_set_signature(interp, CURRENT_CONTEXT(interp), old_ctx);
enc_pmc = decontainerize(interp, VTABLE_get_pmc_keyed_int(interp, cappy, 0));
enc = REPR(enc_pmc)->box_funcs->get_str(interp, STABLE(enc_pmc), OBJECT_BODY(enc_pmc));
return new_from_cstring(interp, body->cstr, enc);
}
示例12: Parrot_io_socket_handle
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
PARROT_CANNOT_RETURN_NULL
INTVAL
Parrot_io_socket_handle(PARROT_INTERP, ARGMOD_NULLOK(PMC *socket), INTVAL fam,
INTVAL type, INTVAL proto)
{
ASSERT_ARGS(Parrot_io_socket_handle)
PMC *new_socket;
PIOHANDLE os_handle;
if (PMC_IS_NULL(socket))
new_socket = Parrot_io_new_socket_pmc(interp,
PIO_F_SOCKET|PIO_F_READ|PIO_F_WRITE);
else
new_socket = socket;
os_handle = Parrot_io_socket(interp, fam, type, proto);
SETATTR_Socket_os_handle(interp, new_socket, os_handle);
SETATTR_Socket_family(interp, new_socket, fam);
SETATTR_Socket_type(interp, new_socket, type);
SETATTR_Socket_protocol(interp, new_socket, proto);
return 0;
}
示例13: pcf_ptr_ptr_STRING
static void
pcf_ptr_ptr_STRING(PARROT_INTERP, PMC *nci, SHIM(PMC *self))
{
typedef void *(* func_t)(void *, STRING *);
func_t fn_pointer;
void *orig_func;
PMC * const ctx = CURRENT_CONTEXT(interp);
PMC * const call_object = Parrot_pcc_get_signature(interp, ctx);
PMC * t_0; void * v_0;
PMC * t_1; void * v_1;
STRING * t_2; STRING * v_2;
Parrot_pcc_fill_params_from_c_args(interp, call_object, "PS", &t_1, &t_2);
v_1 = PMC_IS_NULL(t_1) ? NULL : VTABLE_get_pointer(interp, t_1);;
v_2 = t_2;
GETATTR_NCI_orig_func(interp, nci, orig_func);
fn_pointer = (func_t)D2FPTR(orig_func);
v_0 = (*fn_pointer)(v_1, v_2);
if (v_0 != NULL) {
t_0 = Parrot_pmc_new(interp, enum_class_UnManagedStruct);
VTABLE_set_pointer(interp, t_0, v_0);
}
else {
t_0 = PMCNULL;
};
Parrot_pcc_set_call_from_c_args(interp, call_object, "P", t_0);
}
示例14: get_pmc_proxy
PARROT_INLINE
PARROT_CANNOT_RETURN_NULL
PARROT_WARN_UNUSED_RESULT
static PMC *
get_pmc_proxy(PARROT_INTERP, INTVAL type)
{
ASSERT_ARGS(get_pmc_proxy)
PMC * type_class;
/* Check if not a PMC or invalid type number */
if (type > interp->n_vtable_max || type <= 0)
return PMCNULL;
type_class = interp->vtables[type]->pmc_class;
if (type != enum_class_Class
&& type_class->vtable->base_type == enum_class_Class) {
return type_class;
}
else {
PMC * const parrot_hll = Parrot_ns_get_namespace_keyed_str(interp, interp->root_namespace, CONST_STRING(interp, "parrot"));
PMC * const pmc_ns =
Parrot_ns_make_namespace_keyed_str(interp, parrot_hll,
interp->vtables[type]->whoami);
PMC * proxy = VTABLE_get_class(interp, pmc_ns);
/* Create proxy if not found */
if (PMC_IS_NULL(proxy)) {
proxy = Parrot_pmc_new_init_int(interp, enum_class_PMCProxy, type);
Parrot_pcc_invoke_method_from_c_args(interp, pmc_ns, CONST_STRING(interp, "set_class"), "P->", proxy);
}
return proxy;
}
}
示例15: Rakudo_binding_parcel_from_rpa
/* This function gets shared with perl6.ops for the perl6_parcel_from_rpa op. */
PMC *
Rakudo_binding_parcel_from_rpa(PARROT_INTERP, PMC *rpa, PMC *fill) {
PMC *type = Rakudo_types_parcel_get();
PMC *parcel = REPR(type)->allocate(interp, STABLE(type));
VTABLE_set_attr_keyed(interp, parcel, type, STORAGE_str, rpa);
if (!PMC_IS_NULL(fill)) {
INTVAL elems = VTABLE_elements(interp, rpa);
INTVAL i;
for (i = 0; i < elems; i++) {
if (PMC_IS_NULL(VTABLE_get_pmc_keyed_int(interp, rpa, i)))
VTABLE_set_pmc_keyed_int(interp, rpa, i, fill);
}
}
return parcel;
}