当前位置: 首页>>代码示例>>C++>>正文


C++ OSArray类代码示例

本文整理汇总了C++中OSArray的典型用法代码示例。如果您正苦于以下问题:C++ OSArray类的具体用法?C++ OSArray怎么用?C++ OSArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OSArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: debug

/*---------------------------------------------------------------------------
 * 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();
			}
		}
	}
}
开发者ID:ecashin,项目名称:aoe-osx,代码行数:35,代码来源:EInterfaces.cpp

示例2: OSDynamicCast

void SuperIO::LoadConfiguration(IOService* provider) {
	m_Service = provider;
	
	OSBoolean* fanControl = OSDynamicCast(OSBoolean, provider->getProperty("Enable Fan Control"));	
	m_FanControl = fanControl->getValue();
	
	OSBoolean* alternateRegisters = OSDynamicCast(OSBoolean, provider->getProperty("Register number alternative variant"));
	m_AlternateRegisters = alternateRegisters->getValue();
		
	OSArray* fanIDs = OSDynamicCast(OSArray, provider->getProperty("Fan Names"));	
	if (fanIDs) fanIDs = OSArray::withArray(fanIDs);	
    if (fanIDs)  {
		UInt32 count = fanIDs->getCount();
		
		if(count > 5)
			count = 5;
		
		for (UInt32 i = 0; i < count; i++) {
			OSString* name = OSDynamicCast(OSString, fanIDs->getObject(i)); 
			FanName[i] = name->getCStringNoCopy();
		}
		
		fanIDs->release();
    }
}
开发者ID:AppleLife,项目名称:FakeSMC,代码行数:25,代码来源:SuperIO.cpp

示例3: OSDynamicCast

UInt32 ACPIBacklightPanel::queryACPICurentBrightnessLevel()
{
    //DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);

    if (_backlightHandler)
        return _backlightHandler->getBacklightLevel();
    
    UInt32 level = minAC;
    const char* method = _extended ? "XBQC" : "_BQC";
	if (kIOReturnSuccess == backLightDevice->evaluateInteger(method, &level))
	{
		//DbgLog("%s: queryACPICurentBrightnessLevel %s = %d\n", this->getName(), method, level);
        
        OSBoolean * useIdx = OSDynamicCast(OSBoolean, getProperty("BQC use index"));
        if (useIdx && useIdx->isTrue())
        {
            OSArray * levels = queryACPISupportedBrightnessLevels();
            if (levels)
            {
                OSNumber *num = OSDynamicCast(OSNumber, levels->getObject(level));
                if (num)
                    level = num->unsigned32BitValue();
                levels->release();
            }
        }
        //DbgLog("%s: queryACPICurentBrightnessLevel returning %d\n", this->getName(), level);
	}
	else {
		IOLog("ACPIBacklight: Error in queryACPICurentBrightnessLevel %s\n", method);
	}
    //some laptops didn't return anything on startup, return then max value (first entry in _BCL):
	return level;
}
开发者ID:chemschool,项目名称:OS-X-ACPI-Backlight,代码行数:33,代码来源:ACPIBacklight.cpp

示例4: CompareDeviceUsagePairs

bool CompareDeviceUsagePairs( IOService * owner, OSDictionary * matching, SInt32 * score, SInt32 increment)
{
    // We return success if we match the key in the dictionary with the key in
    // the property table, or if the prop isn't present
    //
    OSArray *		pairArray;
    OSDictionary * 	pair;
    bool		matches = true;
    int			count;
    
    pairArray = OSDynamicCast(OSArray, matching->getObject( kIOHIDDeviceUsagePairsKey ));
    
    if (pairArray)
    {
        count = pairArray->getCount();
        
        for (int i=0; i<count; i++)
        {
            if ( !(pair = OSDynamicCast(OSDictionary,pairArray->getObject(i))) )
                continue;
        
            if ( !(matches = CompareDeviceUsage(owner, pair, score, increment)) )
                continue;

            break;
        }
    }
    
    return matches;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:30,代码来源:IOHIDFamilyPrivate.cpp

示例5: 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;
}
开发者ID:cooljeanius,项目名称:Passenger,代码行数:25,代码来源:main.cpp

示例6: OSDynamicCast

void IOCatalogue::initialize(void)
{
    OSArray              * array;
    OSString             * errorString;
    bool		   rc;

    extern const char * gIOKernelConfigTables;

    array = OSDynamicCast(OSArray, OSUnserialize(gIOKernelConfigTables, &errorString));
    if (!array && errorString) {
        IOLog("KernelConfigTables syntax error: %s\n",
              errorString->getCStringNoCopy());
        errorString->release();
    }

    gIOClassKey              = OSSymbol::withCStringNoCopy( kIOClassKey );
    gIOProbeScoreKey 	     = OSSymbol::withCStringNoCopy( kIOProbeScoreKey );
    gIOModuleIdentifierKey   = OSSymbol::withCStringNoCopy( kCFBundleIdentifierKey );

    assert( array && gIOClassKey && gIOProbeScoreKey
            && gIOModuleIdentifierKey);

    gIOCatalogue = new IOCatalogue;
    assert(gIOCatalogue);
    rc = gIOCatalogue->init(array);
    assert(rc);
    array->release();
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例7: 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 );
}
开发者ID:Algozjb,项目名称:xnu,代码行数:27,代码来源:IODeviceMemory.cpp

示例8: CompareNumberPropertyArray

bool CompareNumberPropertyArray( IOService * owner, OSDictionary * matching, const char * arrayName, const char * key, SInt32 * score, SInt32 increment)
{
	OSNumber    *registryProperty = (OSNumber *)owner->copyProperty(key);
    OSArray     *propertyArray = (OSArray *)matching->getObject(arrayName);
    CONVERT_TO_STACK_RETAIN(registryProperty);
	
    // If the property in the matching doesn't exist return true
	if ( OSDynamicCast(OSArray, propertyArray) )
    {
        if ( OSDynamicCast(OSNumber, registryProperty ) )
        {
            OSNumber *propertyFromArray;
            int i = 0;
            
            for ( i = 0; i < propertyArray->getCount(); i ++ )
            {
                propertyFromArray = OSDynamicCast(OSNumber, propertyArray->getObject(i));
                if ( propertyFromArray && propertyFromArray->isEqualTo(registryProperty) )
                {
                    if ( score )
                        *score += increment;
                    return true;
                }
            }
        }
    }
    else
        return true;
    
	return false;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:31,代码来源:IOHIDFamilyPrivate.cpp

示例9:

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;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:30,代码来源:IOHIDInterface.cpp

示例10: 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 );
}
开发者ID:Algozjb,项目名称:xnu,代码行数:32,代码来源:IORangeAllocator.cpp

示例11: DbgLog

UInt32 ACPIBacklightPanel::setupIndexedLevels()
{
    DbgLog("%s::%s()\n", this->getName(),__FUNCTION__);
    
	OSNumber * num;
	OSArray * levels = queryACPISupportedBrightnessLevels();
	if (levels)
	{
		BCLlevelsCount = levels->getCount();
		
		if (BCLlevelsCount < 3)
			return 0;
		
		//verify the types of objects is good once for all
		for (int i = 0; i< BCLlevelsCount; i++) {
			if (!OSDynamicCast(OSNumber, levels->getObject(i)))
				return 0;
		}
		
        //TODO : manage the case when the list has no order! Linux do that
		//test the order of the list
		UInt32 min, max;
		num = OSDynamicCast(OSNumber, levels->getObject(2));
		min = num->unsigned32BitValue();
		num = OSDynamicCast(OSNumber, levels->getObject(BCLlevelsCount-1));
		max = num->unsigned32BitValue();
		
		if (max < min) //list is reverted !
		{
			BCLlevels = new UInt32[BCLlevelsCount];
			for (int i = 0; i< BCLlevelsCount; i++) {
				num = OSDynamicCast(OSNumber, levels->getObject(BCLlevelsCount -1 -i));
				BCLlevels[i] = num->unsigned32BitValue();
			}
		}
		else
		{
			BCLlevelsCount = BCLlevelsCount -2;
			BCLlevels = new UInt32[BCLlevelsCount];
			for (int i = 0; i< BCLlevelsCount; i++) {
				num = OSDynamicCast(OSNumber, levels->getObject(i+2));
				BCLlevels[i] = num->unsigned32BitValue();
			}
		}

		//2 first items are min on ac and max on bat
		num = OSDynamicCast(OSNumber, levels->getObject(0));
		minAC = findIndexForLevel(num->unsigned32BitValue());
		setDebugProperty("BCL: Min on AC", num);
		num = OSDynamicCast(OSNumber, levels->getObject(1));
		maxBat = findIndexForLevel(num->unsigned32BitValue());
		setDebugProperty("BCL: Max on Bat", num);
		setDebugProperty("Brightness Control Levels", levels);
        levels->release();
		
		return BCLlevelsCount-1;
	}
	return 0;
}
开发者ID:chemschool,项目名称:OS-X-ACPI-Backlight,代码行数:59,代码来源:ACPIBacklight.cpp

示例12: 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;
}
开发者ID:Algozjb,项目名称:xnu,代码行数:58,代码来源:OSSet.cpp

示例13: removePersonalities

bool IOCatalogue::removePersonalities(OSArray * personalitiesToRemove)
{
    bool                   result           = true;
    OSArray              * arrayCopy        = NULL;  // do not release
    OSCollectionIterator * iterator         = NULL;  // must release
    OSDictionary         * personality      = NULL;  // do not release
    OSDictionary         * checkPersonality = NULL;  // do not release
    unsigned int           count, i;

    // remove configs from catalog.

    arrayCopy = OSArray::withArray(array);
    if (!arrayCopy) {
        result = false;
        goto finish;
    }

    iterator = OSCollectionIterator::withCollection(arrayCopy);
    arrayCopy->release();
    if (!iterator) {
        result = false;
        goto finish;
    }

    array->flushCollection();

    count = personalitiesToRemove->getCount();

    /* Go through the old catalog's list of personalities and add back any that
     * are *not* found in 'personalitiesToRemove'.
     */
    while ((personality = (OSDictionary *)iterator->getNextObject())) {
        bool found = false;

        for (i = 0; i < count; i++) {
            checkPersonality = OSDynamicCast(OSDictionary,
                                             personalitiesToRemove->getObject(i));

            /* Do isEqualTo() with the single-arg version to make an exact
             * comparison (unlike _removeDrivers() above).
             */
            if (personality->isEqualTo(checkPersonality)) {
                found = true;
                break;
            }
        }

        if (!found) {
            array->setObject(personality);
        }
    }

