Skip to content

Commit 4feecdc

Browse files
committed
Add print/println/printArray to Processing_api.h for hoisted classes
1 parent f29feb2 commit 4feecdc

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/Processing_api.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ inline float degrees(float r) { return PApplet::degrees(r); }
1111
inline float sq(float x) { return PApplet::sq(x); }
1212
inline float lerp(float a,float b,float t) { return PApplet::lerp(a,b,t); }
1313
inline bool* getKeysDown() { return PApplet::g_papplet ? PApplet::g_papplet->keysDown : nullptr; }
14+
// print/println for hoisted classes
15+
template<typename T> inline void print(const T& v) { ::std::cout << v; ::std::cout.flush(); }
16+
template<typename T> inline void println(const T& v) { ::std::cout << v << "\n"; ::std::cout.flush(); }
17+
inline void println() { ::std::cout << "\n"; ::std::cout.flush(); }
18+
template<typename T> inline void printArray(const ::std::vector<T>& a) {
19+
for(int i=0;i<(int)a.size();i++) ::std::cout<<"["<<i<<"] "<<a[i]<<"\n";
20+
::std::cout.flush();
21+
}
22+
1423
// File/IO functions for hoisted classes
1524
inline ::std::string sketchPath(const ::std::string& w="") { return ::Processing::sketchPath(w); }
1625
inline ::std::string dataPath(const ::std::string& w="") { return ::Processing::dataPath(w); }

0 commit comments

Comments
 (0)