autosar-calltree 0.3.0__tar.gz → 0.3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {autosar_calltree-0.3.0/src/autosar_calltree.egg-info → autosar_calltree-0.3.1}/PKG-INFO +7 -7
  2. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/README.md +3 -3
  3. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/pyproject.toml +4 -4
  4. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/cli/main.py +3 -4
  5. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/database/function_database.py +4 -2
  6. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/parsers/c_parser.py +44 -13
  7. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/version.py +1 -1
  8. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1/src/autosar_calltree.egg-info}/PKG-INFO +7 -7
  9. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/LICENSE +0 -0
  10. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/MANIFEST.in +0 -0
  11. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/setup.cfg +0 -0
  12. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/setup.py +0 -0
  13. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/__init__.py +0 -0
  14. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/analyzers/__init__.py +0 -0
  15. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/analyzers/call_tree_builder.py +0 -0
  16. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/cli/__init__.py +0 -0
  17. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/config/__init__.py +0 -0
  18. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/config/module_config.py +0 -0
  19. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/database/__init__.py +0 -0
  20. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/database/models.py +0 -0
  21. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/generators/__init__.py +0 -0
  22. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/generators/mermaid_generator.py +0 -0
  23. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/parsers/__init__.py +0 -0
  24. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree/parsers/autosar_parser.py +0 -0
  25. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree.egg-info/SOURCES.txt +0 -0
  26. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree.egg-info/dependency_links.txt +0 -0
  27. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree.egg-info/entry_points.txt +0 -0
  28. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree.egg-info/requires.txt +0 -0
  29. {autosar_calltree-0.3.0 → autosar_calltree-0.3.1}/src/autosar_calltree.egg-info/top_level.txt +0 -0
@@ -1,14 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autosar-calltree
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A Python tool to analyze C/AUTOSAR codebases and generate function call trees with Mermaid and XMI output
5
5
  Author-email: melodypapa <melodypapa@outlook.com>
6
6
  Maintainer-email: melodypapa <melodypapa@outlook.com>
7
7
  License: MIT
8
- Project-URL: Homepage, https://github.com/yourusername/autosar-calltree
8
+ Project-URL: Homepage, https://github.com/melodypapa/autosar-calltree
9
9
  Project-URL: Documentation, https://autosar-calltree.readthedocs.io
10
- Project-URL: Repository, https://github.com/yourusername/autosar-calltree
11
- Project-URL: Bug Tracker, https://github.com/yourusername/autosar-calltree/issues
10
+ Project-URL: Repository, https://github.com/melodypapa/autosar-calltree
11
+ Project-URL: Bug Tracker, https://github.com/melodypapa/autosar-calltree/issues
12
12
  Keywords: autosar,c,call-tree,static-analysis,code-analysis,mermaid,xmi,uml,embedded,automotive
13
13
  Classifier: Development Status :: 3 - Alpha
14
14
  Classifier: Intended Audience :: Developers
@@ -78,7 +78,7 @@ pip install autosar-calltree
78
78
  For development:
79
79
 
80
80
  ```bash
81
- git clone https://github.com/yourusername/autosar-calltree.git
81
+ git clone https://github.com/melodypapa/autosar-calltree.git
82
82
  cd autosar-calltree
83
83
  pip install -e ".[dev]"
84
84
  ```
@@ -473,9 +473,9 @@ MIT License - see [LICENSE](LICENSE) file for details.
473
473
 
474
474
  ## Support
475
475
 
