Skip to content

Commit fd6739a

Browse files
committed
📌 Nodepp | Optimization Fixing | V1.3.1 📌
1 parent 1aa49f7 commit fd6739a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+822
-541
lines changed

examples/0-Terminal_Color.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <nodepp/nodepp.h>
2+
3+
using namespace nodepp;
4+
5+
void onMain() {
6+
7+
conio::background( conio::color::cyan | conio::color::bold );
8+
console::log( "hello world!" );
9+
conio::reset();
10+
11+
conio::foreground( conio::color::red | conio::color::bold );
12+
console::log( "hello world!" );
13+
conio::reset();
14+
15+
conio::background( conio::color::magenta | conio::color::bold );
16+
console::log( "hello world!" );
17+
conio::reset();
18+
19+
conio::foreground( conio::color::blue | conio::color::bold );
20+
console::log( "hello world!" );
21+
conio::reset();
22+
23+
conio::background( conio::color::yellow | conio::color::bold );
24+
console::log( "hello world!" );
25+
conio::reset();
26+
27+
conio::foreground( conio::color::green | conio::color::bold );
28+
console::log( "hello world!" );
29+
conio::reset();
30+
31+
}

include/nodepp/cluster.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "fs.h"
2020
#include "worker.h"
2121
#include "initializer.h"
22-
#include "windows/cluster.cpp"
22+
#include "windows/cluster.h"
2323

2424
namespace nodepp { namespace cluster {
2525

@@ -35,12 +35,12 @@
3535
template< class... T > int await( const T&... args ){
3636
auto pid = type::bind( cluster_t(args...) );
3737
if( process::is_parent() ) {
38-
return process::await([=](){ return pid->next(); });
38+
return worker::await([=](){ return pid->next(); });
3939
} return -1; }
4040

41-
bool is_child(){ return !process::env::get("CHILD").empty(); }
41+
inline bool is_child(){ return !process::env::get("CHILD").empty(); }
4242

43-
bool is_parent(){ return process::env::get("CHILD").empty(); }
43+
inline bool is_parent(){ return process::env::get("CHILD").empty(); }
4444

4545
}}
4646

@@ -49,7 +49,7 @@
4949

5050
#include "fs.h"
5151
#include "initializer.h"
52-
#include "posix/cluster.cpp"
52+
#include "posix/cluster.h"
5353

5454
namespace nodepp { namespace cluster {
5555

@@ -68,9 +68,9 @@
6868
return process::await([=](){ return pid->next(); });
6969
} return -1; }
7070

71-
bool is_child(){ return !process::env::get("CHILD").empty(); }
71+
inline bool is_child(){ return !process::env::get("CHILD").empty(); }
7272

73-
bool is_parent(){ return process::env::get("CHILD").empty(); }
73+
inline bool is_parent(){ return process::env::get("CHILD").empty(); }
7474

7575
}}
7676

include/nodepp/conio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
/*────────────────────────────────────────────────────────────────────────────*/
1616

1717
#if _KERNEL_ == NODEPP_KERNEL_WINDOWS
18-
#include "windows/conio.cpp"
18+
#include "windows/conio.h"
1919
#else
20-
#include "posix/conio.cpp"
20+
#include "posix/conio.h"
2121
#endif
2222

2323
/*────────────────────────────────────────────────────────────────────────────*/

