Skip to content

Commit

Permalink
FEAT: REFLECT module! 'title could return the module header title
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jul 23, 2021
1 parent 13d5fc4 commit 4fab4ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/boot/sysobj.reb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ catalog: object [
words [any-function! any-object! map! date!]
values [any-object! map!]
types [any-function!]
title [any-function! datatype!]
title [any-function! datatype! module!]
]
; Official list of system/options/flags that can appear.
; Must match host reb-args.h enum!
Expand Down
7 changes: 6 additions & 1 deletion src/core/t-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,15 @@ static REBSER *Trim_Object(REBSER *obj)

case A_REFLECT:
action = What_Reflector(arg); // zero on error
if (action == OF_SPEC) {
if (action == OF_SPEC || action == OF_TITLE) {
if (!VAL_MOD_SPEC(value)) return R_NONE;
VAL_OBJ_FRAME(value) = VAL_MOD_SPEC(value);
VAL_SET(value, REB_OBJECT);
if (action == OF_TITLE) {
REBCNT n = Find_Word_Index(VAL_OBJ_FRAME(value), SYM_TITLE, FALSE);
if(!n) return R_NONE;
value = VAL_OBJ_VALUE(value, n);
}
break;
}
// Adjust for compatibility with PICK:
Expand Down
5 changes: 5 additions & 0 deletions src/tests/units/module-test.r3
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ supplement system/options/module-paths join what-dir %units/files/
===end-group===

===start-group=== "make module"
--test-- "title-of"
;@@ https://github.com/Oldes/Rebol-issues/issues/572
test: module [Title: "Test Module"] []
--assert "Test Module" = try [title-of test]

--test-- "inlined module"
;@@ https://github.com/Oldes/Rebol-issues/issues/1628
unset 'z1 z2: 2
Expand Down

0 comments on commit 4fab4ce

Please # to comment.