%D \module
%D   [       file=bndr-ini,
%D        version=2022.05.02,
%D          title=\CONTEXT\ Boundary Macros,
%D       subtitle=Initialization,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

\writestatus{loading}{ConTeXt Boundary Macros / Initialization}

\unprotect

\registerctxluafile{bndr-ini}{autosuffix}

% \defineboundary[foobar][public]\meaning\foobar\par
% \defineboundary[barfoo][public]\meaning\barfoo\par

\permanent\cdef\??boundaryprefix{c_bndr_}

\permanent\tolerant\protected\def\defineboundary[#1]#*[#2]% nicer for users
  {\ifinset\s!public{#2}%
     \ifcsname#1\endcsname\else
       \global\permanent\expandafter\integerdef\csname#1\endcsname\clf_defineboundary{#1}\relax
     \fi
  \else
    \ifcsname\??boundaryprefix#1\endcsname\else
      \global\permanent\expandafter\integerdef\csname\??boundaryprefix#1\endcsname\clf_defineboundary{#1}\relax
    \fi
  \fi}

\permanent\protected\def\newboundary#1% nicer for lowlevel
  {\ifdefined#1\else
     \global\permanent\immutable\integerdef#1\clf_defineboundary{\csstring#1}\relax
   \fi}

\protect
