Skip to content

Commit d97df48

Browse files
authored
Merge pull request #8176 from The-OpenROAD-Project-staging/odb-Point3D-swig
odb: add swig mappings for Point3D (tcl & python)
2 parents 3806976 + 2c30a5e commit d97df48

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/odb/src/swig/python/dbtypes.i

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@
2727
$result = list;
2828
}
2929

30+
%typemap(out) odb::Point3D, Point3D {
31+
PyObject *list = PyList_New(3);
32+
PyObject *x = PyInt_FromLong($1.x());
33+
PyObject *y = PyInt_FromLong($1.y());
34+
PyObject *z = PyInt_FromLong($1.z());
35+
PyList_SetItem(list, 0, x);
36+
PyList_SetItem(list, 1, y);
37+
PyList_SetItem(list, 2, z);
38+
$result = list;
39+
}
40+
3041
// Wrapper for dbSet, dbVector...etc
3142
%define WRAP_DB_CONTAINER(T)
3243
%typemap(out) dbSet< T >, dbVector< T > {

src/odb/src/swig/tcl/dbtypes.i

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
Tcl_SetObjResult(interp, list);
2525
}
2626

27+
%typemap(out) odb::Point3D, Point3D {
28+
Tcl_Obj *list = Tcl_NewListObj(0, nullptr);
29+
Tcl_Obj *x = Tcl_NewIntObj($1.x());
30+
Tcl_Obj *y = Tcl_NewIntObj($1.y());
31+
Tcl_Obj *z = Tcl_NewIntObj($1.z());
32+
Tcl_ListObjAppendElement(interp, list, x);
33+
Tcl_ListObjAppendElement(interp, list, y);
34+
Tcl_ListObjAppendElement(interp, list, z);
35+
Tcl_SetObjResult(interp, list);
36+
}
37+
2738
%typemap(out) std::optional<uint8_t> {
2839
if ($1.has_value()) {
2940
Tcl_SetIntObj($result, (int) $1.value());

0 commit comments

Comments
 (0)