Skip to content

Commit 651ad8e

Browse files
authored
Merge pull request #893 from s4y/missing-message-string
Add missing message ID string, then refactor to make that harder to repeat
2 parents b906f87 + 3caccbb commit 651ad8e

6 files changed

Lines changed: 113 additions & 197 deletions

File tree

src/MacVim/MMBackend.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ - (oneway void)processInput:(int)msgid data:(in bycopy NSData *)data
13221322
for (i = 1; i < count; i += 2) {
13231323
if ([[inputQueue objectAtIndex:i-1] intValue] == msgid) {
13241324
ASLogDebug(@"Input queue filling up, remove message: %s",
1325-
MessageStrings[msgid]);
1325+
MMVimMsgIDStrings[msgid]);
13261326
[inputQueue removeObjectAtIndex:i];
13271327
[inputQueue removeObjectAtIndex:i-1];
13281328
break;
@@ -1860,7 +1860,7 @@ - (void)processInputQueue
18601860
if ([data isEqual:[NSNull null]])
18611861
data = nil;
18621862

1863-
ASLogDebug(@"(%d) %s", i, MessageStrings[msgid]);
1863+
ASLogDebug(@"(%d) %s", i, MMVimMsgIDStrings[msgid]);
18641864
[self handleInputEvent:msgid data:data];
18651865
}
18661866

src/MacVim/MMVimController.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ - (void)passArguments:(NSDictionary *)args
351351
- (void)sendMessage:(int)msgid data:(NSData *)data
352352
{
353353
ASLogDebug(@"msg=%s (isInitialized=%d)",
354-
MessageStrings[msgid], isInitialized);
354+
MMVimMsgIDStrings[msgid], isInitialized);
355355

356356
if (!isInitialized) return;
357357

@@ -360,7 +360,7 @@ - (void)sendMessage:(int)msgid data:(NSData *)data
360360
}
361361
@catch (NSException *ex) {
362362
ASLogDebug(@"processInput:data: failed: pid=%d id=%d msg=%s reason=%@",
363-
pid, identifier, MessageStrings[msgid], ex);
363+
pid, identifier, MMVimMsgIDStrings[msgid], ex);
364364
}
365365
}
366366

@@ -373,7 +373,7 @@ - (BOOL)sendMessageNow:(int)msgid data:(NSData *)data
373373
// used instead.
374374

375375
ASLogDebug(@"msg=%s (isInitialized=%d)",
376-
MessageStrings[msgid], isInitialized);
376+
MMVimMsgIDStrings[msgid], isInitialized);
377377

378378
if (!isInitialized)
379379
return NO;
@@ -392,7 +392,7 @@ - (BOOL)sendMessageNow:(int)msgid data:(NSData *)data
392392
@catch (NSException *ex) {
393393
sendOk = NO;
394394
ASLogDebug(@"processInput:data: failed: pid=%d id=%d msg=%s reason=%@",
395-
pid, identifier, MessageStrings[msgid], ex);
395+
pid, identifier, MMVimMsgIDStrings[msgid], ex);
396396
}
397397
@finally {
398398
[conn setRequestTimeout:oldTimeout];
@@ -587,7 +587,7 @@ - (void)doProcessInputQueue:(NSArray *)queue
587587
delayQueue = [NSMutableArray array];
588588

589589
ASLogDebug(@"Adding unsafe message '%s' to delay queue (mode=%@)",
590-
MessageStrings[msgid],
590+
MMVimMsgIDStrings[msgid],
591591
[[NSRunLoop currentRunLoop] currentMode]);
592592
[delayQueue addObject:value];
593593
[delayQueue addObject:data];

src/MacVim/MMVimView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ - (void)frameSizeMayHaveChanged:(BOOL)keepGUISize
968968

969969
ASLogDebug(@"Notify Vim that text dimensions changed from %dx%d to "
970970
"%dx%d (%s)", cols, rows, constrained[1], constrained[0],
971-
MessageStrings[msgid]);
971+
MMVimMsgIDStrings[msgid]);
972972

