本文整理汇总了C++中OSArray::setObject方法的典型用法代码示例。如果您正苦于以下问题:C++ OSArray::setObject方法的具体用法?C++ OSArray::setObject怎么用?C++ OSArray::setObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSArray
的用法示例。
在下文中一共展示了OSArray::setObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: withCString
OSString * ACPIBacklightPanel::getACPIPath(IOACPIPlatformDevice * acpiDevice)
{
OSString * separator = OSString::withCStringNoCopy(".");
OSArray * array = OSArray::withCapacity(10);
char devicePath[512];
bzero(devicePath, sizeof(devicePath));
IOACPIPlatformDevice * parent = acpiDevice;
IORegistryIterator * iter = IORegistryIterator::iterateOver(acpiDevice, gIOACPIPlane, kIORegistryIterateParents | kIORegistryIterateRecursively);
if (iter)
{
do {
array->setObject(parent->copyName(gIOACPIPlane));
array->setObject(separator);
parent = OSDynamicCast(IOACPIPlatformDevice, iter->getNextObject());
} while (parent);
iter->release();
int offset = 0;
OSString * str = OSDynamicCast(OSString, array->getLastObject());
for (int i = array->getCount()-2; ((i>=0) || ((offset + str->getLength()) > sizeof(devicePath))) ; i--)
{
str = OSDynamicCast(OSString, array->getObject(i));
strncpy(devicePath + offset, str->getCStringNoCopy(), str->getLength());
offset += str->getLength();
}
}
return OSString::withCString(devicePath);
}
示例2: serialize
bool IORangeAllocator::serialize(OSSerialize *s) const
{
OSArray * array = OSArray::withCapacity( numElements * 2 );
OSNumber * num;
UInt32 index;
bool ret;
if( !array)
return( false );
LOCK();
for( index = 0; index < numElements; index++) {
if( (num = OSNumber::withNumber( elements[index].start,
8 * sizeof(IORangeScalar) ))) {
array->setObject(num);
num->release();
}
if( (num = OSNumber::withNumber( elements[index].end,
8 * sizeof(IORangeScalar) ))) {
array->setObject(num);
num->release();
}
}
UNLOCK();
ret = array->serialize(s);
array->release();
return( ret );
}
示例3: setProperties
IOReturn FakeSMCDevice::setProperties(OSObject * properties)
{
KEYSLOCK;
IOReturn result = kIOReturnUnsupported;
if (OSDictionary * msg = OSDynamicCast(OSDictionary, properties)) {
if (OSString * name = OSDynamicCast(OSString, msg->getObject(kFakeSMCDeviceUpdateKeyValue))) {
if (FakeSMCKey * key = getKey(name->getCStringNoCopy())) {
OSArray *info = OSArray::withCapacity(2);
info->setObject(OSString::withCString(key->getType()));
info->setObject(OSData::withBytes(key->getValue(), key->getSize()));
exposedValues->setObject(key->getKey(), info);
OSDictionary *values = OSDictionary::withDictionary(exposedValues);
this->setProperty(kFakeSMCDeviceValues, values);
OSSafeRelease(values);
result = kIOReturnSuccess;
}
}
else if (OSArray* array = OSDynamicCast(OSArray, msg->getObject(kFakeSMCDevicePopulateValues))) {
if (OSIterator* iterator = OSCollectionIterator::withCollection(array)) {
while (OSString *keyName = OSDynamicCast(OSString, iterator->getNextObject()))
if (FakeSMCKey * key = getKey(keyName->getCStringNoCopy())) {
OSArray *info = OSArray::withCapacity(2);
info->setObject(OSString::withCString(key->getType()));
info->setObject(OSData::withBytes(key->getValue(), key->getSize()));
exposedValues->setObject(key->getKey(), info);
IOSleep(10); //REVIEW: what is this for?
}
OSDictionary *values = OSDictionary::withDictionary(exposedValues);
this->setProperty(kFakeSMCDeviceValues, values);
OSSafeRelease(values);
OSSafeRelease(iterator);
result = kIOReturnSuccess;
}
}
}
KEYSUNLOCK;
return result;
}
示例4: serializePort
void AppleUSBDiagnostics::serializePort(OSDictionary *dictionary, int port, UIMPortDiagnostics *counts, IOService *controller) const
{
#pragma unused(controller, port)
UpdateNumberEntry( dictionary, counts->errorCount, "Port errors");
if( (gUSBStackDebugFlags & kUSBEnableErrorLogMask) != 0)
{
UpdateNumberEntry( dictionary, counts->totalBytes, "Bytes");
UpdateNumberEntry( dictionary, counts->totalBytes-counts->prevBytes, "Bytes (New)");
counts->prevBytes = counts->totalBytes;
UpdateNumberEntry( dictionary, counts->timeouts, "Timeouts");
UpdateNumberEntry( dictionary, counts->timeouts-counts->prevTimeouts, "Timeouts (New)");
counts->prevTimeouts = counts->timeouts;
}
UpdateNumberEntry( dictionary, counts->resets, "Resets");
UpdateNumberEntry( dictionary, counts->resets-counts->prevResets, "Resets (New)");
counts->prevResets = counts->resets;
UpdateNumberEntry( dictionary, counts->enable, "enable");
UpdateNumberEntry( dictionary, counts->suspend, "suspend");
UpdateNumberEntry( dictionary, counts->resume, "resume");
UpdateNumberEntry( dictionary, counts->warmReset, "warmReset");
UpdateNumberEntry( dictionary, counts->power, "power");
UpdateNumberEntry( dictionary, counts->u1Timeout, "u1Timeout");
UpdateNumberEntry( dictionary, counts->u2Timeout, "u2Timeout");
UpdateNumberEntry( dictionary, counts->remoteWakeMask, "remoteWakeMask");
OSArray * errorArray = OSArray::withCapacity(kXHCIMaxCompletionCodes);
for(int i=0; i<kXHCIMaxCompletionCodes; i++)
{
OSNumber * number = OSNumber::withNumber( counts->xhciErrorCode[i], 32 );
errorArray->setObject( i, number );
number->release();
}
dictionary->setObject( "XHCI Completion Codes", errorArray );
errorArray->release();
OSArray * linkStateArray = OSArray::withCapacity(kXHCILinkStates);
for(int i=0; i<kXHCILinkStates; i++)
{
OSNumber * number = OSNumber::withNumber( counts->linkState[i], 32 );
linkStateArray->setObject( i, number );
number->release();
}
dictionary->setObject( "LinkStates", linkStateArray );
linkStateArray->release();
}
示例5:
OSArray * IOHIDInterface::createMatchingElements (
OSDictionary * matching,
IOOptionBits options __unused)
{
UInt32 count = _elementArray->getCount();
IOHIDElementPrivate * element = NULL;
OSArray * elements = NULL;
if ( count )
{
if ( matching )
{
elements = OSArray::withCapacity(count);
for ( UInt32 i = 0; i < count; i ++)
{
// Compare properties.
if (( element = (IOHIDElementPrivate *)_elementArray->getObject(i) )
&& element->matchProperties(matching))
{
elements->setObject(element);
}
}
}
else
elements = OSArray::withArray(_elementArray);
}
return elements;
}
示例6: return
OSArray * IODeviceMemory::arrayFromList(
InitElement list[],
IOItemCount count )
{
OSArray * array;
IODeviceMemory * range;
IOItemCount i;
array = OSArray::withCapacity( count );
if( 0 == array )
return( 0);
for( i = 0; i < count; i++) {
range = IODeviceMemory::withRange( list[i].start, list[i].length );
if( range) {
range->setTag( list[i].tag );
array->setObject( range);
range->release();
} else {
array->release();
array = 0;
break;
}
}
return( array );
}
示例7: kmod_start
volatile int kmod_start(void)
{
libkern_init0();
OSString* one = OSString::withCString("Anal sex");
OSString* two = OSString::withCString("Cunnilingus");
OSArray* sexthings = OSArray::withCapacity(2);
sexthings->setObject(one);
sexthings->setObject(two);
printk("Hello from IOKit!\n");
printk("Put: %p %p\n", one, two);
printk("OSArray: %p\n", sexthings);
printk("Get: %p %p\n", sexthings->getObject(0), sexthings->getObject(1));
OSSerialize* ser = OSSerialize::withCapacity(1024);
sexthings->serialize(ser);
printk("Serialized: %s \n", ser->text());
return 0;
}
示例8: update_interface_property
/*---------------------------------------------------------------------------
* Update all the registry properties associated with an interface
---------------------------------------------------------------------------*/
void EInterfaces::update_interface_property(void)
{
int n;
debug("update_interface_property - m_nInterfacesInUse=%d\n", m_nInterfacesInUse);
if ( m_pProvider )
{
m_pProvider->removeProperty(ENABLED_INTERFACES_PROPERTY);
if ( m_nInterfacesInUse )
{
OSArray* pInterfaces = OSArray::withCapacity(m_nInterfacesInUse);
if ( pInterfaces )
{
for(n=0; n<numberof(m_aInterfaces); n++)
if ( m_aInterfaces[n].m_fEnabled )
{
OSNumber* pNumber = OSNumber::withNumber(n, 32);
if ( pNumber )
{
pInterfaces->setObject(pNumber);
pNumber->release();
}
}
m_pProvider->setProperty(ENABLED_INTERFACES_PROPERTY, (OSObject* )pInterfaces);
pInterfaces->release();
}
}
}
}
示例9: OSDynamicCast
OSCollection * OSSet::copyCollection(OSDictionary *cycleDict)
{
bool allocDict = !cycleDict;
OSCollection *ret = 0;
OSSet *newSet = 0;
if (allocDict) {
cycleDict = OSDictionary::withCapacity(16);
if (!cycleDict)
return 0;
}
do {
// Check for a cycle
ret = super::copyCollection(cycleDict);
if (ret)
continue; // Found it
newSet = OSSet::withCapacity(members->capacity);
if (!newSet)
continue; // Couldn't create new set abort
// Insert object into cycle Dictionary
cycleDict->setObject((const OSSymbol *) this, newSet);
OSArray *newMembers = newSet->members;
newMembers->capacityIncrement = members->capacityIncrement;
// Now copy over the contents into the new duplicate
for (unsigned int i = 0; i < members->count; i++) {
OSObject *obj = EXT_CAST(members->array[i]);
OSCollection *coll = OSDynamicCast(OSCollection, obj);
if (coll) {
OSCollection *newColl = coll->copyCollection(cycleDict);
if (newColl) {
obj = newColl; // Rely on cycleDict ref for a bit
newColl->release();
}
else
goto abortCopy;
};
newMembers->setObject(obj);
};
ret = newSet;
newSet = 0;
} while(false);
abortCopy:
if (newSet)
newSet->release();
if (allocDict)
cycleDict->release();
return ret;
}
示例10: addAvailableSelection
// <rdar://8202424>
IOReturn IOAudioSelectorControl::addAvailableSelection(SInt32 selectionValue, OSString *selectionDescription, const char* tagName, OSObject* tag)
{
OSArray *newSelections;
OSArray *oldAvailableSelections;
IOReturn result = kIOReturnSuccess;
oldAvailableSelections = availableSelections;
newSelections = OSArray::withArray(availableSelections);
if (!newSelections)
return kIOReturnNoMemory;
if (selectionDescription == NULL) {
result = kIOReturnBadArgument;
} else {
if (valueExists(selectionValue)) {
result = kIOReturnError;
} else {
OSDictionary *newSelection;
newSelection = OSDictionary::withCapacity(2);
if (newSelection) {
OSNumber *number;
number = OSNumber::withNumber(selectionValue, sizeof(SInt32)*8);
if (number) {
newSelection->setObject(kIOAudioSelectorControlSelectionValueKey, number);
newSelection->setObject(kIOAudioSelectorControlSelectionDescriptionKey, selectionDescription);
newSelections->setObject(newSelection);
number->release();
} else {
result = kIOReturnError;
}
if ( tagName && tag ) {
newSelection->setObject(tagName, tag);
}
availableSelections = newSelections;
setProperty(kIOAudioSelectorControlAvailableSelectionsKey, availableSelections);
oldAvailableSelections->release();
newSelection->release();
} else {
result = kIOReturnError;
}
}
}
if (kIOReturnSuccess == result) {
sendChangeNotification(kIOAudioControlRangeChangeNotification);
}
return result;
}
示例11: addPersonality
void IOCatalogue::addPersonality(OSDictionary * dict)
{
const OSSymbol * sym;
OSArray * arr;
sym = OSDynamicCast(OSSymbol, dict->getObject(gIOProviderClassKey));
if (!sym) return;
arr = (OSArray *) personalities->getObject(sym);
if (arr) arr->setObject(dict);
else
{
arr = OSArray::withObjects((const OSObject **)&dict, 1, 2);
personalities->setObject(sym, arr);
arr->release();
}
}
示例12: return
OSArray * OSDictionary::copyKeys(void)
{
OSArray * array;
array = OSArray::withCapacity(count);
if (!array) return (0);
for (unsigned int i = 0; i < count; i++)
{
if (!array->setObject(i, dictionary[i].key))
{
array->release();
array = 0;
break;
}
}
return (array);
}
示例13: initAndStart
bool FakeSMCDevice::initAndStart(IOService *platform, IOService *provider)
{
if (!provider || !super::init(platform, 0, 0))
return false;
OSDictionary *properties = OSDynamicCast(OSDictionary, provider->getProperty("Configuration"));
if (!properties)
return false;
status = (ApleSMCStatus *) IOMalloc(sizeof(struct AppleSMCStatus));
bzero((void*)status, sizeof(struct AppleSMCStatus));
interrupt_handler = 0;
keys = OSArray::withCapacity(1);
types = OSDictionary::withCapacity(0);
exposedValues = OSDictionary::withCapacity(0);
// Add fist key - counter key
keyCounterKey = FakeSMCKey::withValue(KEY_COUNTER, TYPE_UI32, TYPE_UI32_SIZE, "\0\0\0\1");
keys->setObject(keyCounterKey);
fanCounterKey = FakeSMCKey::withValue(KEY_FAN_NUMBER, TYPE_UI8, TYPE_UI8_SIZE, "\0");
keys->setObject(fanCounterKey);
if (!gKeysLock)
gKeysLock = IORecursiveLockAlloc();
// Load preconfigured keys
FakeSMCDebugLog("loading keys...");
if (OSDictionary *dictionary = OSDynamicCast(OSDictionary, properties->getObject("Keys"))) {
if (OSIterator *iterator = OSCollectionIterator::withCollection(dictionary)) {
while (const OSSymbol *key = (const OSSymbol *)iterator->getNextObject()) {
if (OSArray *array = OSDynamicCast(OSArray, dictionary->getObject(key))) {
if (OSIterator *aiterator = OSCollectionIterator::withCollection(array)) {
OSString *type = OSDynamicCast(OSString, aiterator->getNextObject());
OSData *value = OSDynamicCast(OSData, aiterator->getNextObject());
if (type && value)
addKeyWithValue(key->getCStringNoCopy(), type->getCStringNoCopy(), value->getLength(), value->getBytesNoCopy());
OSSafeRelease(aiterator);
}
}
key = 0;
}
OSSafeRelease(iterator);
}
HWSensorsInfoLog("%d preconfigured key%s added", keys->getCount(), keys->getCount() == 1 ? "" : "s");
}
else {
HWSensorsWarningLog("no preconfigured keys found");
}
// Load wellknown type names
FakeSMCDebugLog("loading types...");
if (OSDictionary *dictionary = OSDynamicCast(OSDictionary, properties->getObject("Types"))) {
if (OSIterator *iterator = OSCollectionIterator::withCollection(dictionary)) {
while (OSString *key = OSDynamicCast(OSString, iterator->getNextObject())) {
if (OSString *value = OSDynamicCast(OSString, dictionary->getObject(key))) {
types->setObject(key, value);
}
}
OSSafeRelease(iterator);
}
}
// Set Clover platform keys
if (OSDictionary *dictionary = OSDynamicCast(OSDictionary, properties->getObject("Clover"))) {
UInt32 count = 0;
if (IORegistryEntry* cloverPlatformNode = fromPath("/efi/platform", gIODTPlane)) {
if (OSIterator *iterator = OSCollectionIterator::withCollection(dictionary)) {
while (OSString *name = OSDynamicCast(OSString, iterator->getNextObject())) {
if (OSData *data = OSDynamicCast(OSData, cloverPlatformNode->getProperty(name))) {
if (OSArray *items = OSDynamicCast(OSArray, dictionary->getObject(name))) {
OSString *key = OSDynamicCast(OSString, items->getObject(0));
OSString *type = OSDynamicCast(OSString, items->getObject(1));
if (addKeyWithValue(key->getCStringNoCopy(), type->getCStringNoCopy(), data->getLength(), data->getBytesNoCopy()))
count++;
}
}
}
OSSafeRelease(iterator);
}
}
if (count)
HWSensorsInfoLog("%d key%s exported by Clover EFI", count, count == 1 ? "" : "s");
}
// Start SMC device
if (!super::start(platform))
return false;
//.........这里部分代码省略.........
示例14: assert
IORegistryEntry *
IODeviceTreeAlloc( void * dtTop )
{
IORegistryEntry * parent;
IORegistryEntry * child;
IORegistryIterator * regIter;
DTEntryIterator iter;
DTEntry dtChild;
DTEntry mapEntry;
OSArray * stack;
OSData * prop;
OSDictionary * allInts;
vm_offset_t * dtMap;
unsigned int propSize;
bool intMap;
bool freeDT;
gIODTPlane = IORegistryEntry::makePlane( kIODeviceTreePlane );
gIODTNameKey = OSSymbol::withCStringNoCopy( "name" );
gIODTUnitKey = OSSymbol::withCStringNoCopy( "AAPL,unit-string" );
gIODTCompatibleKey = OSSymbol::withCStringNoCopy( "compatible" );
gIODTTypeKey = OSSymbol::withCStringNoCopy( "device_type" );
gIODTModelKey = OSSymbol::withCStringNoCopy( "model" );
gIODTSizeCellKey = OSSymbol::withCStringNoCopy( "#size-cells" );
gIODTAddressCellKey = OSSymbol::withCStringNoCopy( "#address-cells" );
gIODTRangeKey = OSSymbol::withCStringNoCopy( "ranges" );
gIODTPersistKey = OSSymbol::withCStringNoCopy( "IODTPersist" );
assert( gIODTPlane && gIODTCompatibleKey
&& gIODTTypeKey && gIODTModelKey
&& gIODTSizeCellKey && gIODTAddressCellKey && gIODTRangeKey
&& gIODTPersistKey );
gIODTDefaultInterruptController
= OSSymbol::withCStringNoCopy("IOPrimaryInterruptController");
gIODTNWInterruptMappingKey
= OSSymbol::withCStringNoCopy("IONWInterrupts");
gIODTAAPLInterruptsKey
= OSSymbol::withCStringNoCopy("AAPL,interrupts");
gIODTPHandleKey
= OSSymbol::withCStringNoCopy("AAPL,phandle");
gIODTInterruptParentKey
= OSSymbol::withCStringNoCopy("interrupt-parent");
gIODTPHandles = OSArray::withCapacity( 1 );
gIODTPHandleMap = OSArray::withCapacity( 1 );
gIODTInterruptCellKey
= OSSymbol::withCStringNoCopy("#interrupt-cells");
assert( gIODTDefaultInterruptController && gIODTNWInterruptMappingKey
&& gIODTAAPLInterruptsKey
&& gIODTPHandleKey && gIODTInterruptParentKey
&& gIODTPHandles && gIODTPHandleMap
&& gIODTInterruptCellKey
);
freeDT = (kSuccess == DTLookupEntry( 0, "/chosen/memory-map", &mapEntry ))
&& (kSuccess == DTGetProperty( mapEntry,
"DeviceTree", (void **) &dtMap, &propSize ))
&& ((2 * sizeof(uint32_t)) == propSize);
parent = MakeReferenceTable( (DTEntry)dtTop, freeDT );
stack = OSArray::withObjects( (const OSObject **) &parent, 1, 10 );
DTCreateEntryIterator( (DTEntry)dtTop, &iter );
do {
parent = (IORegistryEntry *)stack->getObject( stack->getCount() - 1);
//parent->release();
stack->removeObject( stack->getCount() - 1);
while( kSuccess == DTIterateEntries( iter, &dtChild) ) {
child = MakeReferenceTable( dtChild, freeDT );
child->attachToParent( parent, gIODTPlane);
AddPHandle( child );
if( kSuccess == DTEnterEntry( iter, dtChild)) {
stack->setObject( parent);
parent = child;
}
// only registry holds retain
child->release();
}
} while( stack->getCount()
&& (kSuccess == DTExitEntry( iter, &dtChild)));
stack->release();
DTDisposeEntryIterator( iter);
// parent is now root of the created tree
// make root name first compatible entry (purely cosmetic)
if( (prop = (OSData *) parent->getProperty( gIODTCompatibleKey))) {
//.........这里部分代码省略.........
示例15: getDependencyListForKmod
/*********************************************************************
* This function builds a uniqued, in-order list of modules that need
* to be loaded in order for kmod_name to be successfully loaded. This
* list ends with kmod_name itself.
*********************************************************************/
static
OSArray * getDependencyListForKmod(const char * kmod_name) {
int error = 0;
OSDictionary * extensionsDict; // don't release
OSDictionary * extDict; // don't release
OSDictionary * extPlist; // don't release
OSString * extName; // don't release
OSArray * dependencyList = NULL; // return value, caller releases
unsigned int i;
/* These are used to remove duplicates from the dependency list.
*/
OSArray * originalList = NULL; // must be released
OSDictionary * encounteredNames = NULL; // must be release
/* Get the dictionary of startup extensions.
* This is keyed by module name.
*/
extensionsDict = getStartupExtensions();
if (!extensionsDict) {
IOLog("getDependencyListForKmod(): No extensions dictionary.\n");
LOG_DELAY();
error = 1;
goto finish;
}
/* Get the requested extension's dictionary entry and its property
* list, containing module dependencies.
*/
extDict = OSDynamicCast(OSDictionary,
extensionsDict->getObject(kmod_name));
if (!extDict) {
IOLog("getDependencyListForKmod(): "
"Extension \"%s\" cannot be found.\n",
kmod_name);
LOG_DELAY();
error = 1;
goto finish;
}
extPlist = OSDynamicCast(OSDictionary, extDict->getObject("plist"));
if (!extPlist) {
IOLog("getDependencyListForKmod(): "
"Extension \"%s\" has no property list.\n",
kmod_name);
LOG_DELAY();
error = 1;
goto finish;
}
/* Verify that the retrieved entry's "CFBundleIdentifier" property exists.
* This will be added to the dependency list.
*/
extName = OSDynamicCast(OSString,
extPlist->getObject("CFBundleIdentifier"));
if (!extName) {
IOLog("getDependencyListForKmod(): "
"Extension \"%s\" has no \"CFBundleIdentifier\" property.\n",
kmod_name);
LOG_DELAY();
error = 1;
goto finish;
}
dependencyList = OSArray::withCapacity(10);
if (!dependencyList) {
IOLog("getDependencyListForKmod(): "
"Couldn't allocate dependency array for extension \"%s\".\n",
kmod_name);
LOG_DELAY();
error = 1;
goto finish;
}
/* Okay, let's get started.
*/
dependencyList->setObject(extName);
/* Here's a slightly tricky bit. This loop iterates through
* the dependency list until it runs off the end. Each time
* through, however, any number of dependencies can be added
* to the end of the list. Eventually some extensions won't
* have any more dependencies, no more names will be added
* to the list, and this loop will terminate.
*/
for (i = 0; i < dependencyList->getCount(); i++) {
//.........这里部分代码省略.........