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

const char * bpp_supershell_function
 
const char * bpp_vtable_lookup
 
const char * bpp_dynamic_cast
 
const char * template_new_function
 
const char * template_delete_function
 
const char * template_copy_function
 
const char * template_method
 
const char * template_constructor
 
const char * template_destructor
 

Variable Documentation

◆ bpp_dynamic_cast

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

◆ bpp_supershell_function

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

◆ template_constructor

const char* template_constructor
Initial value:
= R"EOF(function bpp__%CLASS%____constructor() {
local __objectAddress="$1"
local __vPointer="${__objectAddress}____vPointer"
if [[ "${__objectAddress}" == "0" ]] || [[ -z "${!__vPointer}" ]]; then
>&2 echo "Bash++: Error: %CLASS%: Attempted to construct null object"
return
fi
%CONSTRUCTORBODY%
}
)EOF"

◆ template_copy_function

const char* template_copy_function
Initial value:
= R"EOF(function bpp__%CLASS%____copy() {
local __copyFromAddress="$1" __copyToAddress="$2"
local __copyFromVPointer="${__copyFromAddress}____vPointer" __copyToVPointer="${__copyToAddress}____vPointer"
if [[ "${__copyFromAddress}" == "0" ]] || [[ -z "${!__copyFromVPointer}" ]]; then
>&2 echo "Bash++: Error: %CLASS%: Attempted to copy from null object"
return
fi
if [[ "${__copyToAddress}" == "0" ]] || [[ -z "${!__copyToVPointer}" ]]; then
>&2 echo "Bash++: Error: %CLASS%: Attempted to copy to null object"
return
fi
%COPIES%
eval "${__copyToVPointer}=${!__copyFromVPointer}"
}
)EOF"

◆ template_delete_function

const char* template_delete_function
Initial value:
= R"EOF(function bpp__%CLASS%____delete() {
local __objectAddress="$1"
local __vPointer="${__objectAddress}____vPointer"
if [[ "${__objectAddress}" == "0" ]] || [[ -z "${!__vPointer}" ]]; then
>&2 echo "Bash++: Error: %CLASS%: Attempted to delete null object"
return
fi
%DELETIONS%
unset ${__objectAddress}____vPointer
}
)EOF"

◆ template_destructor

const char* template_destructor
Initial value:
= R"EOF(function bpp__%CLASS%____destructor() {
local __objectAddress="$1"
local __vPointer="${__objectAddress}____vPointer"
if [[ "${__objectAddress}" == "0" ]] || [[ -z "${!__vPointer}" ]]; then
>&2 echo "Bash++: Error: %CLASS%: Attempted to destruct null object"
return
fi
%DESTRUCTORBODY%
}
)EOF"

◆ template_method

const char* template_method
Initial value:
= R"EOF(function bpp__%CLASS%__%SIGNATURE%() {
local __objectAddress="$1"
shift 1
%PARAMS%
local __vPointer="${__objectAddress}____vPointer"
if [[ "${__objectAddress}" == "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
Initial value:
= R"EOF(function bpp__%CLASS%____new() {
local __objectAddress="$1"
if [[ "${__objectAddress}" == "" ]]; then
while : ; do
__objectAddress="bpp__%CLASS%__$RANDOM$RANDOM$RANDOM$RANDOM"
local __unusedVar="${__objectAddress}____vPointer"
[[ -z "${!__unusedVar+x}" ]] && break
done
fi
eval "${__objectAddress}____vPointer=bpp__%CLASS%____vTable"
%ASSIGNMENTS%
echo "${__objectAddress}"
}
)EOF"