From 2284462ccf18d4e502b12bf015a3d1800dd4e85c Mon Sep 17 00:00:00 2001 From: ejakowatz Date: Sun, 28 Jul 2002 20:28:00 +0000 Subject: [PATCH] Scripting-related changes. Also indulged in some unwarrented formatting anality. =P git-svn-id: file:///srv/svn/repos/haiku/trunk/current@519 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/app/Application.cpp | 117 ++++++++++++++++++++++++++++++++++- src/kits/app/Looper.cpp | 21 +++++-- 2 files changed, 133 insertions(+), 5 deletions(-) diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp index 2b40fca911..b57e9abbb6 100644 --- a/src/kits/app/Application.cpp +++ b/src/kits/app/Application.cpp @@ -57,6 +57,101 @@ BMessenger be_app_messenger; BResources* BApplication::_app_resources = NULL; BLocker BApplication::_app_resources_lock("_app_resources_lock"); +property_info gApplicationPropInfo[] = +{ + { + "Window", + {}, + {B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER}, + NULL, 0, + {}, + {}, + {} + }, + { + "Window", + {}, + {B_NAME_SPECIFIER}, + NULL, 1, + {}, + {}, + {} + }, + { + "Looper", + {}, + {B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER}, + NULL, 2, + {}, + {}, + {} + }, + { + "Looper", + {}, + {B_ID_SPECIFIER}, + NULL, 3, + {}, + {}, + {} + }, + { + "Looper", + {}, + {B_NAME_SPECIFIER}, + NULL, 4, + {}, + {}, + {} + }, + { + "Name", + {B_GET_PROPERTY}, + {B_DIRECT_SPECIFIER}, + NULL, 5, + {B_STRING_TYPE}, + {}, + {} + }, + { + "Window", + {B_COUNT_PROPERTIES}, + {B_DIRECT_SPECIFIER}, + NULL, 5, + {B_INT32_TYPE}, + {}, + {} + }, + { + "Loopers", + {B_GET_PROPERTY}, + {B_DIRECT_SPECIFIER}, + NULL, 5, + {B_MESSENGER_TYPE}, + {}, + {} + }, + { + "Windows", + {B_GET_PROPERTY}, + {B_DIRECT_SPECIFIER}, + NULL, 5, + {B_MESSENGER_TYPE}, + {}, + {} + }, + { + "Looper", + {B_COUNT_PROPERTIES}, + {B_DIRECT_SPECIFIER}, + NULL, 5, + {B_INT32_TYPE}, + {}, + {} + }, + {} +}; + // argc/argv extern const int __libc_argc; extern const char * const *__libc_argv; @@ -384,7 +479,27 @@ void BApplication::SetPulseRate(bigtime_t rate) //------------------------------------------------------------------------------ status_t BApplication::GetSupportedSuites(BMessage* data) { - return NOT_IMPLEMENTED; + status_t err; + if (!data) + { + err = B_BAD_VALUE; + } + + if (!err) + { + err = data->AddString("Suites", "suite/vnd.Be-application"); + if (!err) + { + BPropertyInfo PropertyInfo(gApplicationPropInfo); + err = data->AddFlat("message", &PropertyInfo); + if (!err) + { + err = BHandler::GetSupportedSuites(data); + } + } + } + + return err; } //------------------------------------------------------------------------------ status_t BApplication::Perform(perform_code d, void* arg) diff --git a/src/kits/app/Looper.cpp b/src/kits/app/Looper.cpp index 853e952c21..9eff0d30e9 100644 --- a/src/kits/app/Looper.cpp +++ b/src/kits/app/Looper.cpp @@ -93,7 +93,7 @@ team_id BLooper::sTeamID = B_ERROR; static property_info gLooperPropInfo[] = { { - "Handler", + "Handler" {}, {B_INDEX_SPECIFIER, B_REVERSE_INDEX_SPECIFIER}, // TODO: what is the extra_data for? @@ -103,7 +103,7 @@ static property_info gLooperPropInfo[] = {} }, { - "Handlers", + "Handlers" {B_GET_PROPERTY}, {B_DIRECT_SPECIFIER}, NULL, 0, @@ -112,7 +112,7 @@ static property_info gLooperPropInfo[] = {} }, { - "Handler", + "Handler" {B_COUNT_PROPERTIES}, {B_DIRECT_SPECIFIER}, NULL, 0, @@ -673,9 +673,22 @@ BHandler* BLooper::ResolveSpecifier(BMessage* msg, int32 index, BMessage* specifier, int32 form, const char* property) { +/** + @note When I was first dumping the results of GetSupportedSuites() from + various classes, the use of the extra_data field was quite + mysterious to me. Then I dumped BApplication and compared the + result against the BeBook's docs for scripting BApplication. A + bunch of it isn't documented, but what is tipped me to the idea + that the extra_data is being used as a quick and dirty way to tell + what scripting "command" has been sent, e.g., for easy use in a + switch statement. Would certainly be a lot faster than a bunch of + string comparisons -- which wouldn't tell the whole story anyway, + because of the same name being used for multiple properties. + */ // Straight from the BeBook BPropertyInfo PropertyInfo(gLooperPropInfo); - if (PropertyInfo.FindMatch(msg, index, specifier, form, property) >= 0) + uint32 data; + if (PropertyInfo.FindMatch(msg, index, specifier, form, property, &data) >= 0) { return this; }