|
|
Log In | Not a Member? |
Contact ADC |
| < Previous PageNext Page > |
このセクションで説明する変更を加えると、LStreamが必ずデータをビッグエンディアンとして読み書きするようになります。これらの変更を行うと、以下の結果が得られます。
PPobリソースがPowerPCベースおよびインテルベースのMacintoshで正しく機能します。ただし、アプリケーションが使用しているカスタムのタイプは対象外となる可能性があります。カスタムのタイプも、使用するLStreamコンストラクタがバイト操作メソッドではなく、LStreamのストリーミングメソッドを採用していれば正しく機能します。
ディスクまたはネットワークとの間で読み書きされ、LStreamを使用して書き込まれるデータは、Listing D-1に示すメソッドの呼び出しを除いて、PowerPCベースのMacintoshとインテルベースのMacintoshとの間で移植性を持つようになります。リスト内のメソッドを呼び出す場合は、コードの中でバイトをビッグエンディアンフォーマットに変換するか、LStreamのストリーミングメソッドを使用する方法に切り替えてください。
バイトスワップが必要かどうかを確認するには、必ずListing D-1内のすべてのメソッド呼び出し(これらのメソッドのサブクラス化されたバージョンへの呼び出しもすべて含む)を評価します。
Listing D-1 バイトスワップを必要とする可能性がある呼び出し
LStream::PutBytes |
LStream::WriteData |
LStream::WriteBlock |
LStream::operator << (Handle inHandle) |
LStream::GetBytes |
LStream::ReadData |
LStream::ReadBlock |
LStream::PeekData |
LStream::operator >> (Handle &outHandle) |
LStream::WritePtr |
LStream::ReadPtr |
LStream::WriteHandle |
LStream::ReadHandle |
PPobリソースにカスタムクラスがある場合は、LStream::ReadDataの呼び出しを避けるためにLStreamコンストラクタを変更してください。具体的には、LControl、LListBox、およびほかのPowerPlantクラスのLStreamコンストラクタを以下の各セクションで変更するのと同様に、コードを変更する必要があります。変更する必要があるファイル別に分類したセクションで、必要なコード変更について説明します。
単一のWriteBlock呼び出しのoperator << (const Rect &inRect)メソッドを以下のとおり変更します。
Rect rect; |
rect.top = CFSwapInt16HostToBig(inRect.top); |
rect.left = CFSwapInt16HostToBig(inRect.left); |
rect.right= CFSwapInt16HostToBig(inRect.right); |
rect.bottom = CFSwapInt16HostToBig(inRect.bottom); |
WriteBlock(&rect, sizeof(rect)); |
単一のWriteBlock呼び出しのoperator << (const Point &inPoint)メソッドを以下のとおり変更します。
Point pt; |
pt.v = CFSwapInt16HostToBig(inPoint.v); |
pt.h = CFSwapInt16HostToBig(inPoint.h); |
WriteBlock(&pt, sizeof(pt)); |
単一のWriteBlock呼び出しのoperator << (SInt16 inNum)メソッドを以下のとおり変更します。
SInt16 n; |
n = CFSwapInt16HostToBig(inNum); |
WriteBlock(&n, sizeof(n)); |
単一のWriteBlock呼び出しのoperator << (UInt16 inNum)メソッドを以下のとおり変更します。
UInt16 n; |
n = CFSwapInt16HostToBig(inNum); |
WriteBlock(&n, sizeof(n)); |
単一のWriteBlock呼び出しのoperator << (SInt32 inNum)メソッドを以下のとおり変更します。
SInt32 n; |
n = CFSwapInt32HostToBig(inNum); |
WriteBlock(&n, sizeof(n)); |
単一のWriteBlock呼び出しのoperator << (UInt32 inNum)メソッドを以下のとおり変更します。
UInt32 n; |
n = CFSwapInt32HostToBig(inNum); |
WriteBlock(&n, sizeof(n)); |
単一のWriteBlock呼び出しのoperator << (float inNum)メソッドを以下のとおり変更します。
CFSwappedFloat32 swappedFloat; |
swappedFloat = CFConvertFloat32HostToSwapped(inNum); |
WriteBlock(&swappedFloat, sizeof(swappedFloat)); |
単一のWriteBlock呼び出しのoperator << (bool inBool)メソッドを以下のとおり変更します。
UInt32 boolValue; |
boolValue = CFSwapInt32HostToBig(inBool); |
WriteBlock(&boolValue, sizeof(boolValue)); |
operator >> (Rect &outRect)メソッドで、ReadBlock呼び出しの後に以下を追加します。
outRect.top = CFSwapInt16BigToHost(outRect.top); |
outRect.left = CFSwapInt16BigToHost(outRect.left); |
outRect.right= CFSwapInt16BigToHost(outRect.right); |
outRect.bottom = CFSwapInt16BigToHost(outRect.bottom); |
operator >> (Point &outPoint)メソッドで、ReadBlock呼び出しの後に以下を追加します。
outPoint.v = CFSwapInt16BigToHost(outPoint.v); |
outPoint.h = CFSwapInt16BigToHost(outPoint.h); |
operator >> (SInt16 &outNum)メソッドで、ReadBlock呼び出しの後に以下を追加します。
outNum = CFSwapInt16BigToHost(outNum);
operator >> (UInt16 &outNum)メソッドで、ReadBlock呼び出しの後に以下を追加します。
outNum = CFSwapInt16BigToHost(outNum);
operator >> (SInt32 &outNum)メソッドで、ReadBlock呼び出しの後に以下を追加します。
outNum = CFSwapInt32BigToHost(outNum);
operator >> (UInt32 &outNum)メソッドで、ReadBlock呼び出しの後に以下を追加します。
outNum = CFSwapInt32BigToHost(outNum);
operator >> (float &outNum)メソッドで、ReadBlock呼び出しの後に以下を追加します。
CFSwappedFloat32 swappedFloat; |
ReadBlock(&swappedFloat, sizeof(swappedFloat)); |
outNum = CFConvertFloat32SwappedToHost(swappedFloat); |
operator >> (bool &outBool)メソッドで、ReadBlock呼び出しの後に以下を追加します。
UInt32 boolValue; |
ReadBlock(&boolValue, sizeof(boolValue)); |
outBool = CFSwapInt32BigToHost(boolValue); |
operator << (double inNum)メソッドで、#if TARGET_CPU_PPCブロックを以下のとおり変更します。
#if TARGET_CPU_PPC || TARGET_CPU_X86 |
// PowerPCとインテルのdouble -- これらはすでに8バイトなので、 |
// 必要に応じてスワップして書き込む。 |
Assert_(sizeof(inNum) == 8); |
CFSwappedFloat64 swappedDouble = CFConvertDoubleHostToSwapped(inNum); |
WriteBlock(&swappedDouble, sizeof(swappedDouble)); |
operator >> (double& outNum)メソッドで、#if TARGET_CPU_PPCブロックを以下のとおり変更します。
#if TARGET_CPU_PPC || TARGET_CPU_X86 |
// PowerPCとインテルの double -- これらはすでに8バイトなので、 |
// 必要に応じて読み取ってスワップする。 |
Assert_(sizeof(outNum) == 8); |
CFSwappedFloat64 swappedDouble; |
ReadBlock(&swappedDouble, sizeof(swappedDouble)); |
outNum = CFConvertDoubleSwappedToHost(swappedDouble); |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&controlInfo, sizeof(SControlInfo));
以下の行に置き換えます。
*inStream >> controlInfo.valueMessage; |
*inStream >> controlInfo.value; |
*inStream >> controlInfo.minValue; |
*inStream >> controlInfo.maxValue; |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&listInfo, sizeof(SListBoxInfo));
以下の行に置き換えます。
*inStream >> listInfo.hasHorizScroll; |
*inStream >> listInfo.hasVertScroll; |
*inStream >> listInfo.hasGrow; |
*inStream >> listInfo.hasFocusBox; |
*inStream >> listInfo.doubleClickMessage; |
*inStream >> listInfo.textTraitsID; |
*inStream >> listInfo.LDEFid; |
*inStream >> listInfo.numberOfItems; |
RestorePlace(LStream *inPlace)メソッドで、次の行を置き換えます。
inPlace->ReadData(&theRect, sizeof(Rect)); |
以下の行に置き換えます。
*inPlace >> theRect;
このメソッドをずっと下にスクロールして、if (vScroll != nil)という行のすぐ下にある次の行を置き換えます。
inPlace->ReadData(&theRect, sizeof(Rect));
以下の行に置き換えます。
*inPlace >> theRect;
もう一度同じメソッドの中で、if (hScroll != nil)という行のすぐ下にある次の行を置き換えます。
inPlace->ReadData(&theRect, sizeof(Rect));
以下の行に置き換えます。
*inPlace >> theRect;
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&thePaneInfo, sizeof(SPaneInfo));
以下の行に置き換えます。
SInt32 viewPtr; |
*inStream >> thePaneInfo.paneID; |
*inStream >> thePaneInfo.width; |
*inStream >> thePaneInfo.height; |
*inStream >> thePaneInfo.visible; |
*inStream >> thePaneInfo.enabled; |
*inStream >> thePaneInfo.bindings.left; |
*inStream >> thePaneInfo.bindings.top; |
*inStream >> thePaneInfo.bindings.right; |
*inStream >> thePaneInfo.bindings.bottom; |
*inStream >> thePaneInfo.left; |
*inStream >> thePaneInfo.top; |
*inStream >> thePaneInfo.userCon; |
*inStream >> viewPtr; |
thePaneInfo.superView = reinterpret_cast<LView *>(viewPtr); |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&thePrintoutInfo, sizeof(SPrintoutInfo));
以下の行に置き換えます。
*inStream >> thePrintoutInfo.width; |
*inStream >> thePrintoutInfo.height; |
*inStream >> thePrintoutInfo.active; |
*inStream >> thePrintoutInfo.enabled; |
*inStream >> thePrintoutInfo.userCon; |
*inStream >> thePrintoutInfo.attributes; |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&scrollerInfo, sizeof(SScrollerInfo));
以下の行に置き換えます。
*inStream >> scrollerInfo.horizBarLeftIndent; |
*inStream >> scrollerInfo.horizBarRightIndent; |
*inStream >> scrollerInfo.vertBarTopIndent; |
*inStream >> scrollerInfo.vertBarBottomIndent; |
*inStream >> scrollerInfo.scrollingViewID; |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&tableInfo, sizeof(STableInfo));
以下の行に置き換えます。
*inStream >> tableInfo.numberOfRows; |
*inStream >> tableInfo.numberOfCols; |
*inStream >> tableInfo.rowHeight; |
*inStream >> tableInfo.colWidth; |
*inStream >> tableInfo.cellDataSize; |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&viewInfo, sizeof(SViewInfo));
以下の行に置き換えます。
*inStream >> viewInfo.imageSize.width; |
*inStream >> viewInfo.imageSize.height; |
*inStream >> viewInfo.scrollPos.h; |
*inStream >> viewInfo.scrollPos.v; |
*inStream >> viewInfo.scrollUnit.h; |
*inStream >> viewInfo.scrollUnit.v; |
*inStream >> viewInfo.reconcileOverhang; |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&windowInfo, sizeof(SWindowInfo));
以下の行に置き換えます。
*inStream >> windowInfo.WINDid; |
*inStream >> windowInfo.layer; |
*inStream >> windowInfo.attributes; |
*inStream >> windowInfo.minimumWidth; |
*inStream >> windowInfo.minimumHeight; |
*inStream >> windowInfo.maximumWidth; |
*inStream >> windowInfo.maximumHeight; |
*inStream >> windowInfo.standardSize.width; |
*inStream >> windowInfo.standardSize.height; |
*inStream >> windowInfo.userCon; |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&cInfo, sizeof(SControlInfo));
以下の行に置き換えます。
*inStream >> cInfo.valueMessage; |
*inStream >> cInfo.value; |
*inStream >> cInfo.minValue; |
*inStream >> cInfo.maxValue; |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&cInfo, sizeof(SControlInfo));
以下の行に置き換えます。
*inStream >> cInfo.valueMessage; |
*inStream >> cInfo.value; |
*inStream >> cInfo.minValue; |
*inStream >> cInfo.maxValue; |
LStreamコンストラクタで、次の行を置き換えます。
inStream->ReadData(&scrollerInfo, sizeof(SScrollerViewInfo));
以下の行に置き換えます。
*inStream >> scrollerInfo.horizBarLeftIndent; |
*inStream >> scrollerInfo.horizBarRightIndent; |
*inStream >> scrollerInfo.vertBarTopIndent; |
*inStream >> scrollerInfo.vertBarBottomIndent; |
*inStream >> scrollerInfo.scrollingViewID; |
LStreamコンストラクタで、以下の行を置き換えます。
inStream->ReadData( &mBackColor, sizeof(RGBColor)); |
inStream->ReadData( &mFaceColor, sizeof(RGBColor)); |
inStream->ReadData( &mPushedTextColor, sizeof(RGBColor)); |
以下の行に置き換えます。
*inStream >> mBackColor.red; |
*inStream >> mBackColor.green; |
*inStream >> mBackColor.blue; |
*inStream >> mFaceColor.red; |
*inStream >> mFaceColor.green; |
*inStream >> mFaceColor.blue; |
*inStream >> mPushedTextColor.red; |
*inStream >> mPushedTextColor.green; |
*inStream >> mPushedTextColor.blue; |
| < Previous PageNext Page > |
Last updated: 2006-03-08
|
Get information on Apple products.
Visit the Apple Store online or at retail locations. 1-800-MY-APPLE Copyright © 2007 Apple Inc. All rights reserved. | Terms of use | Privacy Notice |