[src] Merge two implementations of converting a FourCC to a string. (#12305)

This commit is contained in:
Rolf Bjarne Kvinge 2021-07-30 18:25:48 +02:00 коммит произвёл GitHub
Родитель 3766cf8fa2
Коммит ebee536ebb
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 19 добавлений и 23 удалений

Просмотреть файл

@ -566,22 +566,13 @@ namespace CoreFoundation {
[DllImport (Constants.CoreFoundationLibrary)]
extern static void CFBundleGetPackageInfo (IntPtr bundle, out uint packageType, out uint packageCreator);
static string FourCCToString (uint code)
{
return new string (new char [] {
(char) (byte) (code >> 24),
(char) (byte) (code >> 16),
(char) (byte) (code >> 8),
(char) (byte) code});
}
public PackageInfo Info {
get {
uint type = 0;
uint creator = 0;
CFBundleGetPackageInfo (handle, out type, out creator);
var creatorStr = FourCCToString (creator);
var creatorStr = Runtime.ToFourCCString (creator);
switch (type) {
case 1095782476: // ""APPL
return new PackageInfo (CFBundle.PackageType.Application, creatorStr);

Просмотреть файл

@ -26,15 +26,6 @@ namespace Foundation {
NSScriptCommandDescriptionDictionary description = null;
static string ToFourCCString (int value)
{
return new string (new char [] {
(char) (byte) (value >> 24),
(char) (byte) (value >> 16),
(char) (byte) (value >> 8),
(char) (byte) value });
}
static int ToIntValue (string fourCC)
{
if (fourCC.Length != 4)
@ -91,11 +82,11 @@ namespace Foundation {
}
public string AppleEventClassCode {
get { return ToFourCCString (FCCAppleEventClassCode); }
get { return Runtime.ToFourCCString (FCCAppleEventClassCode); }
}
public string AppleEventCode {
get { return ToFourCCString (FCCAppleEventCode); }
get { return Runtime.ToFourCCString (FCCAppleEventCode); }
}
public string GetTypeForArgument (string name)
@ -115,7 +106,7 @@ namespace Foundation {
throw new ArgumentNullException (name);
using (var nsName = new NSString (name)) {
return ToFourCCString (FCCAppleEventCodeForArgument (nsName));
return Runtime.ToFourCCString (FCCAppleEventCodeForArgument (nsName));
}
}
@ -127,7 +118,7 @@ namespace Foundation {
}
public string AppleEventCodeForReturnType {
get { return ToFourCCString (FCCAppleEventCodeForReturnType); }
get { return Runtime.ToFourCCString (FCCAppleEventCodeForReturnType); }
}
public NSScriptCommand CreateCommand ()

Просмотреть файл

@ -1712,6 +1712,20 @@ namespace ObjCRuntime {
{
NSLog (string.Format (format, args));
}
internal static string ToFourCCString (uint value)
{
return ToFourCCString (unchecked((int) value));
}
internal static string ToFourCCString (int value)
{
return new string (new char [] {
(char) (byte) (value >> 24),
(char) (byte) (value >> 16),
(char) (byte) (value >> 8),
(char) (byte) value });
}
#endif // !COREBUILD
static int MajorVersion = -1;