Bash++
Bash++ compiler internal documentation
Variables
templates.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Variables

static const char * bpp_supershell_function
 
static const char * bpp_vtable_lookup
 
static const char * bpp_dynamic_cast
 
static const char * template_new_function
 
static const char * template_copy_function
 
static const char * template_method
 

Variable Documentation

◆ bpp_dynamic_cast

const char* bpp_dynamic_cast
static
Initial value:
= R"EOF(function bpp____dynamic__cast() {
local __type="$1" __outputVar="$2" __this="$3"
([[ -z "${__type}" ]] || [[ -z "${__outputVar}" ]]) && >&2 echo "Bash++: Error: Invalid dynamic_cast" && exit 1
eval "${__outputVar}=0"
while : ; do
if ! eval "declare -p \"${__this}\"" &>/dev/null; then
break
fi
[[ -z "${!__this}" ]] && break
__this="${!__this}"
done
local __vTable="${__this}____vPointer"
if ! eval "declare -p \"${__vTable}\"" &>/dev/null; then
return
fi
while [[ ! -z "${!__vTable}" ]] 2>/dev/null; do
[[ "${!__vTable}" == "bpp__${__type}____vTable" ]] && eval "${__outputVar}=\"${__this}\"" && return 0
__vTable="${!__vTable}[\"__parent__\"]"
done
return 1
}
)EOF"

◆ bpp_supershell_function

const char* bpp_supershell_function
static
Initial value:
= R"EOF(function bpp____initsupershell() {
local bpp____supershellDirectory="/dev/shm/"
if [[ ! -d "${bpp____supershellDirectory}" ]]; then
bpp____supershellDirectory="${TMPDIR:-/tmp/}"
fi
local bpp____supershelltempfile="$(mktemp "${bpp____supershellDirectory}/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")"
eval "exec {bpp____supershellFD__$BASHPID}<>\"$bpp____supershelltempfile\""
rm "$bpp____supershelltempfile"
}
function bpp____supershell() {
local __outputVar="$1" __command="$2" __supershellFD="bpp____supershellFD__$BASHPID" __temporaryStorage=""
if [[ -z "${!__supershellFD}" ]]; then
bpp____initsupershell
else
__temporaryStorage=$(< "/dev/fd/${!__supershellFD}")
fi
$__command 1>"/dev/fd/${!__supershellFD}" 2>/dev/null
eval "$__outputVar=\$(< "/dev/fd/${!__supershellFD}")"
echo "${__temporaryStorage}">"/dev/fd/${!__supershellFD}"
}
)EOF"

Copyright (C) 2025 rail5 Bash++: Bash with classes

◆ bpp_vtable_lookup

const char* bpp_vtable_lookup
static
Initial value:
= R"EOF(function bpp____vTable__lookup() {
local __this="$1" __method="$2" __outputVar="$3"
([[ -z "${__this}" ]] || [[ -z "${__method}" ]] || [[ -z "${__outputVar}" ]]) && >&2 echo "Bash++: Error: Invalid vTable lookup" && exit 1
while : ; do
if ! eval "declare -p \"${__this}\"" &>/dev/null; then
break
fi
[[ -z "${!__this}" ]] && break
__this="${!__this}"
done
local __vTable="${__this}____vPointer"
if ! eval "declare -p \"${__vTable}\"" &>/dev/null; then
return 1
fi
local __result="${!__vTable}[\"${__method}\"]"
[[ -z "${!__result}" ]] && >&2 echo "Bash++: Error: Method '${__method}' not found in vTable for object '${__this}'" && return 1
eval "${__outputVar}=\$__result"
}
)EOF"

◆ template_copy_function

const char* template_copy_function
static

◆ template_method

const char* template_method
static
Initial value:
= R"EOF(function bpp__%CLASS%__%SIGNATURE%() {
local __this="$1"
shift 1
%PARAMS%
while : ; do
if ! eval "declare -p \"${__this}\"" &>/dev/null; then
break
fi
[[ -z "${!__this}" ]] && break
__this="${!__this}"
done
local __vPointer="${__this}____vPointer"
if [[ "${__this}" == "0" ]] || [[ -z "${!__vPointer}" ]]; then
>&2 echo "Bash++: Error: Attempted to call @%CLASS%.%SIGNATURE% on null object"
return
fi
%METHODBODY%
}
)EOF"

◆ template_new_function

const char* template_new_function
static
Initial value:
= R"EOF(function bpp__%CLASS%____new() {
local __this="$1"
if [[ "${__this}" == "" ]]; then
while : ; do
__this="bpp__%CLASS%__$RANDOM$RANDOM$RANDOM$RANDOM"
local __unusedVar="${__this}____vPointer"
[[ -z "${!__unusedVar+x}" ]] && break
done
fi
eval "${__this}____vPointer=bpp__%CLASS%____vTable"
%ASSIGNMENTS%
echo "${__this}"
}
)EOF"