本文整理汇总了C++中OSNumber类的典型用法代码示例。如果您正苦于以下问题:C++ OSNumber类的具体用法?C++ OSNumber怎么用?C++ OSNumber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OSNumber类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OSDynamicCast
bool iTCOWatchdog::init (OSDictionary* dict)
{
OSNumber *nkey;
OSBoolean *bkey;
bool res;
//DbgPrint(drvid, "init\n");
res = super::init(dict);
Timeout = DEFAULT_TIMEOUT;
SelfFeeding = false;
WorkaroundBug = false;
if ((conf = OSDynamicCast(OSDictionary, getProperty("Settings"))) &&
(nkey = OSDynamicCast(OSNumber, conf->getObject("Timeout"))))
Timeout = nkey->unsigned32BitValue();
if (conf && (bkey = OSDynamicCast(OSBoolean, conf->getObject("SelfFeeding"))))
SelfFeeding = bkey->isTrue();
if (conf && (bkey = OSDynamicCast(OSBoolean, conf->getObject("UnsafeWorkaroundBIOSBug"))))
WorkaroundBug = bkey->isTrue();
first_run = true;
is_active = SMIWereEnabled = false;
GCSMem.range = NULL; GCSMem.map = NULL;
lock = IOSimpleLockAlloc();
return res;
}
示例2: OSDynamicCast
// Read the settings from the registry
void Xbox360Peripheral::readSettings(void)
{
OSBoolean *value = NULL;
OSNumber *number = NULL;
OSDictionary *dataDictionary = OSDynamicCast(OSDictionary, getProperty(kDriverSettingKey));
if (dataDictionary == NULL) return;
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftX"));
if (value != NULL) invertLeftX = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertLeftY"));
if (value != NULL) invertLeftY = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightX"));
if (value != NULL) invertRightX = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("InvertRightY"));
if (value != NULL) invertRightY = value->getValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneLeft"));
if (number != NULL) deadzoneLeft = number->unsigned32BitValue();
number = OSDynamicCast(OSNumber, dataDictionary->getObject("DeadzoneRight"));
if (number != NULL) deadzoneRight = number->unsigned32BitValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeLeft"));
if (value != NULL) relativeLeft = value->getValue();
value = OSDynamicCast(OSBoolean, dataDictionary->getObject("RelativeRight"));
if (value != NULL) relativeRight=value->getValue();
#if 0
IOLog("Xbox360Peripheral preferences loaded:\n invertLeft X: %s, Y: %s\n invertRight X: %s, Y:%s\n deadzone Left: %d, Right: %d\n\n",
invertLeftX?"True":"False",invertLeftY?"True":"False",
invertRightX?"True":"False",invertRightY?"True":"False",
deadzoneLeft,deadzoneRight);
#endif
}
示例3: return
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 );
}
示例4: memcpy
int VoodooI2CHIDDevice::i2c_hid_acpi_pdata(i2c_hid *ihid) {
UInt32 guid_1 = 0x3CDFF6F7;
UInt32 guid_2 = 0x45554267;
UInt32 guid_3 = 0x0AB305AD;
UInt32 guid_4 = 0xDE38893D;
OSObject *result = NULL;
OSObject *params[3];
char buffer[16];
memcpy(buffer, &guid_1, 4);
memcpy(buffer + 4, &guid_2, 4);
memcpy(buffer + 8, &guid_3, 4);
memcpy(buffer + 12, &guid_4, 4);
params[0] = OSData::withBytes(buffer, 16);
params[1] = OSNumber::withNumber(0x1, 8);
params[2] = OSNumber::withNumber(0x1, 8);
ihid->client->provider->evaluateObject("_DSM", &result, params, 3);
OSNumber* number = OSDynamicCast(OSNumber, result);
ihid->pdata.hid_descriptor_address = number->unsigned32BitValue();
number->release();
params[0]->release();
params[1]->release();
params[2]->release();
return 0;
}
示例5: GetOwnerProvider
OSNumber* Xbox360ControllerClass::newLocationIDNumber() const
{
IOUSBDevice *device;
OSNumber *number;
UInt32 location = 0;
device = GetOwnerProvider(this);
if (device)
{
if ((number = OSDynamicCast(OSNumber, device->getProperty("locationID"))))
{
location = number->unsigned32BitValue();
}
else
{
// Make up an address
if ((number = OSDynamicCast(OSNumber, device->getProperty("USB Address"))))
location |= number->unsigned8BitValue() << 24;
if ((number = OSDynamicCast(OSNumber, device->getProperty("idProduct"))))
location |= number->unsigned8BitValue() << 16;
}
}
return (location != 0) ? OSNumber::withNumber(location, 32) : 0;
}
示例6: OSDynamicCast
IOReturn ApplePS2SynapticsTouchPad::setParamProperties( OSDictionary * dict )
{
OSNumber * clicking = OSDynamicCast( OSNumber, dict->getObject("Clicking") );
if ( clicking )
{
UInt8 newModeByteValue = clicking->unsigned32BitValue() & 0x1 ?
kModeByteValueGesturesEnabled :
kModeByteValueGesturesDisabled;
if (_touchPadModeByte != newModeByteValue)
{
_touchPadModeByte = newModeByteValue;
//
// Write the TouchPad mode byte value.
//
setTouchPadModeByte(_touchPadModeByte, true);
//
// Advertise the current state of the tapping feature.
//
setProperty("Clicking", clicking);
}
}
return super::setParamProperties(dict);
}
示例7: sizeof
bool IOAudioSelectorControl::init(SInt32 initialValue,
UInt32 channelID,
const char *channelName,
UInt32 cntrlID,
UInt32 subType,
UInt32 usage,
OSDictionary *properties)
{
bool result = false;
OSNumber *number;
number = OSNumber::withNumber(initialValue, sizeof(SInt32)*8);
if (number) {
result = super::init(kIOAudioControlTypeSelector,
number,
channelID,
channelName,
cntrlID,
subType,
usage,
properties);
number->release();
}
if (result) {
availableSelections = OSArray::withCapacity(2);
setProperty(kIOAudioSelectorControlAvailableSelectionsKey, availableSelections);
}
return result;
}
示例8: assert
bool
IOEthernetInterface::setFilters(
OSDictionary * dict,
const OSSymbol * group,
UInt32 filters )
{
OSNumber * num;
bool ret = false;
assert( dict && group );
num = (OSNumber *) dict->getObject(group);
if ( num == 0 )
{
if (( num = OSNumber::withNumber(filters, 32) ))
{
ret = dict->setObject(group, num);
num->release();
}
}
else
{
num->setValue(filters);
ret = true;
}
return ret;
}
示例9: assert
bool IOAudioSelectorControl::valueExists(SInt32 selectionValue)
{
bool found = false;
OSCollectionIterator *iterator;
assert(availableSelections);
iterator = OSCollectionIterator::withCollection(availableSelections);
if (iterator) {
OSDictionary *selection;
while ( (selection = (OSDictionary *)iterator->getNextObject()) ) {
OSNumber *sValue;
sValue = (OSNumber *)selection->getObject(kIOAudioSelectorControlSelectionValueKey);
if (sValue && ((SInt32)sValue->unsigned32BitValue() == selectionValue)) {
found = true;
break;
}
}
iterator->release();
}
return found;
}
示例10: OSDynamicCast
IOReturn IOAudioLevelControl::validateValue(OSObject *newValue)
{
IOReturn result = kIOReturnBadArgument;
OSNumber *number;
number = OSDynamicCast(OSNumber, newValue);
DbgLog("+ IOAudioLevelControl::validateValue[%p] (%p)\n", this, newValue);
if (number) {
SInt32 newIntValue;
newIntValue = (SInt32)number->unsigned32BitValue();
DbgLog(" IOAudioLevelControl::validateValue[%p] - newIntValue = %ld, min = %ld, max = %ld\n", this, (long int)newIntValue, (long int)minValue, (long int)maxValue);
if ((newIntValue >= minValue) && (newIntValue <= maxValue)) {
result = kIOReturnSuccess;
} else {
result = kIOReturnError;
}
}
DbgLog("- IOAudioLevelControl::validateValue[%p] (%p) returns 0x%lX\n", this, newValue, (long unsigned int)result );
return result;
}
示例11: createAuxiliary
bool IOFireWireNub::init( OSDictionary * propTable )
{
bool success = true;
OSNumber *offset;
if( !IOService::init(propTable) )
{
success = false;
}
if( success )
{
fAuxiliary = createAuxiliary();
if( fAuxiliary == NULL )
success = false;
}
if( success )
{
offset = OSDynamicCast(OSNumber, propTable->getObject("GUID"));
if( offset )
fUniqueID = offset->unsigned64BitValue();
fConfigDirectorySet = OSSet::withCapacity(1);
if( fConfigDirectorySet == NULL )
success = false;
}
return success;
}
示例12: sizeof
bool IOAudioLevelControl::init(SInt32 initialValue,
SInt32 minValue,
SInt32 maxValue,
IOFixed minDB,
IOFixed maxDB,
UInt32 channelID,
const char *channelName,
UInt32 cntrlID,
UInt32 subType,
UInt32 usage,
OSDictionary *properties)
{
bool result = true;
OSNumber *number;
number = OSNumber::withNumber(initialValue, sizeof(SInt32)*8);
if ((number == NULL) || !super::init(kIOAudioControlTypeLevel, number, channelID, channelName, cntrlID, subType, usage, properties)) {
result = false;
goto Done;
}
setMinValue(minValue);
setMaxValue(maxValue);
setMinDB(minDB);
setMaxDB(maxDB);
Done:
if (number) {
number->release();
}
return result;
}
示例13: OSDynamicCast
// GetPlistValue
UInt32
VoodooPState::getPlistValue(OSDictionary * dictionary,
const char * symbol)
{
OSObject * object = 0;
OSBoolean * boolean = false;
OSNumber * number = 0;
OSString * string = 0;
object = dictionary->getObject(symbol);
if (object && (OSTypeIDInst(object) == OSTypeID(OSBoolean)))
{
boolean = OSDynamicCast(OSBoolean, object);
return boolean->getValue();
}
if (object && (OSTypeIDInst(object) == OSTypeID(OSNumber)))
{
number = OSDynamicCast(OSNumber, object);
return number->unsigned32BitValue();
}
if (object && (OSTypeIDInst(object) == OSTypeID(OSString)))
{
string = OSDynamicCast(OSString, object);
// Implement string to number conversion
}
return 0;
}
示例14: OSDynamicCast
bool IOBSDConsole::publishNotificationHandler(
IOBSDConsole * self,
void * ref,
IOService * newService )
{
IOHIKeyboard * keyboard = 0;
IOService * audio = 0;
if( ref) {
audio = OSDynamicCast(IOService, newService->metaCast("IOAudioStream"));
if (audio != 0) {
OSNumber *out = newService->copyProperty("Out");
if (OSDynamicCast(OSNumber, out)) {
if (out->unsigned8BitValue() == 1) {
self->fAudioOut = newService;
}
}
OSSafeReleaseNULL(out);
}
} else {
audio = 0;
keyboard = OSDynamicCast( IOHIKeyboard, newService );
if( keyboard && self->attach( keyboard )) {
self->arbitrateForKeyboard( keyboard );
}
if( newService->metaCast("IODisplayWrangler"))
self->displayManager = newService;
}
return true;
}
示例15: OSDynamicCast
bool AppleLVMGroup::addMember(AppleRAIDMember * member)
{
if (super::addMember(member) == false) return false;
OSNumber * number = OSDynamicCast(OSNumber, member->getHeaderProperty(kAppleRAIDChunkCountKey));
if (!number) return false;
UInt64 memberBlockCount = number->unsigned64BitValue();
UInt32 memberIndex = member->getMemberIndex();
arMemberBlockCounts[memberIndex] = memberBlockCount;
// total up the block count as we go
arSetBlockCount += memberBlockCount;
arSetMediaSize = arSetBlockCount * arSetBlockSize;
// read the TOC on this member
IOBufferMemoryDescriptor * newPrimaryBuffer = readPrimaryMetaData(member);
if (newPrimaryBuffer && arPrimaryBuffer != newPrimaryBuffer) {
if (arPrimaryBuffer) arPrimaryBuffer->release();
arPrimaryBuffer = newPrimaryBuffer;
}
// scan the logical volumes in start
return true;
}