-
Notifications
You must be signed in to change notification settings - Fork 176
"using namespace ApiWrap" 削除 #2183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"using namespace ApiWrap" 削除 #2183
Conversation
|
berryzplus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
「修正行数が多すぎて、まともにレビューできない(Pull Requestに問題がある)」の一時判断を付けときます。
|
|
||
| ::SetDlgItemInt( hwndCancel, IDC_STATIC_HITCOUNT, 0, FALSE ); | ||
| ::DlgItem_SetText( hwndCancel, IDC_STATIC_CURFILE, L" " ); // 2002/09/09 Moca add | ||
| ApiWrap::DlgItem_SetText( hwndCancel, IDC_STATIC_CURFILE, L" " ); // 2002/09/09 Moca add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
指摘じゃないです。
| ApiWrap::DlgItem_SetText( hwndCancel, IDC_STATIC_CURFILE, L" " ); // 2002/09/09 Moca add | |
| ::SetDlgItemTextW(hwndCancel, IDC_STATIC_CURFILE, L" "); |
と書けるように独自関数を定義してやると、読みやすくなるんじゃないかと思ってます。
bool SetDlgItemTextW(HWND hWndDlg, int nDlgItemId, std::wstring_view text) noexcept;みたいな独自関数を util/window.h あたりに入れてはどうか、という意味ね。
現状の ApiWrap は「なんでAPIをラップしてるか?」が曖昧だと思ってます。
「Windows APIが扱いづらくてラップしたんじゃねぇのかよ」のツッコミ待ちに見える。
| if( HIWORD(lResult) == 0 ){ // クライアントエリア内 | ||
| if( uMsg == WM_LBUTTONDOWN ){ | ||
| List_SetCurSel( hwnd, LOWORD(lResult) ); | ||
| ApiWrap::List_SetCurSel( hwnd, LOWORD(lResult) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
指摘じゃないです。
Windowsには ListBox と ListView があるので、List_XXX は紛らわしいと思います。
また、 ListBox にコントロールメッセージを送る方法は、 windowsx.h で提供されてます。
マクロですが。
| if( 0 < nTextLen ) { | ||
| WCHAR* pszText = new WCHAR[nTextLen + 1]; | ||
| Combo_GetLBText( hwndCtl, iItem, pszText ); | ||
| ApiWrap::Combo_GetLBText( hwndCtl, iItem, pszText ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
指摘じゃないです。
| ApiWrap::Combo_GetLBText( hwndCtl, iItem, pszText ); | |
| ::GetCbItemTextW(hwndCtl, iItem, pszText); |
みたいに書けるとイメージしやすいのかな。
int GetCbItemTextW(HWND hWndDlg, int nDlgItemId, int iItem, std::span<WCHAR> buffer) noexcept;
int GetCbItemTextW(HWND hWndComboBox, int iItem, std::span<WCHAR> buffer) noexcept;みたいな独自関数を作る、ということ。
ListBox同様、ComboBoxにもWindows SDKが提供するマクロがあるけど、文字列取得は独自関数を定義したほうがよさげ。
|
参考: ヘッダーファイル内の using namespace ApiWrap; は禁止級のNG行為なので、できれば直したほうがよいです。 「修正量多過ぎ」の対策として採れる方法は2つ。
現状の ApiWrap 関数群は全体的にビミョーなので、「使うのをやめる」が何気に一番合理的かも。 |
berryzplus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
変更量多いけど、新たな問題を作り込む余地はないと判断して approve します。
対応ありがとうございました。


PR対象
カテゴリ
PR の背景
ヘッダファイルに、"using namespace ApiWrap" を記述している。
仕様・動作説明
PR の影響範囲
影響なし。
テスト内容
変更前後でasmが同じことを確認する。
関連 issue, PR
#2064
参考資料
https://google.github.io/styleguide/cppguide.html#Namespaces