ObjClass* wrenGetClass(WrenVM* vm, Value value) { #if WREN_NAN_TAGGING if (IS_NUM(value)) return vm->numClass; if (IS_OBJ(value)) return getObjectClass(vm, AS_OBJ(value)); switch (GET_TAG(value)) { case TAG_FALSE: return vm->boolClass; case TAG_NAN: return vm->numClass; case TAG_NULL: return vm->nullClass; case TAG_TRUE: return vm->boolClass; } #else switch (value.type) { case VAL_FALSE: return vm->boolClass; case VAL_NULL: return vm->nullClass; case VAL_NUM: return vm->numClass; case VAL_TRUE: return vm->boolClass; case VAL_OBJ: return getObjectClass(vm, value.obj); } #endif return NULL; // Unreachable. }
bool ASTType::isDerivedFrom(const ASTType& that) const { if ( !isUnknown() && !that.isUnknown() ) { return that.getObjectClass().isBase(getObjectClass()) || that.getObjectClass().isImplementing(getObjectClass()); } return false; }
QString PHPSerializeFormatter::parseObject(const QString &rawValue) { QRegExp getObjectClass("O:\\d+:\"(.+)\":\\d+:\\{"); if (getObjectClass.indexIn(rawValue) == -1) { return "Invalid serialized string"; } return QString("Object:%1").arg(getObjectClass.cap(1)); }
suc_code addParent(char *dn, char **attr) { __nis_rule_value_t *rv; __nis_ldap_search_t *ls; int rc, nr; char *parentdn = 0, *rdn = 0; char *myself = "addParent"; /* Obtain parentdn */ if (splitDN(dn, &rdn, &parentdn) == -1) return (FAILURE); if (!parentdn) { sfree(rdn); return (FAILURE); } /* Check if parentdn exists */ ls = buildLdapSearch(parentdn, LDAP_SCOPE_BASE, 0, 0, "objectclass=*", 0, 0, 0); if (ls == 0) { logmsg(MSG_NOTIMECHECK, LOG_ERR, "%s: Unable to create ldapSearch request for " "parent (dn: %s) of (dn: %s)", myself, parentdn, dn); sfree(parentdn); sfree(rdn); return (FAILURE); } nr = -1; rv = ldapSearch(ls, &nr, 0, &rc); freeLdapSearch(ls); freeRuleValue(rv, nr); /* Create parent if it doesn't exists */ if (rc == LDAP_NO_SUCH_OBJECT) { if (makeNISObject(0, parentdn) == FAILURE) { logmsg(MSG_NOTIMECHECK, LOG_ERR, "%s: Unable to create parent (dn: %s) of " "(dn: %s) in the DIT", myself, parentdn, dn); sfree(parentdn); sfree(rdn); return (FAILURE); } } sfree(parentdn); if (attr && rdn) *attr = (char *)getObjectClass(rdn); sfree(rdn); return (SUCCESS); }
/** * Preliminary command to list the current items in the player's inventory */ bool Debugger::cmd_items(int argc, const char **argv) { for (int i = 1; i < numOfLoadedOverlay; i++) { ovlDataStruct *pOvlData = overlayTable[i].ovlData; if (overlayTable[i].alreadyLoaded) { if (overlayTable[i].ovlData->arrayObject) { for (int j = 0; j < pOvlData->numObj; j++) { if (getObjectClass(i, j) != 3) { int16 returnVar; getSingleObjectParam(i, j, 5, &returnVar); if (returnVar < -1) DebugPrintf("%s\n", getObjectName(j, pOvlData->arrayNameObj)); } } } } } return true; }
void buildInventory(int X, int Y) { menuStruct *pMenu; pMenu = createMenu(X, Y, _vm->langString(ID_INVENTORY)); menuTable[1] = pMenu; if (pMenu == NULL) return; int numObjectInInventory = 0; for (int i = 1; i < numOfLoadedOverlay; i++) { ovlDataStruct *pOvlData = overlayTable[i].ovlData; if (overlayTable[i].alreadyLoaded) { if (overlayTable[i].ovlData->arrayObject) { for (int j = 0; j < pOvlData->numObj; j++) { if (getObjectClass(i, j) != 3) { int16 returnVar; getSingleObjectParam(i, j, 5, &returnVar); if (returnVar < -1) { addSelectableMenuEntry(i, j, pMenu, 1, -1, getObjectName(j, pOvlData->arrayNameObj)); numObjectInInventory++; } } } } } } if (numObjectInInventory == 0) { freeMenu(menuTable[1]); menuTable[1] = NULL; } }
// Migrate the database to the session int db2session(sqlite3* db, CK_SESSION_HANDLE hSession, int noPublicKey) { CK_ULONG objectCount; int result = 0, rv; CK_OBJECT_HANDLE* objects = NULL; CK_OBJECT_CLASS ckClass; // Get all objects objects = getObjects(db, &objectCount); if (objects == NULL) { fprintf(stderr, "ERROR: Could not find any objects in the database.\n"); return 1; } // Loop over all objects for (unsigned i = 0; i < objectCount; i++) { ckClass = getObjectClass(objects[i]); switch (ckClass) { case CKO_PUBLIC_KEY: if (noPublicKey) continue; if (getKeyType(objects[i]) != CKK_RSA) { fprintf(stderr, "ERROR: Cannot export object %lu. Only supporting RSA keys. " "Continuing.\n", objects[i]); result = 1; break; } rv = dbRSAPub2session(db, objects[i], hSession); if (rv) result = 1; break; case CKO_PRIVATE_KEY: if (getKeyType(objects[i]) != CKK_RSA) { fprintf(stderr, "ERROR: Cannot export object %lu. Only supporting RSA keys. " "Continuing.\n", objects[i]); result = 1; break; } rv = dbRSAPriv2session(db, objects[i], hSession); if (rv) result = 1; break; case CKO_VENDOR_DEFINED: fprintf(stderr, "ERROR: Could not get the class of object %lu. " "Continuing.\n", objects[i]); result = 1; break; default: fprintf(stderr, "ERROR: Not supporting class %lu in object %lu. " "Continuing.\n", ckClass, objects[i]); result = 1; break; } } free(objects); return result; }
/// \brief Test whether that is greater than this type bool ASTType::greater(const ASTType& that) const { if ( isNull() && (that.isObject() || that.isArray() || that.isString() || that.isGeneric()) ) { return true; } else if ( isObject() && that.isObject() ) { // check if 'that' is a extending or implemented this if ( !(mTypeArguments == that.mTypeArguments) ) { return false; } return getObjectClass().isBase(that.getObjectClass()) || getObjectClass().isImplementing(that.getObjectClass()); } else if ( isArray() && that.isArray() ) { return mpArrayType->equals(*that.mpArrayType) && mArrayDimension == that.mArrayDimension; } else if ( isGeneric() ) { if ( that.isObject() ) { return that.getObjectName() == UTEXT("system.Object"); // object is greater than a generic (its da uber type) } else if ( that.isGeneric() ) { return mObjectName == that.mObjectName; } } else if ( !isObject() && !that.isObject() ) { switch ( that.mKind ) { case eBoolean: return mKind == eBoolean; case eInt: return mKind == eInt; case eReal: return mKind == eInt || mKind == eReal; case eChar: return mKind == eChar; case eString: return mKind == eString || mKind == eInt || mKind == eReal || mKind == eBoolean || mKind == eChar; default: break; } } // no implicit primitive to basic or vs yet return false; }
/* * FUNCTION : addNISObject() * * DESCRIPTION: Add a nis Object in the DIT. * * GIVEN : * Case 1: 'dn' is NULL * Error * Case 2: 'domain' is non-NULL * Create nisDomainObject with the given information * Case 3: 'domain' is NULL * Create an object with the 'dn' * Here we guess the objectclass attribute, based on * oc_lookup table * * RETURNS : SUCCESS = It worked * FAILURE = There was a problem. If the ldap add * operation failed, ldap_rc will be set * to the ldap error code. */ suc_code addNISObject(char *domain, char *dn, int *ldap_rc) { __nis_rule_value_t *rv; int rc; char *objClassAttrs = NULL, *attrs; char *value, *svalue, *rdn = NULL; char *myself = "addNISObject"; if (!dn) return (FAILURE); if ((rv = initRuleValue(1, 0)) == 0) return (FAILURE); if (ldap_rc) *ldap_rc = -1; /* * Add name=value pairs from RDN. Although this is not required * for SunOne Directory Server, during openldap interoperabilty * tests, it was found out that openldap server returned object * class violation errors if MUST attributes were not specified * explicitly. */ if (splitDN(dn, &rdn, 0) == -1) return (FAILURE); if (rdn != NULL) { objClassAttrs = (char *)getObjectClass(rdn); if (objClassAttrs == NULL) { sfree(rdn); return (FAILURE); } /* * RDN can be composed of multiple name=value pairs * concatenated by '+'. Hence, we need to determine each * pair and add it to 'rv' */ for (value = rdn, svalue = NULL; *value != '\0'; value++) { if (*value == '+') { /* Make sure it's not escaped */ if (value == rdn || *(value - 1) != '\\') { /* * We are at the start of the new * pair. 'svalue' now contains the * value for the previous pair. Add * the previous pair to 'rv' */ *value = '\0'; if (svalue && addSAttr2RuleValue(rdn, svalue, rv) == -1) { sfree(rdn); freeRuleValue(rv, 1); return (FAILURE); } svalue = NULL; rdn = value + 1; continue; } } if (*value == '=') { if (value == rdn || *(value - 1) != '\\') { /* * 'rdn' now contains the name. * Whatever follows till the next * unescaped '+' or '\0' is the * value for this pair. */ *value = '\0'; svalue = value + 1; continue; } } } /* * End of String. Add the previous name=value pair to 'rv' */ if (svalue && addSAttr2RuleValue(rdn, svalue, rv) == -1) { sfree(rdn); freeRuleValue(rv, 1); return (FAILURE); } sfree(rdn); } else /* rdn == NULL */ return (FAILURE); /* Create the entry */ if (domain) { if (addSAttr2RuleValue("nisDomain", domain, rv) == -1) { freeRuleValue(rv, 1); return (FAILURE); } attrs = scat(myself, F, "objectclass=nisdomainobject,", objClassAttrs); if (!attrs) { freeRuleValue(rv, 1); return (FAILURE); } rc = ldapAdd(dn, rv, attrs, 0); sfree(attrs); } else { rc = ldapAdd(dn, rv, objClassAttrs, 0); } if (rc == LDAP_SUCCESS) logmsg(MSG_NOTIMECHECK, LOG_INFO, "%s: Entry (dn: %s) added to DIT", myself, dn); else if (rc == LDAP_ALREADY_EXISTS) /* Treat this as success */ rc = LDAP_SUCCESS; else logmsg(MSG_NOTIMECHECK, LOG_ERR, "%s: ldapAdd error %d (%s) for (dn: %s)", myself, rc, ldap_err2string(rc), dn); freeRuleValue(rv, 1); if (ldap_rc) *ldap_rc = rc; return ((rc == LDAP_SUCCESS)?SUCCESS:FAILURE); }
int main(int argc, char *argv[]) { // expects no arguments because we are using a particular class file if (argc != 1) { fprintf(stderr, "Usage: heapTest\n"); exit(-1); } // initialize: need to use a class with a user class that has at least // four fields initializeVM(10000, "userClass.class"); // okay, begin the testing... Class A = getIthClass(4); Reference objectRef = allocateObject(getObjectClass()); Reference integerRef = allocateObject(getIntegerClass()); Reference aRef = allocateObject(A); Reference stringRef = allocateString("abcdefghijklmnopqrstuvwxyz"); if (getObjectClass() != getClass(objectRef)) { fprintf(stderr, "FAIL: getClass from objectRef\n"); } if (getIntegerClass() != getClass(integerRef)) { fprintf(stderr, "FAIL: getClass from integerRef\n"); } if (getStringClass() != getClass(stringRef)) { fprintf(stderr, "FAIL: getClass from stringRef\n"); } if (A != getClass(aRef)) { fprintf(stderr, "FAIL: getClass from aRef\n"); } if (strcmp(getStringValue(stringRef), "abcdefghijklmnopqrstuvwxyz")) { fprintf(stderr, "FAIL: getStringValue\n"); } putIntegerValue(integerRef, 1066); if (getIntegerValue(integerRef) != 1066) { fprintf(stderr, "FAIL: getIntegerValue\n"); } putField(aRef, 0, integerRef); if (getField(aRef, 0) != integerRef) { fprintf(stderr, "FAIL: getField 0\n"); } putField(aRef, 3, objectRef); if (getField(aRef, 3) != objectRef) { fprintf(stderr, "FAIL: getField 3\n"); } printf("testing complete.\n"); return 0; }