973973
if (msgid != LiveResizeMsgID || !self.pendingLiveResize) {
974974
// Live resize messages can be sent really rapidly, especailly if

src/MacVim/MMWindowController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1764,7 +1764,7 @@ - (BOOL)maximizeWindow:(int)options
17641764
}
17651765
NSParameterAssert(data != nil && msgid != 0);
17661766

1767-
ASLogDebug(@"%s: %dx%d", MessageStrings[msgid], fuRows, fuColumns);
1767+
ASLogDebug(@"%s: %dx%d", MMVimMsgIDStrings[msgid], fuRows, fuColumns);
17681768
MMVimController *vc = [self vimController];
17691769
[vc sendMessage:msgid data:data];
17701770
[[vimView textView] setMaxRows:fuRows columns:fuColumns];

src/MacVim/MacVim.h

Lines changed: 99 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -168,102 +168,107 @@
168168
// Vim. These can be sent in processInput:data: and in processCommandQueue:.
169169
//
170170

171-
// NOTE! This array must be updated whenever the enum below changes!
172-
extern char *MessageStrings[];
171+
extern const char * const MMVimMsgIDStrings[];
172+
173+
#define FOREACH_MMVimMsgID(MSG) \
174+
MSG(NullMsgID) \
175+
MSG(OpenWindowMsgID) \
176+
MSG(KeyDownMsgID) \
177+
MSG(BatchDrawMsgID) \
178+
MSG(SelectTabMsgID) \
179+
MSG(CloseTabMsgID) \
180+
MSG(AddNewTabMsgID) \
181+
MSG(DraggedTabMsgID) \
182+
MSG(UpdateTabBarMsgID) \
183+
MSG(ShowTabBarMsgID) \
184+
MSG(HideTabBarMsgID) \
185+
MSG(SetTextRowsMsgID) \
186+
MSG(SetTextColumnsMsgID) \
187+
MSG(SetTextDimensionsMsgID) \
188+
MSG(SetTextDimensionsNoResizeWindowMsgID) \
189+
MSG(LiveResizeMsgID) \
190+
MSG(SetTextDimensionsReplyMsgID) \
191+
MSG(ResizeViewMsgID) \
192+
MSG(SetWindowTitleMsgID) \
193+
MSG(ScrollWheelMsgID) \
194+
MSG(MouseDownMsgID) \
195+
MSG(MouseUpMsgID) \
196+
MSG(MouseDraggedMsgID) \
197+
MSG(FlushQueueMsgID) \
198+
MSG(AddMenuMsgID) \
199+
MSG(AddMenuItemMsgID) \
200+
MSG(RemoveMenuItemMsgID) \
201+
MSG(EnableMenuItemMsgID) \
202+
MSG(ExecuteMenuMsgID) \
203+
MSG(ShowToolbarMsgID) \
204+
MSG(ToggleToolbarMsgID) \
205+
MSG(CreateScrollbarMsgID) \
206+
MSG(DestroyScrollbarMsgID) \
207+
MSG(ShowScrollbarMsgID) \
208+
MSG(SetScrollbarPositionMsgID) \
209+
MSG(SetScrollbarThumbMsgID) \
210+
MSG(ScrollbarEventMsgID) \
211+
MSG(SetFontMsgID) \
212+
MSG(SetWideFontMsgID) \
213+
MSG(VimShouldCloseMsgID) \
214+
MSG(SetDefaultColorsMsgID) \
215+
MSG(ExecuteActionMsgID) \
216+
MSG(DropFilesMsgID) \
217+
MSG(DropStringMsgID) \
218+
MSG(ShowPopupMenuMsgID) \
219+
MSG(GotFocusMsgID) \
220+
MSG(LostFocusMsgID) \
221+
MSG(MouseMovedMsgID) \
222+
MSG(SetMouseShapeMsgID) \
223+
MSG(AdjustLinespaceMsgID) \
224+
MSG(AdjustColumnspaceMsgID) \
225+
MSG(ActivateMsgID) \
226+
MSG(SetServerNameMsgID) \
227+
MSG(EnterFullScreenMsgID) \
228+
MSG(LeaveFullScreenMsgID) \
229+
MSG(SetBuffersModifiedMsgID) \
230+
MSG(AddInputMsgID) \
231+
MSG(SetPreEditPositionMsgID) \
232+
MSG(TerminateNowMsgID) \
233+
MSG(XcodeModMsgID) \
234+
MSG(EnableAntialiasMsgID) \
235+
MSG(DisableAntialiasMsgID) \
236+
MSG(SetVimStateMsgID) \
237+
MSG(SetDocumentFilenameMsgID) \
238+
MSG(OpenWithArgumentsMsgID) \
239+
MSG(CloseWindowMsgID) \
240+
MSG(SetFullScreenColorMsgID) \
241+
MSG(ShowFindReplaceDialogMsgID) \
242+
MSG(FindReplaceMsgID) \
243+
MSG(UseSelectionForFindMsgID) \
244+
MSG(ActivateKeyScriptMsgID) \
245+
MSG(DeactivateKeyScriptMsgID) \
246+
MSG(EnableImControlMsgID) \
247+
MSG(DisableImControlMsgID) \
248+
MSG(ActivatedImMsgID) \
249+
MSG(DeactivatedImMsgID) \
250+
MSG(BrowseForFileMsgID) \
251+
MSG(ShowDialogMsgID) \
252+
MSG(SetMarkedTextMsgID) \
253+
MSG(ZoomMsgID) \
254+
MSG(SetWindowPositionMsgID) \
255+
MSG(DeleteSignMsgID) \
256+
MSG(SetTooltipMsgID) \
257+
MSG(SetTooltipDelayMsgID) \
258+
MSG(GestureMsgID) \
259+
MSG(AddToMRUMsgID) \
260+
MSG(BackingPropertiesChangedMsgID) \
261+
MSG(SetBlurRadiusMsgID) \
262+
MSG(EnableLigaturesMsgID) \
263+
MSG(DisableLigaturesMsgID) \
264+
MSG(EnableThinStrokesMsgID) \
265+
MSG(DisableThinStrokesMsgID) \
266+
MSG(LastMsgID) \
173267

