MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / getComments

Function getComments

buildtools/make_struct.php:174–199  ·  view source on GitHub ↗

* @brief Get the comment block of a function. * Adds see/return doxygen tags * @param string $currentFunction function name * @param string $returnType Return type of function * @param array $parameters Parameter names * @return string Comment block */

(StructGeneratorInterface $generator, string $currentFunction, string $returnType, array $parameters)

Source from the content-addressed store, hash-verified

172 * @return string Comment block
173 */
174function getComments(StructGeneratorInterface $generator, string $currentFunction, string $returnType, array $parameters): string
175{
176 global $header;
177 /* First find the function */
178 foreach ($header as $i => $line) {
179 if (preg_match('/^\s*void\s+' . $currentFunction . '\s*\(.*' . join('.*', $parameters) . '.*command_completion_event_t\s*callback\s*/', $line)) {
180 /* Backpeddle */
181 $lineIndex = 1;
182 for ($n = $i; $n != 0; --$n, $lineIndex++) {
183 $header[$n] = preg_replace('/^\t+/', '', $header[$n]);
184 $header[$n] = preg_replace('/@see (.+?)$/', '@see dpp::cluster::' . $currentFunction . "\n * @see \\1", $header[$n]);
185 $header[$n] = preg_replace('/@param callback .*$/', '@return ' . $returnType . ' returned object on completion', $header[$n]);
186 if (preg_match('/\s*\* On success /i', $header[$n])) {
187 $header[$n] = "";
188 }
189 if (preg_match('/\s*\/\*\*\s*$/', $header[$n])) {
190 $part = array_slice($header, $n, $lineIndex - 1);
191 array_splice($part, count($part) - 1, 0, $generator->getCommentArray());
192 return str_replace("\n\n", "\n", join("\n", $part));
193 }
194 }
195 return '';
196 }
197 }
198 return '';
199}
200
201/* Finished parsing, output autogenerated files */
202$generator->saveHeader($content);

Callers 1

make_struct.phpFile · 0.85

Calls 2

countFunction · 0.85
getCommentArrayMethod · 0.45

Tested by

no test coverage detected