Search codebase for function signature. Returns: { 'return_type': 'void', 'params': [('uint16_t', 'angle'), ...], 'namespace': 'fl', 'header': 'fl/math.h', 'function_name': 'sincos16' }
(self)
| 37 | ) |
| 38 | |
| 39 | def _detect_signature(self) -> dict[str, Any] | None: |
| 40 | """ |
| 41 | Search codebase for function signature. |
| 42 | Returns: { |
| 43 | 'return_type': 'void', |
| 44 | 'params': [('uint16_t', 'angle'), ...], |
| 45 | 'namespace': 'fl', |
| 46 | 'header': 'fl/math.h', |
| 47 | 'function_name': 'sincos16' |
| 48 | } |
| 49 | """ |
| 50 | # Extract function name from target (handle namespaces) |
| 51 | func_name = self.target.split("::")[-1] |
| 52 | |
| 53 | # Search for function declaration using grep |
| 54 | try: |
| 55 | result = RunningProcess.run( |
| 56 | ["git", "grep", "-n", f"\\b{func_name}\\b", "--", "*.h", "*.hpp"], |
| 57 | cwd=None, |
| 58 | check=False, |
| 59 | timeout=30, |
| 60 | ) |
| 61 | |
| 62 | if result.returncode != 0: |
| 63 | print(f"Warning: Could not find function '{func_name}' in codebase") |
| 64 | return None |
| 65 | |
| 66 | # Parse grep output to find function declarations |
| 67 | # Look for patterns like: return_type function_name(params) |
| 68 | func_pattern = re.compile( |
| 69 | r"^([^:]+):(\d+):\s*(?:inline\s+)?(?:static\s+)?(?:FASTLED_\w+\s+)?(\w+)\s+(\w+)\s*\(" |
| 70 | ) |
| 71 | |
| 72 | for line in result.stdout.split("\n"): |
| 73 | match = func_pattern.match(line) |
| 74 | if match: |
| 75 | file_path, _line_num, return_type, found_name = match.groups() |
| 76 | if found_name == func_name: |
| 77 | # Found a match, try to parse parameters |
| 78 | # This is a simplified parser; complex signatures may need refinement |
| 79 | return { |
| 80 | "return_type": return_type, |
| 81 | "params": [], # Simplified: empty params |
| 82 | "namespace": "fl", |
| 83 | "header": file_path.replace("src/", ""), |
| 84 | "function_name": func_name, |
| 85 | } |
| 86 | |
| 87 | except KeyboardInterrupt: |
| 88 | notify_main_thread() |
| 89 | raise |
| 90 | except Exception as e: |
| 91 | print(f"Warning: Error searching for function: {e}") |
| 92 | |
| 93 | return None |
| 94 | |
| 95 | def _generate_profiler(self, signature: dict[str, Any] | None) -> str: |
| 96 | """Generate C++ profiler code from template""" |
no test coverage detected