24 local bpp____supershellDirectory="/dev/shm/"
25 if [[ ! -d "${bpp____supershellDirectory}" ]]; then
26 bpp____supershellDirectory="${TMPDIR:-/tmp/}"
28 local bpp____supershelltempfile="$(mktemp "${bpp____supershellDirectory}/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")"
29 eval "exec {bpp____supershellFD__$BASHPID}<>\"$bpp____supershelltempfile\""
30 rm "$bpp____supershelltempfile"
32function bpp____supershell() {
33 local __outputVar="$1" __command="$2" __supershellFD="bpp____supershellFD__$BASHPID" __temporaryStorage=""
34 if [[ -z "${!__supershellFD}" ]]; then
37 __temporaryStorage=$(< "/dev/fd/${!__supershellFD}")
39 $__command 1>"/dev/fd/${!__supershellFD}"
40 eval "$__outputVar=\$(< "/dev/fd/${!__supershellFD}")"
41 echo "${__temporaryStorage}">"/dev/fd/${!__supershellFD}"
45[[maybe_unused]] static const char*
bpp_repeat = R
"EOF(function bpp____repeat() {
49[[maybe_unused]] static const char*
bpp_vtable_lookup = R
"EOF(function bpp____vTable__lookup() {
50 local __this="$1" __method="$2" __outputVar="$3"
51 ([[ -z "${__this}" ]] || [[ -z "${__method}" ]] || [[ -z "${__outputVar}" ]]) && >&2 echo "Bash++: Error: Invalid vTable lookup" && exit 1
53 if ! eval "declare -p \"${__this}\"" &>/dev/null; then
56 [[ -z "${!__this}" ]] && break
59 local __vTable="${__this}____vPointer"
60 if ! eval "declare -p \"${__vTable}\"" &>/dev/null; then
63 local __result="${!__vTable}[\"${__method}\"]"
64 [[ -z "${!__result}" ]] && >&2 echo "Bash++: Error: Method '${__method}' not found in vTable for object '${__this}'" && return 1
65 eval "${__outputVar}=\$__result"
69[[maybe_unused]] static const char*
bpp_dynamic_cast = R
"EOF(function bpp____dynamic__cast() {
70 local __type="$1" __outputVar="$2" __this="$3"
71 ([[ -z "${__outputVar}" ]]) && >&2 echo "Bash++: Error: Invalid dynamic_cast" && exit 1
72 eval "${__outputVar}=0"
74 if ! eval "declare -p \"${__this}\"" &>/dev/null; then
77 [[ -z "${!__this}" ]] && break
80 local __vTable="${__this}____vPointer"
81 if ! eval "declare -p \"${__vTable}\"" &>/dev/null; then
84 while [[ ! -z "${!__vTable}" ]] 2>/dev/null; do
85 [[ "${!__vTable}" == "bpp__${__type}____vTable" ]] && eval "${__outputVar}=\"${__this}\"" && return 0
86 __vTable="${!__vTable}[\"__parent__\"]"
93 local __this="$1" __outputVar="$2"
94 [[ -z "${__this}" ]] && >&2 echo "Bash++: Error: Invalid type name request" && exit 1
96 if ! eval "declare -p \"${__this}\"" &>/dev/null; then
99 [[ -z "${!__this}" ]] && break
102 local __vTable="${__this}____vPointer"
103 if ! eval "declare -p \"${__vTable}\"" &>/dev/null; then
106 __vTable="${!__vTable}"
107 local __typeName="${__vTable/bpp__/}"
108 __typeName="${__typeName/____vTable/}"
109 eval "${__outputVar}=\"${__typeName}\""
113[[maybe_unused]] static const char*
template_method = R
"EOF(function bpp__%CLASS%__%SIGNATURE%() {
117 %THIS_POINTER_VALIDATION%
123 if ! eval "declare -p \"${__this}\"" &>/dev/null; then
126 [[ -z "${!__this}" ]] && break
129 local __vPointer="${__this}____vPointer"
130 if [[ "${__this}" == "0" ]] || [[ -z "${!__vPointer}" ]]; then
131 >&2 echo "Bash++: Error: Attempted to call @%CLASS%.%SIGNATURE% on null object"
static const char * bpp_vtable_lookup
Definition templates.h:49
static const char * bpp_typeof_function
Definition templates.h:92
static const char * this_pointer_validation
Definition templates.h:122
static const char * bpp_dynamic_cast
Definition templates.h:69
static const char * bpp_supershell_function
Definition templates.h:23
static const char * template_method
Definition templates.h:113
static const char * bpp_repeat
Definition templates.h:45