finish:

    OSSafeRelease(iterator);
    return result;
}
开发者ID:,项目名称:,代码行数:57,代码来源:

示例14: OSDynamicCast

//====================================================================================================
// IOHIDEventOverrideDriver::dispatchKeyboardEvent
//====================================================================================================
bool IOHIDEventOverrideDriver::handleStart( IOService * provider )
{
    OSArray * maps = NULL;
    
    if ( !super::handleStart(provider) )
        return false;
    
    maps = OSDynamicCast(OSArray, getProperty("ButtonMaps"));
    if ( maps ) {
        int index;
        
        for ( index=0; index<maps->getCount(); index++ ) {
            OSDictionary *  map;
            OSNumber *      number;
            uint32_t        button;
            uint32_t        usagePage;
            uint32_t        usage;
            uint32_t        eventType;
            
            map = OSDynamicCast(OSDictionary, maps->getObject(index));
            if ( !map )
                continue;
            
            number = OSDynamicCast(OSNumber, map->getObject("ButtonNumber"));
            if ( !number )
                continue;
            
            button = number->unsigned32BitValue();
            if ( !button || button>32 )
                continue;
            
            number = OSDynamicCast(OSNumber, map->getObject("EventType"));
            if ( !number )
                continue;
            
            eventType = number->unsigned32BitValue();
            
            number = OSDynamicCast(OSNumber, map->getObject("UsagePage"));
            if ( !number )
                continue;
            
            usagePage = number->unsigned32BitValue();

            number = OSDynamicCast(OSNumber, map->getObject("Usage"));
            if ( !number )
                continue;
            
            usage = number->unsigned32BitValue();
            
            _buttonMap[button-1].eventType  = eventType;
            _buttonMap[button-1].usagePage  = usagePage;
            _buttonMap[button-1].usage      = usage;
        }
    }
    
    return true;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:60,代码来源:IOHIDEventOverrideDriver.cpp

示例15: 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;
}
开发者ID:EMlyDinEsHMG,项目名称:IOAudioFamily-Sleep-Audio-FIx,代码行数:58,代码来源:IOAudioSelectorControl.cpp


注:本文中的OSArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。