174268
enum {
175-
OpenWindowMsgID = 1, // NOTE: FIRST IN ENUM MUST BE 1
176-
KeyDownMsgID,
177-
BatchDrawMsgID,
178-
SelectTabMsgID,
179-
CloseTabMsgID,
180-
AddNewTabMsgID,
181-
DraggedTabMsgID,
182-
UpdateTabBarMsgID,
183-
ShowTabBarMsgID,
184-
HideTabBarMsgID,
185-
SetTextRowsMsgID,
186-
SetTextColumnsMsgID,
187-
SetTextDimensionsMsgID,
188-
SetTextDimensionsNoResizeWindowMsgID,
189-
LiveResizeMsgID,
190-
SetTextDimensionsReplyMsgID,
191-
ResizeViewMsgID,
192-
SetWindowTitleMsgID,
193-
ScrollWheelMsgID,
194-
MouseDownMsgID,
195-
MouseUpMsgID,
196-
MouseDraggedMsgID,
197-
FlushQueueMsgID,
198-
AddMenuMsgID,
199-
AddMenuItemMsgID,
200-
RemoveMenuItemMsgID,
201-
EnableMenuItemMsgID,
202-
ExecuteMenuMsgID,
203-
ShowToolbarMsgID,
204-
ToggleToolbarMsgID,
205-
CreateScrollbarMsgID,
206-
DestroyScrollbarMsgID,
207-
ShowScrollbarMsgID,
208-
SetScrollbarPositionMsgID,
209-
SetScrollbarThumbMsgID,
210-
ScrollbarEventMsgID,
211-
SetFontMsgID,
212-
SetWideFontMsgID,
213-
VimShouldCloseMsgID,
214-
SetDefaultColorsMsgID,
215-
ExecuteActionMsgID,
216-
DropFilesMsgID,
217-
DropStringMsgID,
218-
ShowPopupMenuMsgID,
219-
GotFocusMsgID,
220-
LostFocusMsgID,
221-
MouseMovedMsgID,
222-
SetMouseShapeMsgID,
223-
AdjustLinespaceMsgID,
224-
AdjustColumnspaceMsgID,
225-
ActivateMsgID,
226-
SetServerNameMsgID,
227-
EnterFullScreenMsgID,
228-
LeaveFullScreenMsgID,
229-
SetBuffersModifiedMsgID,
230-
AddInputMsgID,
231-
SetPreEditPositionMsgID,
232-
TerminateNowMsgID,
233-
XcodeModMsgID,
234-
EnableAntialiasMsgID,
235-
DisableAntialiasMsgID,
236-
SetVimStateMsgID,
237-
SetDocumentFilenameMsgID,
238-
OpenWithArgumentsMsgID,
239-
CloseWindowMsgID,
240-
SetFullScreenColorMsgID,
241-
ShowFindReplaceDialogMsgID,
242-
FindReplaceMsgID,
243-
UseSelectionForFindMsgID,
244-
ActivateKeyScriptMsgID,
245-
DeactivateKeyScriptMsgID,
246-
EnableImControlMsgID,
247-
DisableImControlMsgID,
248-
ActivatedImMsgID,
249-
DeactivatedImMsgID,
250-
BrowseForFileMsgID,
251-
ShowDialogMsgID,
252-
SetMarkedTextMsgID,
253-
ZoomMsgID,
254-
SetWindowPositionMsgID,
255-
DeleteSignMsgID,
256-
SetTooltipMsgID,
257-
SetTooltipDelayMsgID,
258-
GestureMsgID,
259-
AddToMRUMsgID,
260-
BackingPropertiesChangedMsgID,
261-
SetBlurRadiusMsgID,
262-
EnableLigaturesMsgID,
263-
DisableLigaturesMsgID,
264-
EnableThinStrokesMsgID,
265-
DisableThinStrokesMsgID,
266-
LastMsgID // NOTE: MUST BE LAST MESSAGE IN ENUM!
269+
#define ENUM_ENTRY(X) X,
270+
FOREACH_MMVimMsgID(ENUM_ENTRY)
271+
#undef ENUM_ENTRY
267272
};
268273

