Skip to content

Commit

Permalink
export do_comm_call and use it from TYPE_pane and TYPE_comm
Browse files Browse the repository at this point in the history
This simplifies the inline code for do_call_val(), and
includes pane and comm calls in the backtrace from LOG_BT()

Signed-off-by: NeilBrown <[email protected]>
  • Loading branch information
neilbrown committed Sep 15, 2023
1 parent 855c9bc commit 478d7c3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion DOC/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Core features
hitting a python error - there will be no active view so the
screen will be meaningless. I need to properly abort and
auto-choose a new pane.
- [ ] LOG_BT() doesn't see TYPE_pane and TYPE_comm calls.
- [X] LOG_BT() doesn't see TYPE_pane and TYPE_comm calls.
- [ ] LOG should take a pane arg, and not use any static vars.
- [ ] reduce size of $(nm O/*.o | grep ' b ' | grep -v '_map$')
- [X] give every pane a link to root/editor main and use that
Expand Down
11 changes: 8 additions & 3 deletions core-keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,19 @@ void LOG_BT(void)
LOG("End Backtrace");
}

static int do_comm_call(struct command *comm safe,
const struct cmd_info *ci safe)
int do_comm_call(struct command *comm safe, const struct cmd_info *ci safe)
{
struct backtrace bt;
int ret;

if (ci->home->damaged & DAMAGED_DEAD)
return Efail;
if (times_up_fast(ci->home))
return Efail;
if ((ci->home->damaged & DAMAGED_CLOSED) &&
!comm->closed_ok)
return Efallthrough;

if (backtrace_depth > 100) {
backtrace_depth = 0;
LOG("Recursion limit of 100 reached");
Expand Down Expand Up @@ -569,7 +574,7 @@ int key_handle(const struct cmd_info *ci safe)
vci->home = p;
vci->comm = p->handle;
/* Don't add this to the call stack as it
* should simple call the desired function and
* should simply call the desired function and
* that will appear on the call stack.
*/
ret = p->handle->func(ci);
Expand Down
26 changes: 6 additions & 20 deletions core-pane.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static inline void pane_put(struct pane *p safe)
pane_free(p);
}

int do_comm_call(struct command *comm safe, const struct cmd_info *ci safe);
static inline int do_call_val(enum target_type type, struct pane *home,
struct command *comm2a,
const char *key safe, struct pane *focus safe,
Expand Down Expand Up @@ -136,32 +137,17 @@ static inline int do_call_val(enum target_type type, struct pane *home,
ret = key_handle(&ci);
break;
case TYPE_pane:
if (!home->handle || (home->damaged & DAMAGED_DEAD))
return Efail;
if (times_up_fast(focus))
return Efail;
if (home)
ci.home = home;
if ((home->damaged & DAMAGED_CLOSED) &&
!home->handle->closed_ok)
/* This pane cannot accept anything but
* close_ok commands.
*/
return Efallthrough;
ci.comm = home->handle;
ret = ci.comm->func(&ci);
ci.home = home;
if (home->handle)
ci.comm = home->handle;
ret = do_comm_call(ci.comm, &ci);
break;
case TYPE_comm:
if (times_up_fast(focus))
return Efail;
if (home)
ci.home = home;
if (ci.home->damaged & DAMAGED_CLOSED &&
!comm2a->closed_ok)
return Efallthrough;
ci.comm = comm2a;
ci.comm2 = comm2b;
ret = ci.comm->func(&ci);
ret = do_comm_call(ci.comm, &ci);
break;
}
return ret;
Expand Down

0 comments on commit 478d7c3

Please sign in to comment.