junrushao commented on code in PR #268:
URL: https://github.com/apache/tvm-ffi/pull/268#discussion_r2532309648


##########
python/tvm_ffi/stub/cli.py:
##########
@@ -56,17 +56,37 @@ def __main__() -> int:
     """
     opt = _parse_args()
     dlls = [ctypes.CDLL(lib) for lib in opt.dlls]
-    global_funcs = collect_global_funcs()
     files: list[FileInfo] = collect_files([Path(f) for f in opt.files])
 
     # Stage 1: Process `tvm-ffi-stubgen(ty-map)`
-    ty_map: dict[str, str] = collect_ty_maps(files, opt)
+    ty_map: dict[str, str] = C.TY_MAP_DEFAULTS.copy()
+
+    def _stage_1(file: FileInfo) -> None:
+        for code in file.code_blocks:
+            if code.kind == "ty-map":
+                try:
+                    lhs, rhs = code.param.split("->")
+                except ValueError as e:
+                    raise ValueError(
+                        f"Invalid ty_map format at line {code.lineno_start}. 
Example: `A.B -> C.D`"
+                    ) from e
+                ty_map[lhs.strip()] = rhs.strip()
+
+    for file in files:
+        try:
+            _stage_1(file)
+        except:

Review Comment:
   Good catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to