23 local bpp____supershellDirectory="/dev/shm/"
24 if [[ ! -d "${bpp____supershellDirectory}" ]]; then
25 bpp____supershellDirectory="${TMPDIR:-/tmp/}"
27 local bpp____supershelltempfile="$(mktemp "${bpp____supershellDirectory}/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")"
28 eval "exec {bpp____supershellFD__$BASHPID}<>\"$bpp____supershelltempfile\""
29 rm "$bpp____supershelltempfile"
31function bpp____supershell() {
32 local __outputVar="$1" __command="$2" __supershellFD="bpp____supershellFD__$BASHPID" __temporaryStorage=""
33 if [[ -z "${!__supershellFD}" ]]; then
36 __temporaryStorage=$(< "/dev/fd/${!__supershellFD}")
38 $__command 1>"/dev/fd/${!__supershellFD}" 2>/dev/null
39 eval "$__outputVar=\$(< "/dev/fd/${!__supershellFD}")"
40 echo "${__temporaryStorage}">"/dev/fd/${!__supershellFD}"
44[[maybe_unused]] static const char*
bpp_repeat = R
"EOF(function bpp____repeat() {
48[[maybe_unused]] static const char*
bpp_vtable_lookup = R
"EOF(function bpp____vTable__lookup() {
49 local __this="$1" __method="$2" __outputVar="$3"
50 ([[ -z "${__this}" ]] || [[ -z "${__method}" ]] || [[ -z "${__outputVar}" ]]) && >&2 echo "Bash++: Error: Invalid vTable lookup" && exit 1
52 if ! eval "declare -p \"${__this}\"" &>/dev/null; then
55 [[ -z "${!__this}" ]] && break
58 local __vTable="${__this}____vPointer"
59 if ! eval "declare -p \"${__vTable}\"" &>/dev/null; then
62 local __result="${!__vTable}[\"${__method}\"]"
63 [[ -z "${!__result}" ]] && >&2 echo "Bash++: Error: Method '${__method}' not found in vTable for object '${__this}'" && return 1
64 eval "${__outputVar}=\$__result"
68[[maybe_unused]] static const char*
bpp_dynamic_cast = R
"EOF(function bpp____dynamic__cast() {
69 local __type="$1" __outputVar="$2" __this="$3"
70 ([[ -z "${__outputVar}" ]]) && >&2 echo "Bash++: Error: Invalid dynamic_cast" && exit 1
71 eval "${__outputVar}=0"
73 if ! eval "declare -p \"${__this}\"" &>/dev/null; then
76 [[ -z "${!__this}" ]] && break
79 local __vTable="${__this}____vPointer"
80 if ! eval "declare -p \"${__vTable}\"" &>/dev/null; then
83 while [[ ! -z "${!__vTable}" ]] 2>/dev/null; do
84 [[ "${!__vTable}" == "bpp__${__type}____vTable" ]] && eval "${__outputVar}=\"${__this}\"" && return 0
85 __vTable="${!__vTable}[\"__parent__\"]"
92 local __this="$1" __outputVar="$2"
93 [[ -z "${__this}" ]] && >&2 echo "Bash++: Error: Invalid type name request" && exit 1
95 if ! eval "declare -p \"${__this}\"" &>/dev/null; then
98 [[ -z "${!__this}" ]] && break
101 local __vTable="${__this}____vPointer"
102 if ! eval "declare -p \"${__vTable}\"" &>/dev/null; then
105 __vTable="${!__vTable}"
106 local __typeName="${__vTable/bpp__/}"
107 __typeName="${__typeName/____vTable/}"
108 eval "${__outputVar}=\"${__typeName}\""
112[[maybe_unused]] static const char*
template_method = R
"EOF(function bpp__%CLASS%__%SIGNATURE%() {
116 %THIS_POINTER_VALIDATION%
122 if ! eval "declare -p \"${__this}\"" &>/dev/null; then
125 [[ -z "${!__this}" ]] && break
128 local __vPointer="${__this}____vPointer"
129 if [[ "${__this}" == "0" ]] || [[ -z "${!__vPointer}" ]]; then
130 >&2 echo "Bash++: Error: Attempted to call @%CLASS%.%SIGNATURE% on null object"
static const char * bpp_vtable_lookup
Definition templates.h:48
static const char * bpp_typeof_function
Definition templates.h:91
static const char * this_pointer_validation
Definition templates.h:121
static const char * bpp_dynamic_cast
Definition templates.h:68
static const char * bpp_supershell_function
Definition templates.h:22
static const char * template_method
Definition templates.h:112
static const char * bpp_repeat
Definition templates.h:44