FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pythonnative/src/pythonnative/native/yoga/python.cpp at main · pythonnative/pythonnative · GitHub
pythonnative
pythonnative
Repository navigation
Code
Issues
11
(11)
Pull requests
4
(4)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
pythonnative
/
src
/
pythonnative
/
native
/
yoga
/
python.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
16 lines (16 loc) · 833 Bytes
Breadcrumbs
pythonnative
/
src
/
pythonnative
/
native
/
yoga
/
python.cpp
Copy path
File metadata and controls
16 lines (16 loc) · 833 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//
Python host binding for the same Yoga core used by mobile runtimes.
#
include
<
Python.h
>
#
include
<
yoga/Yoga.h
>
extern
"
C
"
{
typedef
void
(*PNMeasure)(YGNodeConstRef,
float
,
int
,
float
,
int
,
float
*,
float
*);
static
PNMeasure callback =
nullptr
;
static
YGSize
measure
(YGNodeConstRef node,
float
w, YGMeasureMode wm,
float
h, YGMeasureMode hm) {
float
width =
0
, height =
0
;
callback
(node, w,
static_cast
<
int
>(wm), h,
static_cast
<
int
>(hm), &width, &height);
return
{width, height};
}
void
pn_yoga_callback
(PNMeasure fn) { callback = fn; }
void
pn_yoga_measure
(YGNodeRef node,
int
enabled) {
YGNodeSetMeasureFunc
(node, enabled ? measure :
nullptr
); }
static
PyModuleDef
module
= {PyModuleDef_HEAD_INIT,
"
_yoga
"
,
"
Yoga 3.2.1 host library
"
, -
1
,
nullptr
};
PyMODINIT_FUNC
PyInit__yoga
() {
return
PyModule_Create
(&
module
); }
}
Back
|
FazBrowse Home
|
New Git URL