function _defineStdMathFunction($name, $args, $ret, $lib) { $f = function () use($name, $args, $ret, $lib) { $inputs = []; $count = 0; foreach ($args as $arg) { $inputs['arg' . $count] = lookupType($arg); $count += 1; } $retType = lookupType($ret); $hash = \grokit\hashComplex(['BASE::' . $name, $args, $ret]); ?> inline <?php echo $retType; ?> <?php echo $name; ?> ( <?php echo typed_args($inputs); ?> ) { return std::<?php echo $name; ?> (<?php echo args($inputs); ?> ); } <?php return ['kind' => 'FUNCTION', 'name' => $name, 'input' => $inputs, 'result' => $retType, 'deterministic' => true, 'system_headers' => $lib, 'hash' => $hash]; }; declareFunction($name, $args, $f); }
/** * Determines if a type has been defined depending on a set of * characteristics that determine uniqueness. * * @param $characteristics an array containing uniqueness characteristics * for the type. * @param $hash output parameter for the unique hash for the type * @param $type output parameter for the type information object for the * type, if it is defined. * * @returns true if the type was defined, false otherwise */ function typeDefined($characteristics, &$hash, &$type) { $libman =& \grokit\LibraryManager::GetLibraryManager(); $hash = \grokit\hashComplex($characteristics); if ($libman->typeDefined($hash)) { $type = $libman->getDefinedType($hash); return true; } return false; }