forked from NerdLang/nerd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ab3fe50
commit 270d651
Showing
111 changed files
with
47,147 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* This file is part of NectarJS | ||
* Copyright (c) 2017-2020 Adrien THIERRY | ||
* http://nectarjs.com - https://www.linkedin.com/in/adrien-thierry-fr/ | ||
* | ||
* sources : https://github.com/nectarjs/nectarjs/ | ||
* | ||
* this program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* You can be released from the requirements of the license by purchasing | ||
* a commercial license. Buying such a license is mandatory as soon as you | ||
* develop commercial activities involving the NectarJS software without | ||
* disclosing the source code of your own applications. Visit http://seraum.com/ | ||
* and feel free to contact us. | ||
* | ||
*/ | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include <cstring> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <sstream> | ||
#include <vector> | ||
#include <memory> | ||
#include "uv.h" | ||
|
||
using namespace std; | ||
|
||
|
||
#include "njs.h" | ||
using namespace NECTAR; | ||
|
||
{INCLUDE} | ||
|
||
{DECL} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
var __NJS_ARGS = __NJS_Create_Array(); | ||
for( int i = 0; i < argc; i++) | ||
{ | ||
__NJS_Object_Set(i, __NJS_VAR(argv[i]), __NJS_ARGS); | ||
} | ||
|
||
{INIT} | ||
|
||
uv_loop_t *loop = (uv_loop_t *)malloc(sizeof(uv_loop_t)); | ||
uv_loop_init(loop); | ||
|
||
{CODE}; | ||
|
||
printf("Exiting.\n"); | ||
uv_run(loop, UV_RUN_DEFAULT); | ||
|
||
uv_loop_close(loop); | ||
free(loop); | ||
return 0; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,9 @@ | |
|
||
using namespace std; | ||
|
||
|
||
#include "njs.h" | ||
using namespace NECTAR; | ||
|
||
{INCLUDE} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
using namespace std; | ||
|
||
#include "njs.h" | ||
using namespace NECTAR; | ||
|
||
{INCLUDE} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html> | ||
<script> | ||
var Module = {}; | ||
|
||
function WasmLoaded() | ||
{ | ||
console.log(Module.callNectar("callFromJS", "Hello From NectarJS !")); | ||
} | ||
</script> | ||
<script src="wasm_export.asm.js"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var WASM = require("WASM"); | ||
|
||
// function proto for binding : string(string) | ||
function callFromJS(_data) | ||
{ | ||
if(!_data) WASM.run("document.write('<h1>No Data</h1>');"); | ||
else WASM.run("document.write('<h1>" + _data + "</h1>');"); | ||
return "Executed from WASM"; | ||
} | ||
|
||
// bind function to be executed in Browser env with Module.callNectar(_functionName, _data); | ||
WASM.bind("callFromJS", callFromJS); | ||
|
||
// Fire a JS function to know when env is set up, see wasm.html | ||
WASM.run("WasmLoaded();"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 1995, 1999 | ||
* Berkeley Software Design, Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND | ||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
* SUCH DAMAGE. | ||
* | ||
* BSDI ifaddrs.h,v 2.5 2000/02/23 14:51:59 dab Exp | ||
*/ | ||
|
||
#ifndef _IFADDRS_H_ | ||
#define _IFADDRS_H_ | ||
|
||
struct ifaddrs { | ||
struct ifaddrs *ifa_next; | ||
char *ifa_name; | ||
unsigned int ifa_flags; | ||
struct sockaddr *ifa_addr; | ||
struct sockaddr *ifa_netmask; | ||
struct sockaddr *ifa_dstaddr; | ||
void *ifa_data; | ||
}; | ||
|
||
/* | ||
* This may have been defined in <net/if.h>. Note that if <net/if.h> is | ||
* to be included it must be included before this header file. | ||
*/ | ||
#ifndef ifa_broadaddr | ||
#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ | ||
#endif | ||
|
||
#include <sys/cdefs.h> | ||
|
||
__BEGIN_DECLS | ||
extern int getifaddrs(struct ifaddrs **ifap); | ||
extern void freeifaddrs(struct ifaddrs *ifa); | ||
__END_DECLS | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Copyright (c) 2016, Kari Tristan Helgason <[email protected]> | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#ifndef _UV_PTHREAD_BARRIER_ | ||
#define _UV_PTHREAD_BARRIER_ | ||
#include <errno.h> | ||
#include <pthread.h> | ||
#include <semaphore.h> /* sem_t */ | ||
|
||
#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 | ||
|
||
/* | ||
* To maintain ABI compatibility with | ||
* libuv v1.x struct is padded according | ||
* to target platform | ||
*/ | ||
#if defined(__ANDROID__) | ||
# define UV_BARRIER_STRUCT_PADDING \ | ||
sizeof(pthread_mutex_t) + \ | ||
sizeof(pthread_cond_t) + \ | ||
sizeof(unsigned int) - \ | ||
sizeof(void *) | ||
#elif defined(__APPLE__) | ||
# define UV_BARRIER_STRUCT_PADDING \ | ||
sizeof(pthread_mutex_t) + \ | ||
2 * sizeof(sem_t) + \ | ||
2 * sizeof(unsigned int) - \ | ||
sizeof(void *) | ||
#endif | ||
|
||
typedef struct { | ||
pthread_mutex_t mutex; | ||
pthread_cond_t cond; | ||
unsigned threshold; | ||
unsigned in; | ||
unsigned out; | ||
} _uv_barrier; | ||
|
||
typedef struct { | ||
_uv_barrier* b; | ||
char _pad[UV_BARRIER_STRUCT_PADDING]; | ||
} pthread_barrier_t; | ||
|
||
int pthread_barrier_init(pthread_barrier_t* barrier, | ||
const void* barrier_attr, | ||
unsigned count); | ||
|
||
int pthread_barrier_wait(pthread_barrier_t* barrier); | ||
int pthread_barrier_destroy(pthread_barrier_t *barrier); | ||
|
||
#endif /* _UV_PTHREAD_BARRIER_ */ |
Oops, something went wrong.