476
- - **Issues**: [GitHub Issues](https://github.com/yourusername/autosar-calltree/issues)
476
+ - **Issues**: [GitHub Issues](https://github.com/melodypapa/autosar-calltree/issues)
477
477
  - **Documentation**: [Read the Docs](https://autosar-calltree.readthedocs.io)
478
- - **Discussions**: [GitHub Discussions](https://github.com/yourusername/autosar-calltree/discussions)
478
+ - **Discussions**: [GitHub Discussions](https://github.com/melodypapa/autosar-calltree/discussions)
479
479
 
480
480
  ---
481
481
 
@@ -32,7 +32,7 @@ pip install autosar-calltree
32
32
  For development:
33
33
 
34
34
  ```bash
35
- git clone https://github.com/yourusername/autosar-calltree.git
35
+ git clone https://github.com/melodypapa/autosar-calltree.git
36
36
  cd autosar-calltree
37
37
  pip install -e ".[dev]"
38
38
  ```
@@ -427,9 +427,9 @@ MIT License - see [LICENSE](LICENSE) file for details.
427
427
 
428
428
  ## Support
429
429
 
430
- - **Issues**: [GitHub Issues](https://github.com/yourusername/autosar-calltree/issues)
430
+ - **Issues**: [GitHub Issues](https://github.com/melodypapa/autosar-calltree/issues)
431
431
  - **Documentation**: [Read the Docs](https://autosar-calltree.readthedocs.io)
432
- - **Discussions**: [GitHub Discussions](https://github.com/yourusername/autosar-calltree/discussions)
432
+ - **Discussions**: [GitHub Discussions](https://github.com/melodypapa/autosar-calltree/discussions)
433
433
 
434
434
  ---
435
435
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "autosar-calltree"
7
- version = "0.3.0"
7
+ version = "0.3.1"
8
8
  description = "A Python tool to analyze C/AUTOSAR codebases and generate function call trees with Mermaid and XMI output"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -67,10 +67,10 @@ docs = [
67
67
  ]
68
68
 
69
69
  [project.urls]
70
- Homepage = "https://github.com/yourusername/autosar-calltree"
70
+ Homepage = "https://github.com/melodypapa/autosar-calltree"
71
71
  Documentation = "https://autosar-calltree.readthedocs.io"
72
- Repository = "https://github.com/yourusername/autosar-calltree"
73
- "Bug Tracker" = "https://github.com/yourusername/autosar-calltree/issues"
72
+ Repository = "https://github.com/melodypapa/autosar-calltree"
73
+ "Bug Tracker" = "https://github.com/melodypapa/autosar-calltree/issues"
74
74
 
75
75
  [project.scripts]
76
76
  calltree = "autosar_calltree.cli:cli"
@@ -152,12 +152,10 @@ def cli(
152
152
  SpinnerColumn(),
153
153
  TextColumn("[progress.description]{task.description}"),
154
154
  console=console,
155
- transient=True,
155
+ transient=False,
156
156
  ) as progress:
157
157
  # Build database
158
- task = progress.add_task(
159
- f"Building function database from {source_dir}...", total=None
160
- )
158
+ task = progress.add_task("", total=None)
161
159
 
162
160
  db = FunctionDatabase(source_dir, cache_dir=cache_dir, module_config=config)
163
161
  db.build_database(
@@ -199,6 +197,7 @@ def cli(
199
197
 
200
198
  # Handle search
201
199
  if search:
200
+ console.print()
202
201
  console.print(f"[bold]Search Results for '{search}':[/bold]\n")
203
202
  results = db.search_functions(search)
204
203
  if results:
@@ -127,10 +127,12 @@ class FunctionDatabase:
127
127
  if verbose:
128
128
  print(f"Found {len(c_files)} C source files")
129
129
 
130
+ # Print build progress message before processing files
131
+ print(f"Building function database from {self.source_dir}...")
132
+
130
133
  # Parse each file
131
134
  for idx, file_path in enumerate(c_files, 1):
132
- if verbose and idx % 100 == 0:
133
- print(f"Processing file {idx}/{len(c_files)}: {file_path.name}")
135
+ print(f"Processing: [{idx}/{len(c_files)}] {file_path.name}")
134
136
 
135
137
  try:
136
138
  self._parse_file(file_path)
@@ -85,13 +85,14 @@ class CParser:
85
85
 
86
86
  # Pattern for traditional C function declarations/definitions
87
87
  # Matches: [static] [inline] return_type function_name(params)
88
+ # Optimized to avoid catastrophic backtracking with length limits
88
89
  self.function_pattern = re.compile(
89
90
  r"^\s*" # Start of line with optional whitespace
90
91
  r"(?P<static>static\s+)?" # Optional static keyword
91
92
  r"(?P<inline>inline|__inline__|__inline\s+)?" # Optional inline
92
- r"(?P<return_type>[\w\s\*]+?)\s+" # Return type (can include spaces, pointers)
93
- r"(?P<function_name>[a-zA-Z_][a-zA-Z0-9_]*)\s*" # Function name
94
- r"\((?P<params>[^)]*)\)", # Parameters in parentheses
93
+ r"(?P<return_type>[\w\s\*]{1,101}?)\s+" # Return type (1-101 chars, non-greedy)
94
+ r"(?P<function_name>[a-zA-Z_][a-zA-Z0-9_]{1,50})\s*" # Function name (1-50 chars)
95
+ r"\((?P<params>[^()]{0,500}(?:\([^()]{0,100}\)[^()]{0,500})*)\)", # Parameters (limited length)
95
96
  re.MULTILINE,
96
97
  )
97
98
 
@@ -156,16 +157,46 @@ class CParser:
156
157
  functions.append(autosar_func)
157
158
 
158
159
  # Then, parse traditional C functions
159
- for match in self.function_pattern.finditer(content):
160
- func_info = self._parse_function_match(match, content, file_path)
161
- if func_info:
162
- # Check if this function was already found as AUTOSAR
163
- is_duplicate = any(
164
- f.name == func_info.name and f.line_number == func_info.line_number
165
- for f in functions
166
- )
167
- if not is_duplicate:
168
- functions.append(func_info)
160
+ # Use line-by-line matching to avoid catastrophic backtracking on large files
161
+ lines = content.split("\n")
162
+ current_pos = 0
163
+ for line_num, line in enumerate(lines, 1):
164
+ line_length = len(line) + 1 # +1 for newline
165
+ # Skip empty lines and lines that don't look like function declarations
166
+ if not line or "(" not in line or ";" in line:
167
+ current_pos += line_length
168
+ continue
169
+
170
+ # Check if line matches function pattern
171
+ match = self.function_pattern.match(line)
172
+ if match:
173
+ # Adjust match positions to be relative to full content
174
+ class AdjustedMatch:
175
+ def __init__(self, original_match, offset):
176
+ self._match = original_match
177
+ self._offset = offset
178
+
179
+ def group(self, name):
180
+ return self._match.group(name)
181
+
182
+ def start(self):
183
+ return self._offset + self._match.start()
184
+
185
+ def end(self):
186
+ return self._offset + self._match.end()
187
+
188
+ adjusted_match = AdjustedMatch(match, current_pos)
189
+ func_info = self._parse_function_match(adjusted_match, content, file_path) # type: ignore[arg-type]
190
+ if func_info:
191
+ # Check if this function was already found as AUTOSAR
192
+ is_duplicate = any(
193
+ f.name == func_info.name and f.line_number == func_info.line_number
194
+ for f in functions
195
+ )
196
+ if not is_duplicate:
197
+ functions.append(func_info)
198
+
199
+ current_pos += line_length
169
200
 
170
201
  return functions
171
202
 
@@ -1,5 +1,5 @@
1
1
  """Version information for autosar-calltree package."""
2
2
 
3
- __version__ = "0.3.0"
3
+ __version__ = "0.3.1"
4
4
  __author__ = "melodypapa"
5
5
  __email__ = "melodypapa@outlook.com"
@@ -1,14 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autosar-calltree
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Summary: A Python tool to analyze C/AUTOSAR codebases and generate function call trees with Mermaid and XMI output
5
5
  Author-email: melodypapa <melodypapa@outlook.com>
6
6
  Maintainer-email: melodypapa <melodypapa@outlook.com>
7
7
  License: MIT
8
- Project-URL: Homepage, https://github.com/yourusername/autosar-calltree
8
+ Project-URL: Homepage, https://github.com/melodypapa/autosar-calltree
9
9
  Project-URL: Documentation, https://autosar-calltree.readthedocs.io
10
- Project-URL: Repository, https://github.com/yourusername/autosar-calltree
11
- Project-URL: Bug Tracker, https://github.com/yourusername/autosar-calltree/issues
10
+ Project-URL: Repository, https://github.com/melodypapa/autosar-calltree
11
+ Project-URL: Bug Tracker, https://github.com/melodypapa/autosar-calltree/issues
12
12
  Keywords: autosar,c,call-tree,static-analysis,code-analysis,mermaid,xmi,uml,embedded,automotive
13
13
  Classifier: Development Status :: 3 - Alpha
14
14
  Classifier: Intended Audience :: Developers
@@ -78,7 +78,7 @@ pip install autosar-calltree
78
78
  For development:
79
79
 
80
80
  ```bash
81
- git clone https://github.com/yourusername/autosar-calltree.git
81
+ git clone https://github.com/melodypapa/autosar-calltree.git
82
82
  cd autosar-calltree
83
83
  pip install -e ".[dev]"
84
84
  ```
@@ -473,9 +473,9 @@ MIT License - see [LICENSE](LICENSE) file for details.
473
473
 
474
474
  ## Support
475
475
 
476
- - **Issues**: [GitHub Issues](https://github.com/yourusername/autosar-calltree/issues)
476
+ - **Issues**: [GitHub Issues](https://github.com/melodypapa/autosar-calltree/issues)
477
477
  - **Documentation**: [Read the Docs](https://autosar-calltree.readthedocs.io)
478
- - **Discussions**: [GitHub Discussions](https://github.com/yourusername/autosar-calltree/discussions)
478
+ - **Discussions**: [GitHub Discussions](https://github.com/melodypapa/autosar-calltree/discussions)
479
479
 
480
480
  ---
481
481