include/nodepp/console.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ namespace nodepp { namespace console {
3232
template< class... T >
3333
int pout( const T&... args ){ return conio::log( args... ); }
3434

35-
void wait(){ char x; conio::scan("%c",&x); }
35+
inline void wait(){ char x; conio::scan("%c",&x); }
3636

37-
void clear(){ conio::clear(); }
37+
inline void clear(){ conio::clear(); }
3838

3939
/*─······································································─*/
4040

include/nodepp/cookie.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
namespace nodepp { using cookie_t = map_t< string_t, string_t >;
2323
namespace cookie {
2424

25-
query_t parse( string_t data ){
25+
inline query_t parse( string_t data ){
2626
static regex_t reg( "([^= ;]+)=([^;]+)" );
2727

2828
if( data.empty() ){ return query_t(); } query_t out;
@@ -38,7 +38,7 @@ namespace cookie {
3838

3939
/*─······································································─*/
4040

41-
string_t format( const cookie_t& data ){
41+
inline string_t format( const cookie_t& data ){
4242
if( data.empty() ){ return nullptr; } /*------*/
4343
array_t<string_t> out; for( auto x:data.data() )
4444
{ out.push( x.first + "=" + x.second ); }

include/nodepp/coroutine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ namespace nodepp { class coroutine_t {
7272
/*────────────────────────────────────────────────────────────────────────────*/
7373

7474
namespace nodepp { namespace coroutine {
75-
coroutine_t add( function_t<int,int&,ulong&> callback ) {
75+
inline coroutine_t add( function_t<int,int&,ulong&> callback ) {
7676
return coroutine_t( callback );
7777
}
7878
}}

include/nodepp/date.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -187,22 +187,22 @@ namespace nodepp { class date_t {
187187

188188
namespace nodepp {
189189

190-
date_t operator+( const date_t& A, const date_t& B ){
190+
inline date_t operator+( const date_t& A, const date_t& B ){
191191
date_t C; C.set_stamp( A.get_stamp() + B.get_stamp(), false );
192192
return C;
193193
}
194194

195-
date_t operator-( const date_t& A, const date_t& B ){
195+
inline date_t operator-( const date_t& A, const date_t& B ){
196196
date_t C; C.set_stamp( A.get_stamp() - B.get_stamp(), false );
197197
return C;
198198
}
199199

200-
date_t operator*( const date_t& A, const date_t& B ){
200+
inline date_t operator*( const date_t& A, const date_t& B ){
201201
date_t C; C.set_stamp( A.get_stamp() * B.get_stamp(), false );
202202
return C;
203203
}
204204

205-
date_t operator/( const date_t& A, const date_t& B ){
205+
inline date_t operator/( const date_t& A, const date_t& B ){
206206
date_t C; C.set_stamp( A.get_stamp() / B.get_stamp(), false );
207207
return C;
208208
}
@@ -213,21 +213,21 @@ namespace nodepp {
213213

214214
namespace nodepp { namespace date {
215215

216-
uint now(){ return date_t().get_stamp(); }
216+
inline uint now(){ return date_t().get_stamp(); }
217217

218-
string_t fulltime(){ return date_t().get_fulltime(); }
218+
inline string_t fulltime(){ return date_t().get_fulltime(); }
219219

220-
uint day( const bool& utc ){ return date_t(utc).get_day(); }
220+
inline uint day( const bool& utc ){ return date_t(utc).get_day(); }
221221

222-
uint year( const bool& utc ){ return date_t(utc).get_year(); }
222+
inline uint year( const bool& utc ){ return date_t(utc).get_year(); }
223223

224-
uint hour( const bool& utc ){ return date_t(utc).get_hour(); }
224+
inline uint hour( const bool& utc ){ return date_t(utc).get_hour(); }
225225

226-
uint month( const bool& utc ){ return date_t(utc).get_month(); }
226+
inline uint month( const bool& utc ){ return date_t(utc).get_month(); }
227227

228-
uint minute( const bool& utc ){ return date_t(utc).get_minute(); }
228+
inline uint minute( const bool& utc ){ return date_t(utc).get_minute(); }
229229

230-
uint second( const bool& utc ){ return date_t(utc).get_second(); }
230+
inline uint second( const bool& utc ){ return date_t(utc).get_second(); }
231231

232232
}}
233233

include/nodepp/dns.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
#if _KERNEL_ == NODEPP_KERNEL_WINDOWS
1818
#include "url.h"
1919
#include "socket.h"
20-
#include "windows/dns.cpp"
20+
#include "windows/dns.h"
2121
#elif _KERNEL_ == NODEPP_KERNEL_POSIX
2222
#include "url.h"
2323
#include "socket.h"
24-
#include "posix/dns.cpp"
24+
#include "posix/dns.h"
2525
#else
2626
#error "This OS Does not support dns.h"
2727
#endif

include/nodepp/encoder.h

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,44 @@
2323

2424
namespace nodepp { namespace encoder { namespace key {
2525

26-
string_t generate( const string_t& alph, int x=32 ){ ulong idx=0;
26+
inline string_t generate( const string_t& alph, int x=32 ){ ulong idx=0;
2727
string_t data ( (ulong)x, '\0' ); for( auto &x: data ){
2828
x = alph[rand()%(alph.size())]; ++idx; } return data;
2929
}
3030

31-
string_t generate( int x=32 ) { return generate( NODEPP_BASE64, x ); }
31+
inline string_t generate( int x=32 ) { return generate( NODEPP_BASE64, x ); }
3232

3333
}}}
3434

3535
/*────────────────────────────────────────────────────────────────────────────*/
3636

3737
namespace nodepp { namespace encoder { namespace hash {
3838

39-
ulong get( const string_t& key, int tableSize ) {
39+
inline ulong get( const string_t& key, int tableSize ) {
4040
ulong hash = 5381; forEach( x, key ) {
4141
hash = ((hash << 5) + hash) + x;
4242
} return hash % tableSize;
4343
}
4444

45-
ulong get( int key, int tableSize ) { return key % tableSize; }
45+
inline ulong get( int key, int tableSize ) { return key % tableSize; }
4646

47-
ulong get( const string_t& key ) { return get( key, HASH_TABLE_SIZE ); }
47+
inline ulong get( const string_t& key ) { return get( key, HASH_TABLE_SIZE ); }
4848

4949
}}}
5050

5151
/*────────────────────────────────────────────────────────────────────────────*/
5252

5353
namespace nodepp { namespace encoder { namespace XOR {
5454

55-
string_t get( string_t data, const string_t& key ){
55+
inline string_t get( string_t data, const string_t& key ){
5656
auto tmp= data.copy();
5757
ulong pos= 0; forEach( x, tmp ) {
5858
x = x^ key[pos]; ++pos;
5959
pos %= key.size();
6060
} return tmp;
6161
}
6262

63-
string_t set( string_t data, const string_t& key ){
63+
inline string_t set( string_t data, const string_t& key ){
6464
auto tmp= data.copy();
6565
ulong pos= 0; forEach( x, tmp ) {
6666
x = x^ key[pos]; ++pos;
@@ -173,14 +173,14 @@ namespace nodepp { namespace encoder { namespace hex {
173173

174174
namespace nodepp { namespace encoder { namespace hex {
175175

176-
string_t get( const ptr_t<uchar>& inp ){
176+
inline string_t get( const ptr_t<uchar>& inp ){
177177
if ( inp.empty() ){ return nullptr; }
178178
queue_t<char> out; for( auto x : inp ){
179179
for( auto y: get(x) ){ out.push( y ); }
180180
} out.push('\0'); return string_t( out.data() );
181181
}
182182

183-
ptr_t<uchar> set( string_t x ){
183+
inline ptr_t<uchar> set( string_t x ){
184184
if ( x.empty() ){ return nullptr; }
185185
ulong size = x.size()/2 + ( x.size()%2 != 0?1:0 );
186186
ptr_t<uchar> out(size,'\0'); for( auto &y : out ){
@@ -190,25 +190,25 @@ namespace nodepp { namespace encoder { namespace hex {
190190

191191
/*─······································································─*/
192192

193-
ptr_t<uchar> btoa( string_t inp ) { return set( inp ); }
193+
inline ptr_t<uchar> btoa( string_t inp ) { return set( inp ); }
194194

195-
string_t atob( const ptr_t<uchar>& inp ) { return get( inp ); }
195+
inline string_t atob( const ptr_t<uchar>& inp ) { return get( inp ); }
196196

197197
}}}
198198

199199
/*────────────────────────────────────────────────────────────────────────────*/
200200

201201
namespace nodepp { namespace encoder { namespace buffer {
202202

203-
string_t hex2buff( const string_t& inp ){
203+
inline string_t hex2buff( const string_t& inp ){
204204
if( inp.empty() ){ return nullptr; }
205205
ptr_t<uchar> buff = hex::set(inp);
206206
string_t raw ( buff.size() + 1 );
207207
memcpy( raw.get(), &buff, buff.size() );
208208
return raw;
209209
}
210210

211-
string_t buff2hex( const string_t& inp ){
211+
inline string_t buff2hex( const string_t& inp ){
212212
if( inp.empty() ){ return nullptr; }
213213
auto raw = ptr_t<uchar>( inp.size() );
214214
memcpy( &raw, inp.get(), inp.size() );
@@ -217,27 +217,27 @@ namespace nodepp { namespace encoder { namespace buffer {
217217

218218
/*─······································································─*/
219219

220-
string_t atob( const string_t& inp ) { return buff2hex( inp ); }
220+
inline string_t atob( const string_t& inp ) { return buff2hex( inp ); }
221221

222-
string_t btoa( const string_t& inp ) { return hex2buff( inp ); }
222+
inline string_t btoa( const string_t& inp ) { return hex2buff( inp ); }
223223

224224
}}}
225225

226226
/*────────────────────────────────────────────────────────────────────────────*/
227227

228228
namespace nodepp { namespace encoder { namespace base16 {
229229

230-
string_t atob( const string_t& inp ) { return buffer::buff2hex( inp ); }
230+
inline string_t atob( const string_t& inp ) { return buffer::buff2hex( inp ); }
231231

232-
string_t btoa( const string_t& inp ) { return buffer::hex2buff( inp ); }
232+
inline string_t btoa( const string_t& inp ) { return buffer::hex2buff( inp ); }
233233

234234
}}}
235235

236236
/*────────────────────────────────────────────────────────────────────────────*/
237237

238238
namespace nodepp { namespace encoder { namespace base64 {
239239

240-
string_t get( const string_t &in ) {
240+
inline string_t get( const string_t &in ) {
241241

242242
queue_t<char> out; int pos1 = 0, pos2 = -6;
243243

@@ -255,7 +255,7 @@ namespace nodepp { namespace encoder { namespace base64 {
255255
out.push('\0'); return string_t( out.data() );
256256
}
257257

258-
string_t set( const string_t &in ) {
258+
inline string_t set( const string_t &in ) {
259259

260260
queue_t<char> out; int pos1=0, pos2=-8;
261261
array_t<int> T( 256, -1 );
@@ -274,31 +274,31 @@ namespace nodepp { namespace encoder { namespace base64 {
274274

275275
/*─······································································─*/
276276

277-
string_t btoa( const string_t &in ) { return set( in ); }
277+
inline string_t btoa( const string_t &in ) { return set( in ); }
278278

279-
string_t atob( const string_t &in ) { return get( in ); }
279+
inline string_t atob( const string_t &in ) { return get( in ); }
280280

281281
}}}
282282

283283
/*────────────────────────────────────────────────────────────────────────────*/
284284

285285
namespace nodepp { namespace encoder { namespace utf8 {
286-
ptr_t<uint16> to_utf16( ptr_t<uint8> inp ){ return utf::utf8_to_utf16( inp ); }
287-
ptr_t<uint32> to_utf32( ptr_t<uint8> inp ){ return utf::utf8_to_utf32( inp ); }
286+
inline ptr_t<uint16> to_utf16( ptr_t<uint8> inp ){ return utf::utf8_to_utf16( inp ); }
287+
inline ptr_t<uint32> to_utf32( ptr_t<uint8> inp ){ return utf::utf8_to_utf32( inp ); }
288288
}}}
289289

290290
/*────────────────────────────────────────────────────────────────────────────*/
291291

292292
namespace nodepp { namespace encoder { namespace utf16 {
293-
ptr_t<uint8> to_utf8 ( ptr_t<uint16> inp ){ return utf::utf16_to_utf8 ( inp ); }
294-
ptr_t<uint32> to_utf32( ptr_t<uint16> inp ){ return utf::utf16_to_utf32( inp ); }
293+
inline ptr_t<uint8> to_utf8 ( ptr_t<uint16> inp ){ return utf::utf16_to_utf8 ( inp ); }
294+
inline ptr_t<uint32> to_utf32( ptr_t<uint16> inp ){ return utf::utf16_to_utf32( inp ); }
295295
}}}
296296

297297
/*────────────────────────────────────────────────────────────────────────────*/
298298

299299
namespace nodepp { namespace encoder { namespace utf32 {
300-
ptr_t<uint8> to_utf8 ( ptr_t<uint32> inp ){ return utf::utf32_to_utf8 ( inp ); }
301-
ptr_t<uint16> to_utf16( ptr_t<uint32> inp ){ return utf::utf32_to_utf16( inp ); }
300+
inline ptr_t<uint8> to_utf8 ( ptr_t<uint32> inp ){ return utf::utf32_to_utf8 ( inp ); }
301+
inline ptr_t<uint16> to_utf16( ptr_t<uint32> inp ){ return utf::utf32_to_utf16( inp ); }
302302
}}}
303303

304304
/*────────────────────────────────────────────────────────────────────────────*/

include/nodepp/env.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
#if _KERNEL_ == NODEPP_KERNEL_WINDOWS
1818
#include "file.h"
19-
#include "windows/env.cpp"
19+
#include "windows/env.h"
2020
#elif _KERNEL_ == NODEPP_KERNEL_POSIX
2121
#include "file.h"
22-
#include "posix/env.cpp"
22+
#include "posix/env.h"
2323
#else
2424
#error "This OS Does not support env.h"
2525
#endif

0 commit comments

Comments
 (0)