269274

src/MacVim/MacVim.m

Lines changed: 5 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -14,100 +14,11 @@
1414
#import "MacVim.h"
1515

1616

17-
char *MessageStrings[] =
17+
const char * const MMVimMsgIDStrings[] =
1818
{
19-
"INVALID MESSAGE ID",
20-
"OpenWindowMsgID",
21-
"KeyDownMsgID",
22-
"BatchDrawMsgID",
23-
"SelectTabMsgID",
24-
"CloseTabMsgID",
25-
"AddNewTabMsgID",
26-
"DraggedTabMsgID",
27-
"UpdateTabBarMsgID",
28-
"ShowTabBarMsgID",
29-
"HideTabBarMsgID",
30-
"SetTextRowsMsgID",
31-
"SetTextColumnsMsgID",
32-
"SetTextDimensionsMsgID",
33-
"SetTextDimensionsNoResizeWindowMsgID",
34-
"LiveResizeMsgID",
35-
"SetTextDimensionsReplyMsgID",
36-
"ResizeViewMsgID",
37-
"SetWindowTitleMsgID",
38-
"ScrollWheelMsgID",
39-
"MouseDownMsgID",
40-
"MouseUpMsgID",
41-
"MouseDraggedMsgID",
42-
"FlushQueueMsgID",
43-
"AddMenuMsgID",
44-
"AddMenuItemMsgID",
45-
"RemoveMenuItemMsgID",
46-
"EnableMenuItemMsgID",
47-
"ExecuteMenuMsgID",
48-
"ShowToolbarMsgID",
49-
"ToggleToolbarMsgID",
50-
"CreateScrollbarMsgID",
51-
"DestroyScrollbarMsgID",
52-
"ShowScrollbarMsgID",
53-
"SetScrollbarPositionMsgID",
54-
"SetScrollbarThumbMsgID",
55-
"ScrollbarEventMsgID",
56-
"SetFontMsgID",
57-
"SetWideFontMsgID",
58-
"VimShouldCloseMsgID",
59-
"SetDefaultColorsMsgID",
60-
"ExecuteActionMsgID",
61-
"DropFilesMsgID",
62-
"DropStringMsgID",
63-
"ShowPopupMenuMsgID",
64-
"GotFocusMsgID",
65-
"LostFocusMsgID",
66-
"MouseMovedMsgID",
67-
"SetMouseShapeMsgID",
68-
"AdjustLinespaceMsgID",
69-
"AdjustColumnspaceMsgID",
70-
"ActivateMsgID",
71-
"SetServerNameMsgID",
72-
"EnterFullScreenMsgID",
73-
"LeaveFullScreenMsgID",
74-
"SetBuffersModifiedMsgID",
75-
"AddInputMsgID",
76-
"SetPreEditPositionMsgID",
77-
"TerminateNowMsgID",
78-
"XcodeModMsgID",
79-
"EnableAntialiasMsgID",
80-
"DisableAntialiasMsgID",
81-
"SetVimStateMsgID",
82-
"SetDocumentFilenameMsgID",
83-
"OpenWithArgumentsMsgID",
84-
"CloseWindowMsgID",
85-
"SetFullScreenColorMsgID",
86-
"ShowFindReplaceDialogMsgID",
87-
"FindReplaceMsgID",
88-
"ActivateKeyScriptMsgID",
89-
"DeactivateKeyScriptMsgID",
90-
"EnableImControlMsgID",
91-
"DisableImControlMsgID",
92-
"ActivatedImMsgID",
93-
"DeactivatedImMsgID",
94-
"BrowseForFileMsgID",
95-
"ShowDialogMsgID",
96-
"SetMarkedTextMsgID",
97-
"ZoomMsgID",
98-
"SetWindowPositionMsgID",
99-
"DeleteSignMsgID",
100-
"SetTooltipMsgID",
101-
"SetTooltipDelayMsgID",
102-
"GestureMsgID",
103-
"AddToMRUMsgID",
104-
"BackingPropertiesChangedMsgID",
105-
"SetBlurRadiusMsgID",
106-
"EnableLigaturesMsgID",
107-
"DisableLigaturesMsgID",
108-
"EnableThinStrokesMsgID",
109-
"DisableThinStrokesMsgID",
110-
"END OF MESSAGE IDs" // NOTE: Must be last!
19+
#define STRING_ARRAY_ENTRY(X) #X,
20+
FOREACH_MMVimMsgID(STRING_ARRAY_ENTRY)
21+
#undef STRING_ARRAY_ENTRY
11122
};
11223

11324

@@ -157,7 +68,7 @@
15768
else if (msgid == ShowScrollbarMsgID) ++shows;
15869
else if (msgid == CreateScrollbarMsgID) ++cres;
15970
else if (msgid == DestroyScrollbarMsgID) ++dess;
160-
else [s appendFormat:@"%s ", MessageStrings[msgid]];
71+
else [s appendFormat:@"%s ", MMVimMsgIDStrings[msgid]];
16172
}
16273
if (item > 0) [s appendFormat:@"AddMenuItemMsgID(%d) ", item];
16374
if (menu > 0) [s appendFormat:@"AddMenuMsgID(%d) ", menu];

0 commit comments

Comments
 (0)