mirror of
https://github.com/wgh136/flutter_qjs.git
synced 2025-09-27 05:27:23 +00:00
quickjs msvc
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
|||||||
[submodule "cxx/quickjspp"]
|
|
||||||
path = cxx/quickjspp
|
|
||||||
url = https://github.com/ekibun/quickjspp.git
|
|
47
README.md
47
README.md
@@ -3,7 +3,7 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-08 08:16:50
|
* @Date: 2020-08-08 08:16:50
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-20 00:33:22
|
* @LastEditTime: 2020-08-20 12:02:54
|
||||||
-->
|
-->
|
||||||
# flutter_qjs
|
# flutter_qjs
|
||||||
|
|
||||||
@@ -11,9 +11,9 @@ A quickjs engine for flutter.
|
|||||||
|
|
||||||
## Feature
|
## Feature
|
||||||
|
|
||||||
This plugin is a simple js engine for flutter used `quickjs` project.
|
This plugin is a simple js engine for flutter used `quickjs` project. Plugin currently supports Windows, Linux, and Android.
|
||||||
|
|
||||||
Each `FlutterJs` object create a new thread that running a simple js loop. A global async function `dart` is presented to invoke dart function, and `Promise` is supported in evaluating js script so that you can use `await` or `then` to get external result from `dart`.
|
Each `FlutterJs` object creates a new thread that runs a simple js loop. A global async function `dart` is presented to invoke dart function, and `Promise` is supported so that you can use `await` or `then` to get external result from `dart`.
|
||||||
|
|
||||||
Data convertion between dart and js are implemented as follow:
|
Data convertion between dart and js are implemented as follow:
|
||||||
|
|
||||||
@@ -36,13 +36,46 @@ Data convertion between dart and js are implemented as follow:
|
|||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
1. Creat a `FlutterJs` object. Makes sure call `close` to release memory when not need it.
|
1. Creat a `FlutterJs` object. Make sure call `close` to terminate thread and release memory when you don't need it.
|
||||||
|
|
||||||
2. Call `setMethodHandler` to maintain `dart` function.
|
```dart
|
||||||
|
FlutterJs engine = FlutterJs();
|
||||||
|
// do something ...
|
||||||
|
await engine.destroy();
|
||||||
|
engine = null;
|
||||||
|
```
|
||||||
|
|
||||||
3. Use `evaluate` to evaluate js script. Makes sure surrounding try-cacth to capture evaluating error.
|
2. Call `setMethodHandler` to implements `dart` interaction. For example, you can use `Dio` to implements http in js:
|
||||||
|
|
||||||
[this](example/lib/test.dart) contains a fully use of this plugin.
|
```dart
|
||||||
|
engine.setMethodHandler((String method, List arg) async {
|
||||||
|
switch (method) {
|
||||||
|
case "http":
|
||||||
|
Response response = await Dio().get(arg[0]);
|
||||||
|
return response.data;
|
||||||
|
default:
|
||||||
|
return JsMethodHandlerNotImplement();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
and in javascript, call `dart` function to get data:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
dart("http", "https://baidu.com");
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Use `evaluate` to run js script, and try-cacth is needed to capture exception.
|
||||||
|
|
||||||
|
```
|
||||||
|
try {
|
||||||
|
resp = "${await engine.evaluate(code ?? '', "<eval>")}";
|
||||||
|
} catch (e) {
|
||||||
|
resp = e.toString();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
[Example](example/lib/test.dart) contains a fully use of this plugin.
|
||||||
|
|
||||||
**notice:**
|
**notice:**
|
||||||
To use this plugin in Linux desktop application, you must change `cxx_std_14` to `cxx_std_17` in your project's `CMakeLists.txt`.
|
To use this plugin in Linux desktop application, you must change `cxx_std_14` to `cxx_std_17` in your project's `CMakeLists.txt`.
|
@@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
cmake_minimum_required(VERSION 3.4.1)
|
cmake_minimum_required(VERSION 3.4.1)
|
||||||
set(JNI_LIB_NAME libjsengine)
|
set(JNI_LIB_NAME libjsengine)
|
||||||
set(QUICK_JS_LIB_DIR ../../../../cxx/quickjspp)
|
|
||||||
|
|
||||||
|
|
||||||
# Creates and names a library, sets it as either STATIC
|
# Creates and names a library, sets it as either STATIC
|
||||||
# or SHARED, and provides the relative paths to its source code.
|
# or SHARED, and provides the relative paths to its source code.
|
||||||
@@ -23,13 +21,14 @@ add_library( # Sets the name of the library.
|
|||||||
native-lib.cpp )
|
native-lib.cpp )
|
||||||
|
|
||||||
# quickjs
|
# quickjs
|
||||||
file (STRINGS "${QUICK_JS_LIB_DIR}/quickjs/VERSION" QUICKJS_VERSION)
|
set(QUICK_JS_LIB_DIR ../../../../cxx/quickjs)
|
||||||
|
file (STRINGS "${QUICK_JS_LIB_DIR}/VERSION" QUICKJS_VERSION)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCONFIG_VERSION=\\\"${QUICKJS_VERSION}\\\"")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCONFIG_VERSION=\\\"${QUICKJS_VERSION}\\\"")
|
||||||
target_sources(${JNI_LIB_NAME} PUBLIC
|
target_sources(${JNI_LIB_NAME} PUBLIC
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/cutils.c
|
${QUICK_JS_LIB_DIR}/cutils.c
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/libregexp.c
|
${QUICK_JS_LIB_DIR}/libregexp.c
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/libunicode.c
|
${QUICK_JS_LIB_DIR}/libunicode.c
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/quickjs.c
|
${QUICK_JS_LIB_DIR}/quickjs.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# Searches for a specified prebuilt library and stores the path as a
|
# Searches for a specified prebuilt library and stores the path as a
|
||||||
|
@@ -3,12 +3,11 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-16 11:08:23
|
* @Date: 2020-08-16 11:08:23
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-19 13:06:19
|
* @LastEditTime: 2020-08-20 11:29:32
|
||||||
*/
|
*/
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "jni_helper.hpp"
|
#include "jni_helper.hpp"
|
||||||
#include <android/log.h>
|
|
||||||
#include "../../../../cxx/js_engine.hpp"
|
#include "../../../../cxx/js_engine.hpp"
|
||||||
|
|
||||||
namespace std
|
namespace std
|
||||||
@@ -37,7 +36,6 @@ namespace qjs
|
|||||||
jmethodID mid = env->GetMethodID(classclass, "getName", "()Ljava/lang/String;");
|
jmethodID mid = env->GetMethodID(classclass, "getName", "()Ljava/lang/String;");
|
||||||
jobject clsObj = env->CallObjectMethod(objclass, mid);
|
jobject clsObj = env->CallObjectMethod(objclass, mid);
|
||||||
std::string className(env->GetStringUTFChars((jstring)clsObj, 0));
|
std::string className(env->GetStringUTFChars((jstring)clsObj, 0));
|
||||||
__android_log_print(ANDROID_LOG_DEBUG, "class", "class: %s", className.c_str());
|
|
||||||
if (className.compare("[B") == 0)
|
if (className.compare("[B") == 0)
|
||||||
{
|
{
|
||||||
jsize len = env->GetArrayLength((jbyteArray)val);
|
jsize len = env->GetArrayLength((jbyteArray)val);
|
||||||
|
@@ -3,16 +3,16 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-07 13:55:52
|
* @Date: 2020-08-07 13:55:52
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-15 16:28:38
|
* @LastEditTime: 2020-08-20 11:10:20
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "quickjspp/quickjspp.hpp"
|
#include "quickjs/quickjspp.hpp"
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace qjs
|
namespace qjs
|
||||||
{
|
{
|
||||||
#include "quickjspp/quickjs/list.h"
|
#include "quickjs/list.h"
|
||||||
|
|
||||||
static JSClassID js_dart_promise_class_id;
|
static JSClassID js_dart_promise_class_id;
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-08 10:30:59
|
* @Date: 2020-08-08 10:30:59
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-15 16:31:14
|
* @LastEditTime: 2020-08-20 11:11:30
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "js_dart_promise.hpp"
|
#include "js_dart_promise.hpp"
|
||||||
#include "quickjspp/quickjspp.hpp"
|
|
||||||
|
|
||||||
namespace qjs
|
namespace qjs
|
||||||
{
|
{
|
||||||
|
1
cxx/quickjs/VERSION
Normal file
1
cxx/quickjs/VERSION
Normal file
@@ -0,0 +1 @@
|
|||||||
|
2020-07-05
|
616
cxx/quickjs/cutils.c
Normal file
616
cxx/quickjs/cutils.c
Normal file
@@ -0,0 +1,616 @@
|
|||||||
|
/*
|
||||||
|
* C utilities
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 Fabrice Bellard
|
||||||
|
* Copyright (c) 2018 Charlie Gordon
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "cutils.h"
|
||||||
|
|
||||||
|
void pstrcpy(char *buf, int buf_size, const char *str)
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
char *q = buf;
|
||||||
|
|
||||||
|
if (buf_size <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(;;) {
|
||||||
|
c = *str++;
|
||||||
|
if (c == 0 || q >= buf + buf_size - 1)
|
||||||
|
break;
|
||||||
|
*q++ = c;
|
||||||
|
}
|
||||||
|
*q = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* strcat and truncate. */
|
||||||
|
char *pstrcat(char *buf, int buf_size, const char *s)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
len = strlen(buf);
|
||||||
|
if (len < buf_size)
|
||||||
|
pstrcpy(buf + len, buf_size - len, s);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
int strstart(const char *str, const char *val, const char **ptr)
|
||||||
|
{
|
||||||
|
const char *p, *q;
|
||||||
|
p = str;
|
||||||
|
q = val;
|
||||||
|
while (*q != '\0') {
|
||||||
|
if (*p != *q)
|
||||||
|
return 0;
|
||||||
|
p++;
|
||||||
|
q++;
|
||||||
|
}
|
||||||
|
if (ptr)
|
||||||
|
*ptr = p;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int has_suffix(const char *str, const char *suffix)
|
||||||
|
{
|
||||||
|
size_t len = strlen(str);
|
||||||
|
size_t slen = strlen(suffix);
|
||||||
|
return (len >= slen && !memcmp(str + len - slen, suffix, slen));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Dynamic buffer package */
|
||||||
|
|
||||||
|
static void *dbuf_default_realloc(void *opaque, void *ptr, size_t size)
|
||||||
|
{
|
||||||
|
return realloc(ptr, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbuf_init2(DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func)
|
||||||
|
{
|
||||||
|
memset(s, 0, sizeof(*s));
|
||||||
|
if (!realloc_func)
|
||||||
|
realloc_func = dbuf_default_realloc;
|
||||||
|
s->opaque = opaque;
|
||||||
|
s->realloc_func = realloc_func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbuf_init(DynBuf *s)
|
||||||
|
{
|
||||||
|
dbuf_init2(s, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return < 0 if error */
|
||||||
|
int dbuf_realloc(DynBuf *s, size_t new_size)
|
||||||
|
{
|
||||||
|
size_t size;
|
||||||
|
uint8_t *new_buf;
|
||||||
|
if (new_size > s->allocated_size) {
|
||||||
|
if (s->error)
|
||||||
|
return -1;
|
||||||
|
size = s->allocated_size * 3 / 2;
|
||||||
|
if (size > new_size)
|
||||||
|
new_size = size;
|
||||||
|
new_buf = s->realloc_func(s->opaque, s->buf, new_size);
|
||||||
|
if (!new_buf) {
|
||||||
|
s->error = TRUE;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
s->buf = new_buf;
|
||||||
|
s->allocated_size = new_size;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbuf_write(DynBuf *s, size_t offset, const uint8_t *data, size_t len)
|
||||||
|
{
|
||||||
|
size_t end;
|
||||||
|
end = offset + len;
|
||||||
|
if (dbuf_realloc(s, end))
|
||||||
|
return -1;
|
||||||
|
memcpy(s->buf + offset, data, len);
|
||||||
|
if (end > s->size)
|
||||||
|
s->size = end;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbuf_put(DynBuf *s, const uint8_t *data, size_t len)
|
||||||
|
{
|
||||||
|
if (unlikely((s->size + len) > s->allocated_size)) {
|
||||||
|
if (dbuf_realloc(s, s->size + len))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(s->buf + s->size, data, len);
|
||||||
|
s->size += len;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbuf_put_self(DynBuf *s, size_t offset, size_t len)
|
||||||
|
{
|
||||||
|
if (unlikely((s->size + len) > s->allocated_size)) {
|
||||||
|
if (dbuf_realloc(s, s->size + len))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
memcpy(s->buf + s->size, s->buf + offset, len);
|
||||||
|
s->size += len;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbuf_putc(DynBuf *s, uint8_t c)
|
||||||
|
{
|
||||||
|
return dbuf_put(s, &c, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dbuf_putstr(DynBuf *s, const char *str)
|
||||||
|
{
|
||||||
|
return dbuf_put(s, (const uint8_t *)str, strlen(str));
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
__attribute__((format(printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
dbuf_printf(DynBuf *s, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
char buf[128];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
len = vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
if (len < sizeof(buf)) {
|
||||||
|
/* fast case */
|
||||||
|
return dbuf_put(s, (uint8_t *)buf, len);
|
||||||
|
} else {
|
||||||
|
if (dbuf_realloc(s, s->size + len + 1))
|
||||||
|
return -1;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vsnprintf((char *)(s->buf + s->size), s->allocated_size - s->size,
|
||||||
|
fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
s->size += len;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dbuf_free(DynBuf *s)
|
||||||
|
{
|
||||||
|
/* we test s->buf as a fail safe to avoid crashing if dbuf_free()
|
||||||
|
is called twice */
|
||||||
|
if (s->buf) {
|
||||||
|
s->realloc_func(s->opaque, s->buf, 0);
|
||||||
|
}
|
||||||
|
memset(s, 0, sizeof(*s));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Note: at most 31 bits are encoded. At most UTF8_CHAR_LEN_MAX bytes
|
||||||
|
are output. */
|
||||||
|
int unicode_to_utf8(uint8_t *buf, unsigned int c)
|
||||||
|
{
|
||||||
|
uint8_t *q = buf;
|
||||||
|
|
||||||
|
if (c < 0x80) {
|
||||||
|
*q++ = c;
|
||||||
|
} else {
|
||||||
|
if (c < 0x800) {
|
||||||
|
*q++ = (c >> 6) | 0xc0;
|
||||||
|
} else {
|
||||||
|
if (c < 0x10000) {
|
||||||
|
*q++ = (c >> 12) | 0xe0;
|
||||||
|
} else {
|
||||||
|
if (c < 0x00200000) {
|
||||||
|
*q++ = (c >> 18) | 0xf0;
|
||||||
|
} else {
|
||||||
|
if (c < 0x04000000) {
|
||||||
|
*q++ = (c >> 24) | 0xf8;
|
||||||
|
} else if (c < 0x80000000) {
|
||||||
|
*q++ = (c >> 30) | 0xfc;
|
||||||
|
*q++ = ((c >> 24) & 0x3f) | 0x80;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
*q++ = ((c >> 18) & 0x3f) | 0x80;
|
||||||
|
}
|
||||||
|
*q++ = ((c >> 12) & 0x3f) | 0x80;
|
||||||
|
}
|
||||||
|
*q++ = ((c >> 6) & 0x3f) | 0x80;
|
||||||
|
}
|
||||||
|
*q++ = (c & 0x3f) | 0x80;
|
||||||
|
}
|
||||||
|
return q - buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const unsigned int utf8_min_code[5] = {
|
||||||
|
0x80, 0x800, 0x10000, 0x00200000, 0x04000000,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned char utf8_first_code_mask[5] = {
|
||||||
|
0x1f, 0xf, 0x7, 0x3, 0x1,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* return -1 if error. *pp is not updated in this case. max_len must
|
||||||
|
be >= 1. The maximum length for a UTF8 byte sequence is 6 bytes. */
|
||||||
|
int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp)
|
||||||
|
{
|
||||||
|
int l, c, b, i;
|
||||||
|
|
||||||
|
c = *p++;
|
||||||
|
if (c < 0x80) {
|
||||||
|
*pp = p;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
if (c >= 0xc0 && c <= 0xdf)
|
||||||
|
l = 1;
|
||||||
|
else if (c >= 0xe0 && c <= 0xef)
|
||||||
|
l = 2;
|
||||||
|
else if (c >= 0xf0 && c <= 0xf7)
|
||||||
|
l = 3;
|
||||||
|
else if (c >= 0xf8 && c <= 0xfb)
|
||||||
|
l = 4;
|
||||||
|
else if (c >= 0xfc && c <= 0xfd)
|
||||||
|
l = 5;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
/* check that we have enough characters */
|
||||||
|
if (l > (max_len - 1))
|
||||||
|
return -1;
|
||||||
|
c &= utf8_first_code_mask[l - 1];
|
||||||
|
for(i = 0; i < l; i++) {
|
||||||
|
b = *p++;
|
||||||
|
if (b < 0x80 || b >= 0xc0)
|
||||||
|
return -1;
|
||||||
|
c = (c << 6) | (b & 0x3f);
|
||||||
|
}
|
||||||
|
if (c < utf8_min_code[l - 1])
|
||||||
|
return -1;
|
||||||
|
*pp = p;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
#if defined(EMSCRIPTEN) || defined(__ANDROID__)
|
||||||
|
|
||||||
|
static void *rqsort_arg;
|
||||||
|
static int (*rqsort_cmp)(const void *, const void *, void *);
|
||||||
|
|
||||||
|
static int rqsort_cmp2(const void *p1, const void *p2)
|
||||||
|
{
|
||||||
|
return rqsort_cmp(p1, p2, rqsort_arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* not reentrant, but not needed with emscripten */
|
||||||
|
void rqsort(void *base, size_t nmemb, size_t size,
|
||||||
|
int (*cmp)(const void *, const void *, void *),
|
||||||
|
void *arg)
|
||||||
|
{
|
||||||
|
rqsort_arg = arg;
|
||||||
|
rqsort_cmp = cmp;
|
||||||
|
qsort(base, nmemb, size, rqsort_cmp2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
typedef void (*exchange_f)(void *a, void *b, size_t size);
|
||||||
|
typedef int (*cmp_f)(const void *, const void *, void *opaque);
|
||||||
|
|
||||||
|
static void exchange_bytes(void *a, void *b, size_t size) {
|
||||||
|
uint8_t *ap = (uint8_t *)a;
|
||||||
|
uint8_t *bp = (uint8_t *)b;
|
||||||
|
|
||||||
|
while (size-- != 0) {
|
||||||
|
uint8_t t = *ap;
|
||||||
|
*ap++ = *bp;
|
||||||
|
*bp++ = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_one_byte(void *a, void *b, size_t size) {
|
||||||
|
uint8_t *ap = (uint8_t *)a;
|
||||||
|
uint8_t *bp = (uint8_t *)b;
|
||||||
|
uint8_t t = *ap;
|
||||||
|
*ap = *bp;
|
||||||
|
*bp = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_int16s(void *a, void *b, size_t size) {
|
||||||
|
uint16_t *ap = (uint16_t *)a;
|
||||||
|
uint16_t *bp = (uint16_t *)b;
|
||||||
|
|
||||||
|
for (size /= sizeof(uint16_t); size-- != 0;) {
|
||||||
|
uint16_t t = *ap;
|
||||||
|
*ap++ = *bp;
|
||||||
|
*bp++ = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_one_int16(void *a, void *b, size_t size) {
|
||||||
|
uint16_t *ap = (uint16_t *)a;
|
||||||
|
uint16_t *bp = (uint16_t *)b;
|
||||||
|
uint16_t t = *ap;
|
||||||
|
*ap = *bp;
|
||||||
|
*bp = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_int32s(void *a, void *b, size_t size) {
|
||||||
|
uint32_t *ap = (uint32_t *)a;
|
||||||
|
uint32_t *bp = (uint32_t *)b;
|
||||||
|
|
||||||
|
for (size /= sizeof(uint32_t); size-- != 0;) {
|
||||||
|
uint32_t t = *ap;
|
||||||
|
*ap++ = *bp;
|
||||||
|
*bp++ = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_one_int32(void *a, void *b, size_t size) {
|
||||||
|
uint32_t *ap = (uint32_t *)a;
|
||||||
|
uint32_t *bp = (uint32_t *)b;
|
||||||
|
uint32_t t = *ap;
|
||||||
|
*ap = *bp;
|
||||||
|
*bp = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_int64s(void *a, void *b, size_t size) {
|
||||||
|
uint64_t *ap = (uint64_t *)a;
|
||||||
|
uint64_t *bp = (uint64_t *)b;
|
||||||
|
|
||||||
|
for (size /= sizeof(uint64_t); size-- != 0;) {
|
||||||
|
uint64_t t = *ap;
|
||||||
|
*ap++ = *bp;
|
||||||
|
*bp++ = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_one_int64(void *a, void *b, size_t size) {
|
||||||
|
uint64_t *ap = (uint64_t *)a;
|
||||||
|
uint64_t *bp = (uint64_t *)b;
|
||||||
|
uint64_t t = *ap;
|
||||||
|
*ap = *bp;
|
||||||
|
*bp = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_int128s(void *a, void *b, size_t size) {
|
||||||
|
uint64_t *ap = (uint64_t *)a;
|
||||||
|
uint64_t *bp = (uint64_t *)b;
|
||||||
|
|
||||||
|
for (size /= sizeof(uint64_t) * 2; size-- != 0; ap += 2, bp += 2) {
|
||||||
|
uint64_t t = ap[0];
|
||||||
|
uint64_t u = ap[1];
|
||||||
|
ap[0] = bp[0];
|
||||||
|
ap[1] = bp[1];
|
||||||
|
bp[0] = t;
|
||||||
|
bp[1] = u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void exchange_one_int128(void *a, void *b, size_t size) {
|
||||||
|
uint64_t *ap = (uint64_t *)a;
|
||||||
|
uint64_t *bp = (uint64_t *)b;
|
||||||
|
uint64_t t = ap[0];
|
||||||
|
uint64_t u = ap[1];
|
||||||
|
ap[0] = bp[0];
|
||||||
|
ap[1] = bp[1];
|
||||||
|
bp[0] = t;
|
||||||
|
bp[1] = u;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline exchange_f exchange_func(const void *base, size_t size) {
|
||||||
|
switch (((uintptr_t)base | (uintptr_t)size) & 15) {
|
||||||
|
case 0:
|
||||||
|
if (size == sizeof(uint64_t) * 2)
|
||||||
|
return exchange_one_int128;
|
||||||
|
else
|
||||||
|
return exchange_int128s;
|
||||||
|
case 8:
|
||||||
|
if (size == sizeof(uint64_t))
|
||||||
|
return exchange_one_int64;
|
||||||
|
else
|
||||||
|
return exchange_int64s;
|
||||||
|
case 4:
|
||||||
|
case 12:
|
||||||
|
if (size == sizeof(uint32_t))
|
||||||
|
return exchange_one_int32;
|
||||||
|
else
|
||||||
|
return exchange_int32s;
|
||||||
|
case 2:
|
||||||
|
case 6:
|
||||||
|
case 10:
|
||||||
|
case 14:
|
||||||
|
if (size == sizeof(uint16_t))
|
||||||
|
return exchange_one_int16;
|
||||||
|
else
|
||||||
|
return exchange_int16s;
|
||||||
|
default:
|
||||||
|
if (size == 1)
|
||||||
|
return exchange_one_byte;
|
||||||
|
else
|
||||||
|
return exchange_bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void heapsortx(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
|
||||||
|
{
|
||||||
|
uint8_t *basep = (uint8_t *)base;
|
||||||
|
size_t i, n, c, r;
|
||||||
|
exchange_f swap = exchange_func(base, size);
|
||||||
|
|
||||||
|
if (nmemb > 1) {
|
||||||
|
i = (nmemb / 2) * size;
|
||||||
|
n = nmemb * size;
|
||||||
|
|
||||||
|
while (i > 0) {
|
||||||
|
i -= size;
|
||||||
|
for (r = i; (c = r * 2 + size) < n; r = c) {
|
||||||
|
if (c < n - size && cmp(basep + c, basep + c + size, opaque) <= 0)
|
||||||
|
c += size;
|
||||||
|
if (cmp(basep + r, basep + c, opaque) > 0)
|
||||||
|
break;
|
||||||
|
swap(basep + r, basep + c, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = n - size; i > 0; i -= size) {
|
||||||
|
swap(basep, basep + i, size);
|
||||||
|
|
||||||
|
for (r = 0; (c = r * 2 + size) < i; r = c) {
|
||||||
|
if (c < i - size && cmp(basep + c, basep + c + size, opaque) <= 0)
|
||||||
|
c += size;
|
||||||
|
if (cmp(basep + r, basep + c, opaque) > 0)
|
||||||
|
break;
|
||||||
|
swap(basep + r, basep + c, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void *med3(void *a, void *b, void *c, cmp_f cmp, void *opaque)
|
||||||
|
{
|
||||||
|
return cmp(a, b, opaque) < 0 ?
|
||||||
|
(cmp(b, c, opaque) < 0 ? b : (cmp(a, c, opaque) < 0 ? c : a )) :
|
||||||
|
(cmp(b, c, opaque) > 0 ? b : (cmp(a, c, opaque) < 0 ? a : c ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* pointer based version with local stack and insertion sort threshhold */
|
||||||
|
void rqsort(void *base, size_t nmemb, size_t size, cmp_f cmp, void *opaque)
|
||||||
|
{
|
||||||
|
struct { uint8_t *base; size_t count; int depth; } stack[50], *sp = stack;
|
||||||
|
uint8_t *ptr, *pi, *pj, *plt, *pgt, *top, *m;
|
||||||
|
size_t m4, i, lt, gt, span, span2;
|
||||||
|
int c, depth;
|
||||||
|
exchange_f swap = exchange_func(base, size);
|
||||||
|
exchange_f swap_block = exchange_func(base, size | 128);
|
||||||
|
|
||||||
|
if (nmemb < 2 || size <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sp->base = (uint8_t *)base;
|
||||||
|
sp->count = nmemb;
|
||||||
|
sp->depth = 0;
|
||||||
|
sp++;
|
||||||
|
|
||||||
|
while (sp > stack) {
|
||||||
|
sp--;
|
||||||
|
ptr = sp->base;
|
||||||
|
nmemb = sp->count;
|
||||||
|
depth = sp->depth;
|
||||||
|
|
||||||
|
while (nmemb > 6) {
|
||||||
|
if (++depth > 50) {
|
||||||
|
/* depth check to ensure worst case logarithmic time */
|
||||||
|
heapsortx(ptr, nmemb, size, cmp, opaque);
|
||||||
|
nmemb = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* select median of 3 from 1/4, 1/2, 3/4 positions */
|
||||||
|
/* should use median of 5 or 9? */
|
||||||
|
m4 = (nmemb >> 2) * size;
|
||||||
|
m = med3(ptr + m4, ptr + 2 * m4, ptr + 3 * m4, cmp, opaque);
|
||||||
|
swap(ptr, m, size); /* move the pivot to the start or the array */
|
||||||
|
i = lt = 1;
|
||||||
|
pi = plt = ptr + size;
|
||||||
|
gt = nmemb;
|
||||||
|
pj = pgt = top = ptr + nmemb * size;
|
||||||
|
for (;;) {
|
||||||
|
while (pi < pj && (c = cmp(ptr, pi, opaque)) >= 0) {
|
||||||
|
if (c == 0) {
|
||||||
|
swap(plt, pi, size);
|
||||||
|
lt++;
|
||||||
|
plt += size;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
pi += size;
|
||||||
|
}
|
||||||
|
while (pi < (pj -= size) && (c = cmp(ptr, pj, opaque)) <= 0) {
|
||||||
|
if (c == 0) {
|
||||||
|
gt--;
|
||||||
|
pgt -= size;
|
||||||
|
swap(pgt, pj, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pi >= pj)
|
||||||
|
break;
|
||||||
|
swap(pi, pj, size);
|
||||||
|
i++;
|
||||||
|
pi += size;
|
||||||
|
}
|
||||||
|
/* array has 4 parts:
|
||||||
|
* from 0 to lt excluded: elements identical to pivot
|
||||||
|
* from lt to pi excluded: elements smaller than pivot
|
||||||
|
* from pi to gt excluded: elements greater than pivot
|
||||||
|
* from gt to n excluded: elements identical to pivot
|
||||||
|
*/
|
||||||
|
/* move elements identical to pivot in the middle of the array: */
|
||||||
|
/* swap values in ranges [0..lt[ and [i-lt..i[
|
||||||
|
swapping the smallest span between lt and i-lt is sufficient
|
||||||
|
*/
|
||||||
|
span = plt - ptr;
|
||||||
|
span2 = pi - plt;
|
||||||
|
lt = i - lt;
|
||||||
|
if (span > span2)
|
||||||
|
span = span2;
|
||||||
|
swap_block(ptr, pi - span, span);
|
||||||
|
/* swap values in ranges [gt..top[ and [i..top-(top-gt)[
|
||||||
|
swapping the smallest span between top-gt and gt-i is sufficient
|
||||||
|
*/
|
||||||
|
span = top - pgt;
|
||||||
|
span2 = pgt - pi;
|
||||||
|
pgt = top - span2;
|
||||||
|
gt = nmemb - (gt - i);
|
||||||
|
if (span > span2)
|
||||||
|
span = span2;
|
||||||
|
swap_block(pi, top - span, span);
|
||||||
|
|
||||||
|
/* now array has 3 parts:
|
||||||
|
* from 0 to lt excluded: elements smaller than pivot
|
||||||
|
* from lt to gt excluded: elements identical to pivot
|
||||||
|
* from gt to n excluded: elements greater than pivot
|
||||||
|
*/
|
||||||
|
/* stack the larger segment and keep processing the smaller one
|
||||||
|
to minimize stack use for pathological distributions */
|
||||||
|
if (lt > nmemb - gt) {
|
||||||
|
sp->base = ptr;
|
||||||
|
sp->count = lt;
|
||||||
|
sp->depth = depth;
|
||||||
|
sp++;
|
||||||
|
ptr = pgt;
|
||||||
|
nmemb -= gt;
|
||||||
|
} else {
|
||||||
|
sp->base = pgt;
|
||||||
|
sp->count = nmemb - gt;
|
||||||
|
sp->depth = depth;
|
||||||
|
sp++;
|
||||||
|
nmemb = lt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Use insertion sort for small fragments */
|
||||||
|
for (pi = ptr + size, top = ptr + nmemb * size; pi < top; pi += size) {
|
||||||
|
for (pj = pi; pj > ptr && cmp(pj - size, pj, opaque) > 0; pj -= size)
|
||||||
|
swap(pj, pj - size, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
354
cxx/quickjs/cutils.h
Normal file
354
cxx/quickjs/cutils.h
Normal file
@@ -0,0 +1,354 @@
|
|||||||
|
/*
|
||||||
|
* C utilities
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017 Fabrice Bellard
|
||||||
|
* Copyright (c) 2018 Charlie Gordon
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef CUTILS_H
|
||||||
|
#define CUTILS_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <intrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* set if CPU is big endian */
|
||||||
|
#undef WORDS_BIGENDIAN
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define likely(x) (x)
|
||||||
|
#define unlikely(x) (x)
|
||||||
|
#define force_inline __forceinline
|
||||||
|
#define no_inline __declspec(noinline)
|
||||||
|
#define __maybe_unused
|
||||||
|
#else
|
||||||
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
#define force_inline inline __attribute__((always_inline))
|
||||||
|
#define no_inline __attribute__((noinline))
|
||||||
|
#define __maybe_unused __attribute__((unused))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define xglue(x, y) x ## y
|
||||||
|
#define glue(x, y) xglue(x, y)
|
||||||
|
#define stringify(s) tostring(s)
|
||||||
|
#define tostring(s) #s
|
||||||
|
|
||||||
|
#ifndef offsetof
|
||||||
|
#define offsetof(type, field) ((size_t) &((type *)0)->field)
|
||||||
|
#endif
|
||||||
|
#ifndef countof
|
||||||
|
#define countof(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int BOOL;
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
enum {
|
||||||
|
FALSE = 0,
|
||||||
|
TRUE = 1,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void pstrcpy(char *buf, int buf_size, const char *str);
|
||||||
|
char *pstrcat(char *buf, int buf_size, const char *s);
|
||||||
|
int strstart(const char *str, const char *val, const char **ptr);
|
||||||
|
int has_suffix(const char *str, const char *suffix);
|
||||||
|
|
||||||
|
static inline int max_int(int a, int b)
|
||||||
|
{
|
||||||
|
if (a > b)
|
||||||
|
return a;
|
||||||
|
else
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int min_int(int a, int b)
|
||||||
|
{
|
||||||
|
if (a < b)
|
||||||
|
return a;
|
||||||
|
else
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t max_uint32(uint32_t a, uint32_t b)
|
||||||
|
{
|
||||||
|
if (a > b)
|
||||||
|
return a;
|
||||||
|
else
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t min_uint32(uint32_t a, uint32_t b)
|
||||||
|
{
|
||||||
|
if (a < b)
|
||||||
|
return a;
|
||||||
|
else
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int64_t max_int64(int64_t a, int64_t b)
|
||||||
|
{
|
||||||
|
if (a > b)
|
||||||
|
return a;
|
||||||
|
else
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int64_t min_int64(int64_t a, int64_t b)
|
||||||
|
{
|
||||||
|
if (a < b)
|
||||||
|
return a;
|
||||||
|
else
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WARNING: undefined if a = 0 */
|
||||||
|
static inline int clz32(unsigned int a)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
unsigned long idx;
|
||||||
|
_BitScanReverse(&idx, a);
|
||||||
|
return 31 ^ idx;
|
||||||
|
#else
|
||||||
|
return __builtin_clz(a);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WARNING: undefined if a = 0 */
|
||||||
|
static inline int clz64(uint64_t a)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
unsigned long idx;
|
||||||
|
_BitScanReverse64(&idx, a);
|
||||||
|
return 63 ^ idx;
|
||||||
|
#else
|
||||||
|
return __builtin_clzll(a);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WARNING: undefined if a = 0 */
|
||||||
|
static inline int ctz32(unsigned int a)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
unsigned long idx;
|
||||||
|
_BitScanForward(&idx, a);
|
||||||
|
return 31 ^ idx;
|
||||||
|
#else
|
||||||
|
return __builtin_ctz(a);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* WARNING: undefined if a = 0 */
|
||||||
|
static inline int ctz64(uint64_t a)
|
||||||
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
unsigned long idx;
|
||||||
|
_BitScanForward64(&idx, a);
|
||||||
|
return 63 ^ idx;
|
||||||
|
#else
|
||||||
|
return __builtin_ctzll(a);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct packed_u64 {
|
||||||
|
uint64_t v;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct packed_u32 {
|
||||||
|
uint32_t v;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct packed_u16 {
|
||||||
|
uint16_t v;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
#else
|
||||||
|
struct __attribute__((packed)) packed_u64 {
|
||||||
|
uint64_t v;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct __attribute__((packed)) packed_u32 {
|
||||||
|
uint32_t v;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct __attribute__((packed)) packed_u16 {
|
||||||
|
uint16_t v;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static inline uint64_t get_u64(const uint8_t *tab)
|
||||||
|
{
|
||||||
|
return ((const struct packed_u64 *)tab)->v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int64_t get_i64(const uint8_t *tab)
|
||||||
|
{
|
||||||
|
return (int64_t)((const struct packed_u64 *)tab)->v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void put_u64(uint8_t *tab, uint64_t val)
|
||||||
|
{
|
||||||
|
((struct packed_u64 *)tab)->v = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t get_u32(const uint8_t *tab)
|
||||||
|
{
|
||||||
|
return ((const struct packed_u32 *)tab)->v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int32_t get_i32(const uint8_t *tab)
|
||||||
|
{
|
||||||
|
return (int32_t)((const struct packed_u32 *)tab)->v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void put_u32(uint8_t *tab, uint32_t val)
|
||||||
|
{
|
||||||
|
((struct packed_u32 *)tab)->v = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t get_u16(const uint8_t *tab)
|
||||||
|
{
|
||||||
|
return ((const struct packed_u16 *)tab)->v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int32_t get_i16(const uint8_t *tab)
|
||||||
|
{
|
||||||
|
return (int16_t)((const struct packed_u16 *)tab)->v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void put_u16(uint8_t *tab, uint16_t val)
|
||||||
|
{
|
||||||
|
((struct packed_u16 *)tab)->v = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t get_u8(const uint8_t *tab)
|
||||||
|
{
|
||||||
|
return *tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int32_t get_i8(const uint8_t *tab)
|
||||||
|
{
|
||||||
|
return (int8_t)*tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void put_u8(uint8_t *tab, uint8_t val)
|
||||||
|
{
|
||||||
|
*tab = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint16_t bswap16(uint16_t x)
|
||||||
|
{
|
||||||
|
return (x >> 8) | (x << 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t bswap32(uint32_t v)
|
||||||
|
{
|
||||||
|
return ((v & 0xff000000) >> 24) | ((v & 0x00ff0000) >> 8) |
|
||||||
|
((v & 0x0000ff00) << 8) | ((v & 0x000000ff) << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint64_t bswap64(uint64_t v)
|
||||||
|
{
|
||||||
|
return ((v & ((uint64_t)0xff << (7 * 8))) >> (7 * 8)) |
|
||||||
|
((v & ((uint64_t)0xff << (6 * 8))) >> (5 * 8)) |
|
||||||
|
((v & ((uint64_t)0xff << (5 * 8))) >> (3 * 8)) |
|
||||||
|
((v & ((uint64_t)0xff << (4 * 8))) >> (1 * 8)) |
|
||||||
|
((v & ((uint64_t)0xff << (3 * 8))) << (1 * 8)) |
|
||||||
|
((v & ((uint64_t)0xff << (2 * 8))) << (3 * 8)) |
|
||||||
|
((v & ((uint64_t)0xff << (1 * 8))) << (5 * 8)) |
|
||||||
|
((v & ((uint64_t)0xff << (0 * 8))) << (7 * 8));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* XXX: should take an extra argument to pass slack information to the caller */
|
||||||
|
typedef void *DynBufReallocFunc(void *opaque, void *ptr, size_t size);
|
||||||
|
|
||||||
|
typedef struct DynBuf {
|
||||||
|
uint8_t *buf;
|
||||||
|
size_t size;
|
||||||
|
size_t allocated_size;
|
||||||
|
BOOL error; /* true if a memory allocation error occurred */
|
||||||
|
DynBufReallocFunc *realloc_func;
|
||||||
|
void *opaque; /* for realloc_func */
|
||||||
|
} DynBuf;
|
||||||
|
|
||||||
|
void dbuf_init(DynBuf *s);
|
||||||
|
void dbuf_init2(DynBuf *s, void *opaque, DynBufReallocFunc *realloc_func);
|
||||||
|
int dbuf_realloc(DynBuf *s, size_t new_size);
|
||||||
|
int dbuf_write(DynBuf *s, size_t offset, const uint8_t *data, size_t len);
|
||||||
|
int dbuf_put(DynBuf *s, const uint8_t *data, size_t len);
|
||||||
|
int dbuf_put_self(DynBuf *s, size_t offset, size_t len);
|
||||||
|
int dbuf_putc(DynBuf *s, uint8_t c);
|
||||||
|
int dbuf_putstr(DynBuf *s, const char *str);
|
||||||
|
static inline int dbuf_put_u16(DynBuf *s, uint16_t val)
|
||||||
|
{
|
||||||
|
return dbuf_put(s, (uint8_t *)&val, 2);
|
||||||
|
}
|
||||||
|
static inline int dbuf_put_u32(DynBuf *s, uint32_t val)
|
||||||
|
{
|
||||||
|
return dbuf_put(s, (uint8_t *)&val, 4);
|
||||||
|
}
|
||||||
|
static inline int dbuf_put_u64(DynBuf *s, uint64_t val)
|
||||||
|
{
|
||||||
|
return dbuf_put(s, (uint8_t *)&val, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
#ifndef _MSC_VER
|
||||||
|
__attribute__((format(printf, 2, 3)))
|
||||||
|
#endif
|
||||||
|
dbuf_printf(DynBuf *s, const char *fmt, ...);
|
||||||
|
|
||||||
|
void dbuf_free(DynBuf *s);
|
||||||
|
static inline BOOL dbuf_error(DynBuf *s) {
|
||||||
|
return s->error;
|
||||||
|
}
|
||||||
|
static inline void dbuf_set_error(DynBuf *s)
|
||||||
|
{
|
||||||
|
s->error = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define UTF8_CHAR_LEN_MAX 6
|
||||||
|
|
||||||
|
int unicode_to_utf8(uint8_t *buf, unsigned int c);
|
||||||
|
int unicode_from_utf8(const uint8_t *p, int max_len, const uint8_t **pp);
|
||||||
|
|
||||||
|
static inline int from_hex(int c)
|
||||||
|
{
|
||||||
|
if (c >= '0' && c <= '9')
|
||||||
|
return c - '0';
|
||||||
|
else if (c >= 'A' && c <= 'F')
|
||||||
|
return c - 'A' + 10;
|
||||||
|
else if (c >= 'a' && c <= 'f')
|
||||||
|
return c - 'a' + 10;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rqsort(void *base, size_t nmemb, size_t size,
|
||||||
|
int (*cmp)(const void *, const void *, void *),
|
||||||
|
void *arg);
|
||||||
|
|
||||||
|
#endif /* CUTILS_H */
|
58
cxx/quickjs/libregexp-opcode.h
Normal file
58
cxx/quickjs/libregexp-opcode.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Regular Expression Engine
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017-2018 Fabrice Bellard
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef DEF
|
||||||
|
|
||||||
|
DEF(invalid, 1) /* never used */
|
||||||
|
DEF(char, 3)
|
||||||
|
DEF(char32, 5)
|
||||||
|
DEF(dot, 1)
|
||||||
|
DEF(any, 1) /* same as dot but match any character including line terminator */
|
||||||
|
DEF(line_start, 1)
|
||||||
|
DEF(line_end, 1)
|
||||||
|
DEF(goto, 5)
|
||||||
|
DEF(split_goto_first, 5)
|
||||||
|
DEF(split_next_first, 5)
|
||||||
|
DEF(match, 1)
|
||||||
|
DEF(save_start, 2) /* save start position */
|
||||||
|
DEF(save_end, 2) /* save end position, must come after saved_start */
|
||||||
|
DEF(save_reset, 3) /* reset save positions */
|
||||||
|
DEF(loop, 5) /* decrement the top the stack and goto if != 0 */
|
||||||
|
DEF(push_i32, 5) /* push integer on the stack */
|
||||||
|
DEF(drop, 1)
|
||||||
|
DEF(word_boundary, 1)
|
||||||
|
DEF(not_word_boundary, 1)
|
||||||
|
DEF(back_reference, 2)
|
||||||
|
DEF(backward_back_reference, 2) /* must come after back_reference */
|
||||||
|
DEF(range, 3) /* variable length */
|
||||||
|
DEF(range32, 3) /* variable length */
|
||||||
|
DEF(lookahead, 5)
|
||||||
|
DEF(negative_lookahead, 5)
|
||||||
|
DEF(push_char_pos, 1) /* push the character position on the stack */
|
||||||
|
DEF(bne_char_pos, 5) /* pop one stack element and jump if equal to the character
|
||||||
|
position */
|
||||||
|
DEF(prev, 1) /* go to the previous char */
|
||||||
|
DEF(simple_greedy_quant, 17)
|
||||||
|
|
||||||
|
#endif /* DEF */
|
2607
cxx/quickjs/libregexp.c
Normal file
2607
cxx/quickjs/libregexp.c
Normal file
File diff suppressed because it is too large
Load Diff
91
cxx/quickjs/libregexp.h
Normal file
91
cxx/quickjs/libregexp.h
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* Regular Expression Engine
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017-2018 Fabrice Bellard
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef LIBREGEXP_H
|
||||||
|
#define LIBREGEXP_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#include "libunicode.h"
|
||||||
|
|
||||||
|
#define LRE_BOOL int /* for documentation purposes */
|
||||||
|
|
||||||
|
#define LRE_FLAG_GLOBAL (1 << 0)
|
||||||
|
#define LRE_FLAG_IGNORECASE (1 << 1)
|
||||||
|
#define LRE_FLAG_MULTILINE (1 << 2)
|
||||||
|
#define LRE_FLAG_DOTALL (1 << 3)
|
||||||
|
#define LRE_FLAG_UTF16 (1 << 4)
|
||||||
|
#define LRE_FLAG_STICKY (1 << 5)
|
||||||
|
|
||||||
|
#define LRE_FLAG_NAMED_GROUPS (1 << 7) /* named groups are present in the regexp */
|
||||||
|
|
||||||
|
uint8_t *lre_compile(int *plen, char *error_msg, int error_msg_size,
|
||||||
|
const char *buf, size_t buf_len, int re_flags,
|
||||||
|
void *opaque);
|
||||||
|
int lre_get_capture_count(const uint8_t *bc_buf);
|
||||||
|
int lre_get_flags(const uint8_t *bc_buf);
|
||||||
|
int lre_exec(uint8_t **capture,
|
||||||
|
const uint8_t *bc_buf, const uint8_t *cbuf, int cindex, int clen,
|
||||||
|
int cbuf_type, void *opaque);
|
||||||
|
|
||||||
|
int lre_parse_escape(const uint8_t **pp, int allow_utf16);
|
||||||
|
LRE_BOOL lre_is_space(int c);
|
||||||
|
|
||||||
|
/* must be provided by the user */
|
||||||
|
LRE_BOOL lre_check_stack_overflow(void *opaque, size_t alloca_size);
|
||||||
|
void *lre_realloc(void *opaque, void *ptr, size_t size);
|
||||||
|
|
||||||
|
/* JS identifier test */
|
||||||
|
extern uint32_t const lre_id_start_table_ascii[4];
|
||||||
|
extern uint32_t const lre_id_continue_table_ascii[4];
|
||||||
|
|
||||||
|
static inline int lre_js_is_ident_first(int c)
|
||||||
|
{
|
||||||
|
if ((uint32_t)c < 128) {
|
||||||
|
return (lre_id_start_table_ascii[c >> 5] >> (c & 31)) & 1;
|
||||||
|
} else {
|
||||||
|
#ifdef CONFIG_ALL_UNICODE
|
||||||
|
return lre_is_id_start(c);
|
||||||
|
#else
|
||||||
|
return !lre_is_space(c);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int lre_js_is_ident_next(int c)
|
||||||
|
{
|
||||||
|
if ((uint32_t)c < 128) {
|
||||||
|
return (lre_id_continue_table_ascii[c >> 5] >> (c & 31)) & 1;
|
||||||
|
} else {
|
||||||
|
/* ZWNJ and ZWJ are accepted in identifiers */
|
||||||
|
#ifdef CONFIG_ALL_UNICODE
|
||||||
|
return lre_is_id_continue(c) || c == 0x200C || c == 0x200D;
|
||||||
|
#else
|
||||||
|
return !lre_is_space(c) || c == 0x200C || c == 0x200D;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef LRE_BOOL
|
||||||
|
|
||||||
|
#endif /* LIBREGEXP_H */
|
4368
cxx/quickjs/libunicode-table.h
Normal file
4368
cxx/quickjs/libunicode-table.h
Normal file
File diff suppressed because it is too large
Load Diff
1556
cxx/quickjs/libunicode.c
Normal file
1556
cxx/quickjs/libunicode.c
Normal file
File diff suppressed because it is too large
Load Diff
124
cxx/quickjs/libunicode.h
Normal file
124
cxx/quickjs/libunicode.h
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Unicode utilities
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017-2018 Fabrice Bellard
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef LIBUNICODE_H
|
||||||
|
#define LIBUNICODE_H
|
||||||
|
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#define LRE_BOOL int /* for documentation purposes */
|
||||||
|
|
||||||
|
/* define it to include all the unicode tables (40KB larger) */
|
||||||
|
#define CONFIG_ALL_UNICODE
|
||||||
|
|
||||||
|
#define LRE_CC_RES_LEN_MAX 3
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
UNICODE_NFC,
|
||||||
|
UNICODE_NFD,
|
||||||
|
UNICODE_NFKC,
|
||||||
|
UNICODE_NFKD,
|
||||||
|
} UnicodeNormalizationEnum;
|
||||||
|
|
||||||
|
int lre_case_conv(uint32_t *res, uint32_t c, int conv_type);
|
||||||
|
LRE_BOOL lre_is_cased(uint32_t c);
|
||||||
|
LRE_BOOL lre_is_case_ignorable(uint32_t c);
|
||||||
|
|
||||||
|
/* char ranges */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int len; /* in points, always even */
|
||||||
|
int size;
|
||||||
|
uint32_t *points; /* points sorted by increasing value */
|
||||||
|
void *mem_opaque;
|
||||||
|
void *(*realloc_func)(void *opaque, void *ptr, size_t size);
|
||||||
|
} CharRange;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CR_OP_UNION,
|
||||||
|
CR_OP_INTER,
|
||||||
|
CR_OP_XOR,
|
||||||
|
} CharRangeOpEnum;
|
||||||
|
|
||||||
|
void cr_init(CharRange *cr, void *mem_opaque, void *(*realloc_func)(void *opaque, void *ptr, size_t size));
|
||||||
|
void cr_free(CharRange *cr);
|
||||||
|
int cr_realloc(CharRange *cr, int size);
|
||||||
|
int cr_copy(CharRange *cr, const CharRange *cr1);
|
||||||
|
|
||||||
|
static inline int cr_add_point(CharRange *cr, uint32_t v)
|
||||||
|
{
|
||||||
|
if (cr->len >= cr->size) {
|
||||||
|
if (cr_realloc(cr, cr->len + 1))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
cr->points[cr->len++] = v;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int cr_add_interval(CharRange *cr, uint32_t c1, uint32_t c2)
|
||||||
|
{
|
||||||
|
if ((cr->len + 2) > cr->size) {
|
||||||
|
if (cr_realloc(cr, cr->len + 2))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
cr->points[cr->len++] = c1;
|
||||||
|
cr->points[cr->len++] = c2;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cr_union1(CharRange *cr, const uint32_t *b_pt, int b_len);
|
||||||
|
|
||||||
|
static inline int cr_union_interval(CharRange *cr, uint32_t c1, uint32_t c2)
|
||||||
|
{
|
||||||
|
uint32_t b_pt[2];
|
||||||
|
b_pt[0] = c1;
|
||||||
|
b_pt[1] = c2 + 1;
|
||||||
|
return cr_union1(cr, b_pt, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int cr_op(CharRange *cr, const uint32_t *a_pt, int a_len,
|
||||||
|
const uint32_t *b_pt, int b_len, int op);
|
||||||
|
|
||||||
|
int cr_invert(CharRange *cr);
|
||||||
|
|
||||||
|
#ifdef CONFIG_ALL_UNICODE
|
||||||
|
|
||||||
|
LRE_BOOL lre_is_id_start(uint32_t c);
|
||||||
|
LRE_BOOL lre_is_id_continue(uint32_t c);
|
||||||
|
|
||||||
|
int unicode_normalize(uint32_t **pdst, const uint32_t *src, int src_len,
|
||||||
|
UnicodeNormalizationEnum n_type,
|
||||||
|
void *opaque, void *(*realloc_func)(void *opaque, void *ptr, size_t size));
|
||||||
|
|
||||||
|
/* Unicode character range functions */
|
||||||
|
|
||||||
|
int unicode_script(CharRange *cr,
|
||||||
|
const char *script_name, LRE_BOOL is_ext);
|
||||||
|
int unicode_general_category(CharRange *cr, const char *gc_name);
|
||||||
|
int unicode_prop(CharRange *cr, const char *prop_name);
|
||||||
|
|
||||||
|
#endif /* CONFIG_ALL_UNICODE */
|
||||||
|
|
||||||
|
#undef LRE_BOOL
|
||||||
|
|
||||||
|
#endif /* LIBUNICODE_H */
|
100
cxx/quickjs/list.h
Normal file
100
cxx/quickjs/list.h
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/*
|
||||||
|
* Linux klist like system
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016-2017 Fabrice Bellard
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef LIST_H
|
||||||
|
#define LIST_H
|
||||||
|
|
||||||
|
#ifndef NULL
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct list_head {
|
||||||
|
struct list_head *prev;
|
||||||
|
struct list_head *next;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LIST_HEAD_INIT(el) { &(el), &(el) }
|
||||||
|
|
||||||
|
/* return the pointer of type 'type *' containing 'el' as field 'member' */
|
||||||
|
#define list_entry(el, type, member) \
|
||||||
|
((type *)((uint8_t *)(el) - offsetof(type, member)))
|
||||||
|
|
||||||
|
static inline void init_list_head(struct list_head *head)
|
||||||
|
{
|
||||||
|
head->prev = head;
|
||||||
|
head->next = head;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* insert 'el' between 'prev' and 'next' */
|
||||||
|
static inline void __list_add(struct list_head *el,
|
||||||
|
struct list_head *prev, struct list_head *next)
|
||||||
|
{
|
||||||
|
prev->next = el;
|
||||||
|
el->prev = prev;
|
||||||
|
el->next = next;
|
||||||
|
next->prev = el;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add 'el' at the head of the list 'head' (= after element head) */
|
||||||
|
static inline void list_add(struct list_head *el, struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_add(el, head, head->next);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* add 'el' at the end of the list 'head' (= before element head) */
|
||||||
|
static inline void list_add_tail(struct list_head *el, struct list_head *head)
|
||||||
|
{
|
||||||
|
__list_add(el, head->prev, head);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void list_del(struct list_head *el)
|
||||||
|
{
|
||||||
|
struct list_head *prev, *next;
|
||||||
|
prev = el->prev;
|
||||||
|
next = el->next;
|
||||||
|
prev->next = next;
|
||||||
|
next->prev = prev;
|
||||||
|
el->prev = NULL; /* fail safe */
|
||||||
|
el->next = NULL; /* fail safe */
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int list_empty(struct list_head *el)
|
||||||
|
{
|
||||||
|
return el->next == el;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define list_for_each(el, head) \
|
||||||
|
for(el = (head)->next; el != (head); el = el->next)
|
||||||
|
|
||||||
|
#define list_for_each_safe(el, el1, head) \
|
||||||
|
for(el = (head)->next, el1 = el->next; el != (head); \
|
||||||
|
el = el1, el1 = el->next)
|
||||||
|
|
||||||
|
#define list_for_each_prev(el, head) \
|
||||||
|
for(el = (head)->prev; el != (head); el = el->prev)
|
||||||
|
|
||||||
|
#define list_for_each_prev_safe(el, el1, head) \
|
||||||
|
for(el = (head)->prev, el1 = el->prev; el != (head); \
|
||||||
|
el = el1, el1 = el->prev)
|
||||||
|
|
||||||
|
#endif /* LIST_H */
|
272
cxx/quickjs/quickjs-atom.h
Normal file
272
cxx/quickjs/quickjs-atom.h
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
/*
|
||||||
|
* QuickJS atom definitions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017-2018 Fabrice Bellard
|
||||||
|
* Copyright (c) 2017-2018 Charlie Gordon
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef DEF
|
||||||
|
|
||||||
|
/* Note: first atoms are considered as keywords in the parser */
|
||||||
|
DEF(null, "null") /* must be first */
|
||||||
|
DEF(false, "false")
|
||||||
|
DEF(true, "true")
|
||||||
|
DEF(if, "if")
|
||||||
|
DEF(else, "else")
|
||||||
|
DEF(return, "return")
|
||||||
|
DEF(var, "var")
|
||||||
|
DEF(this, "this")
|
||||||
|
DEF(delete, "delete")
|
||||||
|
DEF(void, "void")
|
||||||
|
DEF(typeof, "typeof")
|
||||||
|
DEF(new, "new")
|
||||||
|
DEF(in, "in")
|
||||||
|
DEF(instanceof, "instanceof")
|
||||||
|
DEF(do, "do")
|
||||||
|
DEF(while, "while")
|
||||||
|
DEF(for, "for")
|
||||||
|
DEF(break, "break")
|
||||||
|
DEF(continue, "continue")
|
||||||
|
DEF(switch, "switch")
|
||||||
|
DEF(case, "case")
|
||||||
|
DEF(default, "default")
|
||||||
|
DEF(throw, "throw")
|
||||||
|
DEF(try, "try")
|
||||||
|
DEF(catch, "catch")
|
||||||
|
DEF(finally, "finally")
|
||||||
|
DEF(function, "function")
|
||||||
|
DEF(debugger, "debugger")
|
||||||
|
DEF(with, "with")
|
||||||
|
/* FutureReservedWord */
|
||||||
|
DEF(class, "class")
|
||||||
|
DEF(const, "const")
|
||||||
|
DEF(enum, "enum")
|
||||||
|
DEF(export, "export")
|
||||||
|
DEF(extends, "extends")
|
||||||
|
DEF(import, "import")
|
||||||
|
DEF(super, "super")
|
||||||
|
/* FutureReservedWords when parsing strict mode code */
|
||||||
|
DEF(implements, "implements")
|
||||||
|
DEF(interface, "interface")
|
||||||
|
DEF(let, "let")
|
||||||
|
DEF(package, "package")
|
||||||
|
DEF(private, "private")
|
||||||
|
DEF(protected, "protected")
|
||||||
|
DEF(public, "public")
|
||||||
|
DEF(static, "static")
|
||||||
|
DEF(yield, "yield")
|
||||||
|
DEF(await, "await")
|
||||||
|
|
||||||
|
/* empty string */
|
||||||
|
DEF(empty_string, "")
|
||||||
|
/* identifiers */
|
||||||
|
DEF(length, "length")
|
||||||
|
DEF(fileName, "fileName")
|
||||||
|
DEF(lineNumber, "lineNumber")
|
||||||
|
DEF(message, "message")
|
||||||
|
DEF(errors, "errors")
|
||||||
|
DEF(stack, "stack")
|
||||||
|
DEF(name, "name")
|
||||||
|
DEF(toString, "toString")
|
||||||
|
DEF(toLocaleString, "toLocaleString")
|
||||||
|
DEF(valueOf, "valueOf")
|
||||||
|
DEF(eval, "eval")
|
||||||
|
DEF(prototype, "prototype")
|
||||||
|
DEF(constructor, "constructor")
|
||||||
|
DEF(configurable, "configurable")
|
||||||
|
DEF(writable, "writable")
|
||||||
|
DEF(enumerable, "enumerable")
|
||||||
|
DEF(value, "value")
|
||||||
|
DEF(get, "get")
|
||||||
|
DEF(set, "set")
|
||||||
|
DEF(of, "of")
|
||||||
|
DEF(__proto__, "__proto__")
|
||||||
|
DEF(undefined, "undefined")
|
||||||
|
DEF(number, "number")
|
||||||
|
DEF(boolean, "boolean")
|
||||||
|
DEF(string, "string")
|
||||||
|
DEF(object, "object")
|
||||||
|
DEF(symbol, "symbol")
|
||||||
|
DEF(integer, "integer")
|
||||||
|
DEF(unknown, "unknown")
|
||||||
|
DEF(arguments, "arguments")
|
||||||
|
DEF(callee, "callee")
|
||||||
|
DEF(caller, "caller")
|
||||||
|
DEF(_eval_, "<eval>")
|
||||||
|
DEF(_ret_, "<ret>")
|
||||||
|
DEF(_var_, "<var>")
|
||||||
|
DEF(_with_, "<with>")
|
||||||
|
DEF(lastIndex, "lastIndex")
|
||||||
|
DEF(target, "target")
|
||||||
|
DEF(index, "index")
|
||||||
|
DEF(input, "input")
|
||||||
|
DEF(defineProperties, "defineProperties")
|
||||||
|
DEF(apply, "apply")
|
||||||
|
DEF(join, "join")
|
||||||
|
DEF(concat, "concat")
|
||||||
|
DEF(split, "split")
|
||||||
|
DEF(construct, "construct")
|
||||||
|
DEF(getPrototypeOf, "getPrototypeOf")
|
||||||
|
DEF(setPrototypeOf, "setPrototypeOf")
|
||||||
|
DEF(isExtensible, "isExtensible")
|
||||||
|
DEF(preventExtensions, "preventExtensions")
|
||||||
|
DEF(has, "has")
|
||||||
|
DEF(deleteProperty, "deleteProperty")
|
||||||
|
DEF(defineProperty, "defineProperty")
|
||||||
|
DEF(getOwnPropertyDescriptor, "getOwnPropertyDescriptor")
|
||||||
|
DEF(ownKeys, "ownKeys")
|
||||||
|
DEF(add, "add")
|
||||||
|
DEF(done, "done")
|
||||||
|
DEF(next, "next")
|
||||||
|
DEF(values, "values")
|
||||||
|
DEF(source, "source")
|
||||||
|
DEF(flags, "flags")
|
||||||
|
DEF(global, "global")
|
||||||
|
DEF(unicode, "unicode")
|
||||||
|
DEF(raw, "raw")
|
||||||
|
DEF(new_target, "new.target")
|
||||||
|
DEF(this_active_func, "this.active_func")
|
||||||
|
DEF(home_object, "<home_object>")
|
||||||
|
DEF(computed_field, "<computed_field>")
|
||||||
|
DEF(static_computed_field, "<static_computed_field>") /* must come after computed_fields */
|
||||||
|
DEF(class_fields_init, "<class_fields_init>")
|
||||||
|
DEF(brand, "<brand>")
|
||||||
|
DEF(hash_constructor, "#constructor")
|
||||||
|
DEF(as, "as")
|
||||||
|
DEF(from, "from")
|
||||||
|
DEF(meta, "meta")
|
||||||
|
DEF(_default_, "*default*")
|
||||||
|
DEF(_star_, "*")
|
||||||
|
DEF(Module, "Module")
|
||||||
|
DEF(then, "then")
|
||||||
|
DEF(resolve, "resolve")
|
||||||
|
DEF(reject, "reject")
|
||||||
|
DEF(promise, "promise")
|
||||||
|
DEF(proxy, "proxy")
|
||||||
|
DEF(revoke, "revoke")
|
||||||
|
DEF(async, "async")
|
||||||
|
DEF(exec, "exec")
|
||||||
|
DEF(groups, "groups")
|
||||||
|
DEF(status, "status")
|
||||||
|
DEF(reason, "reason")
|
||||||
|
DEF(globalThis, "globalThis")
|
||||||
|
#ifdef CONFIG_BIGNUM
|
||||||
|
DEF(bigint, "bigint")
|
||||||
|
DEF(bigfloat, "bigfloat")
|
||||||
|
DEF(bigdecimal, "bigdecimal")
|
||||||
|
DEF(roundingMode, "roundingMode")
|
||||||
|
DEF(maximumSignificantDigits, "maximumSignificantDigits")
|
||||||
|
DEF(maximumFractionDigits, "maximumFractionDigits")
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_ATOMICS
|
||||||
|
DEF(not_equal, "not-equal")
|
||||||
|
DEF(timed_out, "timed-out")
|
||||||
|
DEF(ok, "ok")
|
||||||
|
#endif
|
||||||
|
DEF(toJSON, "toJSON")
|
||||||
|
/* class names */
|
||||||
|
DEF(Object, "Object")
|
||||||
|
DEF(Array, "Array")
|
||||||
|
DEF(Error, "Error")
|
||||||
|
DEF(Number, "Number")
|
||||||
|
DEF(String, "String")
|
||||||
|
DEF(Boolean, "Boolean")
|
||||||
|
DEF(Symbol, "Symbol")
|
||||||
|
DEF(Arguments, "Arguments")
|
||||||
|
DEF(Math, "Math")
|
||||||
|
DEF(JSON, "JSON")
|
||||||
|
DEF(Date, "Date")
|
||||||
|
DEF(Function, "Function")
|
||||||
|
DEF(GeneratorFunction, "GeneratorFunction")
|
||||||
|
DEF(ForInIterator, "ForInIterator")
|
||||||
|
DEF(RegExp, "RegExp")
|
||||||
|
DEF(ArrayBuffer, "ArrayBuffer")
|
||||||
|
DEF(SharedArrayBuffer, "SharedArrayBuffer")
|
||||||
|
/* must keep same order as class IDs for typed arrays */
|
||||||
|
DEF(Uint8ClampedArray, "Uint8ClampedArray")
|
||||||
|
DEF(Int8Array, "Int8Array")
|
||||||
|
DEF(Uint8Array, "Uint8Array")
|
||||||
|
DEF(Int16Array, "Int16Array")
|
||||||
|
DEF(Uint16Array, "Uint16Array")
|
||||||
|
DEF(Int32Array, "Int32Array")
|
||||||
|
DEF(Uint32Array, "Uint32Array")
|
||||||
|
#ifdef CONFIG_BIGNUM
|
||||||
|
DEF(BigInt64Array, "BigInt64Array")
|
||||||
|
DEF(BigUint64Array, "BigUint64Array")
|
||||||
|
#endif
|
||||||
|
DEF(Float32Array, "Float32Array")
|
||||||
|
DEF(Float64Array, "Float64Array")
|
||||||
|
DEF(DataView, "DataView")
|
||||||
|
#ifdef CONFIG_BIGNUM
|
||||||
|
DEF(BigInt, "BigInt")
|
||||||
|
DEF(BigFloat, "BigFloat")
|
||||||
|
DEF(BigFloatEnv, "BigFloatEnv")
|
||||||
|
DEF(BigDecimal, "BigDecimal")
|
||||||
|
DEF(OperatorSet, "OperatorSet")
|
||||||
|
DEF(Operators, "Operators")
|
||||||
|
#endif
|
||||||
|
DEF(Map, "Map")
|
||||||
|
DEF(Set, "Set") /* Map + 1 */
|
||||||
|
DEF(WeakMap, "WeakMap") /* Map + 2 */
|
||||||
|
DEF(WeakSet, "WeakSet") /* Map + 3 */
|
||||||
|
DEF(Map_Iterator, "Map Iterator")
|
||||||
|
DEF(Set_Iterator, "Set Iterator")
|
||||||
|
DEF(Array_Iterator, "Array Iterator")
|
||||||
|
DEF(String_Iterator, "String Iterator")
|
||||||
|
DEF(RegExp_String_Iterator, "RegExp String Iterator")
|
||||||
|
DEF(Generator, "Generator")
|
||||||
|
DEF(Proxy, "Proxy")
|
||||||
|
DEF(Promise, "Promise")
|
||||||
|
DEF(PromiseResolveFunction, "PromiseResolveFunction")
|
||||||
|
DEF(PromiseRejectFunction, "PromiseRejectFunction")
|
||||||
|
DEF(AsyncFunction, "AsyncFunction")
|
||||||
|
DEF(AsyncFunctionResolve, "AsyncFunctionResolve")
|
||||||
|
DEF(AsyncFunctionReject, "AsyncFunctionReject")
|
||||||
|
DEF(AsyncGeneratorFunction, "AsyncGeneratorFunction")
|
||||||
|
DEF(AsyncGenerator, "AsyncGenerator")
|
||||||
|
DEF(EvalError, "EvalError")
|
||||||
|
DEF(RangeError, "RangeError")
|
||||||
|
DEF(ReferenceError, "ReferenceError")
|
||||||
|
DEF(SyntaxError, "SyntaxError")
|
||||||
|
DEF(TypeError, "TypeError")
|
||||||
|
DEF(URIError, "URIError")
|
||||||
|
DEF(InternalError, "InternalError")
|
||||||
|
/* private symbols */
|
||||||
|
DEF(Private_brand, "<brand>")
|
||||||
|
/* symbols */
|
||||||
|
DEF(Symbol_toPrimitive, "Symbol.toPrimitive")
|
||||||
|
DEF(Symbol_iterator, "Symbol.iterator")
|
||||||
|
DEF(Symbol_match, "Symbol.match")
|
||||||
|
DEF(Symbol_matchAll, "Symbol.matchAll")
|
||||||
|
DEF(Symbol_replace, "Symbol.replace")
|
||||||
|
DEF(Symbol_search, "Symbol.search")
|
||||||
|
DEF(Symbol_split, "Symbol.split")
|
||||||
|
DEF(Symbol_toStringTag, "Symbol.toStringTag")
|
||||||
|
DEF(Symbol_isConcatSpreadable, "Symbol.isConcatSpreadable")
|
||||||
|
DEF(Symbol_hasInstance, "Symbol.hasInstance")
|
||||||
|
DEF(Symbol_species, "Symbol.species")
|
||||||
|
DEF(Symbol_unscopables, "Symbol.unscopables")
|
||||||
|
DEF(Symbol_asyncIterator, "Symbol.asyncIterator")
|
||||||
|
#ifdef CONFIG_BIGNUM
|
||||||
|
DEF(Symbol_operatorSet, "Symbol.operatorSet")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* DEF */
|
367
cxx/quickjs/quickjs-opcode.h
Normal file
367
cxx/quickjs/quickjs-opcode.h
Normal file
@@ -0,0 +1,367 @@
|
|||||||
|
/*
|
||||||
|
* QuickJS opcode definitions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2017-2018 Fabrice Bellard
|
||||||
|
* Copyright (c) 2017-2018 Charlie Gordon
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef FMT
|
||||||
|
FMT(none)
|
||||||
|
FMT(none_int)
|
||||||
|
FMT(none_loc)
|
||||||
|
FMT(none_arg)
|
||||||
|
FMT(none_var_ref)
|
||||||
|
FMT(u8)
|
||||||
|
FMT(i8)
|
||||||
|
FMT(loc8)
|
||||||
|
FMT(const8)
|
||||||
|
FMT(label8)
|
||||||
|
FMT(u16)
|
||||||
|
FMT(i16)
|
||||||
|
FMT(label16)
|
||||||
|
FMT(npop)
|
||||||
|
FMT(npopx)
|
||||||
|
FMT(npop_u16)
|
||||||
|
FMT(loc)
|
||||||
|
FMT(arg)
|
||||||
|
FMT(var_ref)
|
||||||
|
FMT(u32)
|
||||||
|
FMT(i32)
|
||||||
|
FMT(const)
|
||||||
|
FMT(label)
|
||||||
|
FMT(atom)
|
||||||
|
FMT(atom_u8)
|
||||||
|
FMT(atom_u16)
|
||||||
|
FMT(atom_label_u8)
|
||||||
|
FMT(atom_label_u16)
|
||||||
|
FMT(label_u16)
|
||||||
|
#undef FMT
|
||||||
|
#endif /* FMT */
|
||||||
|
|
||||||
|
#ifdef DEF
|
||||||
|
|
||||||
|
#ifndef def
|
||||||
|
#define def(id, size, n_pop, n_push, f) DEF(id, size, n_pop, n_push, f)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DEF(invalid, 1, 0, 0, none) /* never emitted */
|
||||||
|
|
||||||
|
/* push values */
|
||||||
|
DEF( push_i32, 5, 0, 1, i32)
|
||||||
|
DEF( push_const, 5, 0, 1, const)
|
||||||
|
DEF( fclosure, 5, 0, 1, const) /* must follow push_const */
|
||||||
|
DEF(push_atom_value, 5, 0, 1, atom)
|
||||||
|
DEF( private_symbol, 5, 0, 1, atom)
|
||||||
|
DEF( undefined, 1, 0, 1, none)
|
||||||
|
DEF( null, 1, 0, 1, none)
|
||||||
|
DEF( push_this, 1, 0, 1, none) /* only used at the start of a function */
|
||||||
|
DEF( push_false, 1, 0, 1, none)
|
||||||
|
DEF( push_true, 1, 0, 1, none)
|
||||||
|
DEF( object, 1, 0, 1, none)
|
||||||
|
DEF( special_object, 2, 0, 1, u8) /* only used at the start of a function */
|
||||||
|
DEF( rest, 3, 0, 1, u16) /* only used at the start of a function */
|
||||||
|
|
||||||
|
DEF( drop, 1, 1, 0, none) /* a -> */
|
||||||
|
DEF( nip, 1, 2, 1, none) /* a b -> b */
|
||||||
|
DEF( nip1, 1, 3, 2, none) /* a b c -> b c */
|
||||||
|
DEF( dup, 1, 1, 2, none) /* a -> a a */
|
||||||
|
DEF( dup1, 1, 2, 3, none) /* a b -> a a b */
|
||||||
|
DEF( dup2, 1, 2, 4, none) /* a b -> a b a b */
|
||||||
|
DEF( dup3, 1, 3, 6, none) /* a b c -> a b c a b c */
|
||||||
|
DEF( insert2, 1, 2, 3, none) /* obj a -> a obj a (dup_x1) */
|
||||||
|
DEF( insert3, 1, 3, 4, none) /* obj prop a -> a obj prop a (dup_x2) */
|
||||||
|
DEF( insert4, 1, 4, 5, none) /* this obj prop a -> a this obj prop a */
|
||||||
|
DEF( perm3, 1, 3, 3, none) /* obj a b -> a obj b */
|
||||||
|
DEF( perm4, 1, 4, 4, none) /* obj prop a b -> a obj prop b */
|
||||||
|
DEF( perm5, 1, 5, 5, none) /* this obj prop a b -> a this obj prop b */
|
||||||
|
DEF( swap, 1, 2, 2, none) /* a b -> b a */
|
||||||
|
DEF( swap2, 1, 4, 4, none) /* a b c d -> c d a b */
|
||||||
|
DEF( rot3l, 1, 3, 3, none) /* x a b -> a b x */
|
||||||
|
DEF( rot3r, 1, 3, 3, none) /* a b x -> x a b */
|
||||||
|
DEF( rot4l, 1, 4, 4, none) /* x a b c -> a b c x */
|
||||||
|
DEF( rot5l, 1, 5, 5, none) /* x a b c d -> a b c d x */
|
||||||
|
|
||||||
|
DEF(call_constructor, 3, 2, 1, npop) /* func new.target args -> ret. arguments are not counted in n_pop */
|
||||||
|
DEF( call, 3, 1, 1, npop) /* arguments are not counted in n_pop */
|
||||||
|
DEF( tail_call, 3, 1, 0, npop) /* arguments are not counted in n_pop */
|
||||||
|
DEF( call_method, 3, 2, 1, npop) /* arguments are not counted in n_pop */
|
||||||
|
DEF(tail_call_method, 3, 2, 0, npop) /* arguments are not counted in n_pop */
|
||||||
|
DEF( array_from, 3, 0, 1, npop) /* arguments are not counted in n_pop */
|
||||||
|
DEF( apply, 3, 3, 1, u16)
|
||||||
|
DEF( return, 1, 1, 0, none)
|
||||||
|
DEF( return_undef, 1, 0, 0, none)
|
||||||
|
DEF(check_ctor_return, 1, 1, 2, none)
|
||||||
|
DEF( check_ctor, 1, 0, 0, none)
|
||||||
|
DEF( check_brand, 1, 2, 2, none) /* this_obj func -> this_obj func */
|
||||||
|
DEF( add_brand, 1, 2, 0, none) /* this_obj home_obj -> */
|
||||||
|
DEF( return_async, 1, 1, 0, none)
|
||||||
|
DEF( throw, 1, 1, 0, none)
|
||||||
|
DEF( throw_var, 6, 0, 0, atom_u8)
|
||||||
|
DEF( eval, 5, 1, 1, npop_u16) /* func args... -> ret_val */
|
||||||
|
DEF( apply_eval, 3, 2, 1, u16) /* func array -> ret_eval */
|
||||||
|
DEF( regexp, 1, 2, 1, none) /* create a RegExp object from the pattern and a
|
||||||
|
bytecode string */
|
||||||
|
DEF( get_super, 1, 1, 1, none)
|
||||||
|
DEF( import, 1, 1, 1, none) /* dynamic module import */
|
||||||
|
|
||||||
|
DEF( check_var, 5, 0, 1, atom) /* check if a variable exists */
|
||||||
|
DEF( get_var_undef, 5, 0, 1, atom) /* push undefined if the variable does not exist */
|
||||||
|
DEF( get_var, 5, 0, 1, atom) /* throw an exception if the variable does not exist */
|
||||||
|
DEF( put_var, 5, 1, 0, atom) /* must come after get_var */
|
||||||
|
DEF( put_var_init, 5, 1, 0, atom) /* must come after put_var. Used to initialize a global lexical variable */
|
||||||
|
DEF( put_var_strict, 5, 2, 0, atom) /* for strict mode variable write */
|
||||||
|
|
||||||
|
DEF( get_ref_value, 1, 2, 3, none)
|
||||||
|
DEF( put_ref_value, 1, 3, 0, none)
|
||||||
|
|
||||||
|
DEF( define_var, 6, 0, 0, atom_u8)
|
||||||
|
DEF(check_define_var, 6, 0, 0, atom_u8)
|
||||||
|
DEF( define_func, 6, 1, 0, atom_u8)
|
||||||
|
DEF( get_field, 5, 1, 1, atom)
|
||||||
|
DEF( get_field2, 5, 1, 2, atom)
|
||||||
|
DEF( put_field, 5, 2, 0, atom)
|
||||||
|
DEF( get_private_field, 1, 2, 1, none) /* obj prop -> value */
|
||||||
|
DEF( put_private_field, 1, 3, 0, none) /* obj value prop -> */
|
||||||
|
DEF(define_private_field, 1, 3, 1, none) /* obj prop value -> obj */
|
||||||
|
DEF( get_array_el, 1, 2, 1, none)
|
||||||
|
DEF( get_array_el2, 1, 2, 2, none) /* obj prop -> obj value */
|
||||||
|
DEF( put_array_el, 1, 3, 0, none)
|
||||||
|
DEF(get_super_value, 1, 3, 1, none) /* this obj prop -> value */
|
||||||
|
DEF(put_super_value, 1, 4, 0, none) /* this obj prop value -> */
|
||||||
|
DEF( define_field, 5, 2, 1, atom)
|
||||||
|
DEF( set_name, 5, 1, 1, atom)
|
||||||
|
DEF(set_name_computed, 1, 2, 2, none)
|
||||||
|
DEF( set_proto, 1, 2, 1, none)
|
||||||
|
DEF(set_home_object, 1, 2, 2, none)
|
||||||
|
DEF(define_array_el, 1, 3, 2, none)
|
||||||
|
DEF( append, 1, 3, 2, none) /* append enumerated object, update length */
|
||||||
|
DEF(copy_data_properties, 2, 3, 3, u8)
|
||||||
|
DEF( define_method, 6, 2, 1, atom_u8)
|
||||||
|
DEF(define_method_computed, 2, 3, 1, u8) /* must come after define_method */
|
||||||
|
DEF( define_class, 6, 2, 2, atom_u8) /* parent ctor -> ctor proto */
|
||||||
|
DEF( define_class_computed, 6, 3, 3, atom_u8) /* field_name parent ctor -> field_name ctor proto (class with computed name) */
|
||||||
|
|
||||||
|
DEF( get_loc, 3, 0, 1, loc)
|
||||||
|
DEF( put_loc, 3, 1, 0, loc) /* must come after get_loc */
|
||||||
|
DEF( set_loc, 3, 1, 1, loc) /* must come after put_loc */
|
||||||
|
DEF( get_arg, 3, 0, 1, arg)
|
||||||
|
DEF( put_arg, 3, 1, 0, arg) /* must come after get_arg */
|
||||||
|
DEF( set_arg, 3, 1, 1, arg) /* must come after put_arg */
|
||||||
|
DEF( get_var_ref, 3, 0, 1, var_ref)
|
||||||
|
DEF( put_var_ref, 3, 1, 0, var_ref) /* must come after get_var_ref */
|
||||||
|
DEF( set_var_ref, 3, 1, 1, var_ref) /* must come after put_var_ref */
|
||||||
|
DEF(set_loc_uninitialized, 3, 0, 0, loc)
|
||||||
|
DEF( get_loc_check, 3, 0, 1, loc)
|
||||||
|
DEF( put_loc_check, 3, 1, 0, loc) /* must come after get_loc_check */
|
||||||
|
DEF( put_loc_check_init, 3, 1, 0, loc)
|
||||||
|
DEF(get_var_ref_check, 3, 0, 1, var_ref)
|
||||||
|
DEF(put_var_ref_check, 3, 1, 0, var_ref) /* must come after get_var_ref_check */
|
||||||
|
DEF(put_var_ref_check_init, 3, 1, 0, var_ref)
|
||||||
|
DEF( close_loc, 3, 0, 0, loc)
|
||||||
|
DEF( if_false, 5, 1, 0, label)
|
||||||
|
DEF( if_true, 5, 1, 0, label) /* must come after if_false */
|
||||||
|
DEF( goto, 5, 0, 0, label) /* must come after if_true */
|
||||||
|
DEF( catch, 5, 0, 1, label)
|
||||||
|
DEF( gosub, 5, 0, 0, label) /* used to execute the finally block */
|
||||||
|
DEF( ret, 1, 1, 0, none) /* used to return from the finally block */
|
||||||
|
|
||||||
|
DEF( to_object, 1, 1, 1, none)
|
||||||
|
//DEF( to_string, 1, 1, 1, none)
|
||||||
|
DEF( to_propkey, 1, 1, 1, none)
|
||||||
|
DEF( to_propkey2, 1, 2, 2, none)
|
||||||
|
|
||||||
|
DEF( with_get_var, 10, 1, 0, atom_label_u8) /* must be in the same order as scope_xxx */
|
||||||
|
DEF( with_put_var, 10, 2, 1, atom_label_u8) /* must be in the same order as scope_xxx */
|
||||||
|
DEF(with_delete_var, 10, 1, 0, atom_label_u8) /* must be in the same order as scope_xxx */
|
||||||
|
DEF( with_make_ref, 10, 1, 0, atom_label_u8) /* must be in the same order as scope_xxx */
|
||||||
|
DEF( with_get_ref, 10, 1, 0, atom_label_u8) /* must be in the same order as scope_xxx */
|
||||||
|
DEF(with_get_ref_undef, 10, 1, 0, atom_label_u8)
|
||||||
|
|
||||||
|
DEF( make_loc_ref, 7, 0, 2, atom_u16)
|
||||||
|
DEF( make_arg_ref, 7, 0, 2, atom_u16)
|
||||||
|
DEF(make_var_ref_ref, 7, 0, 2, atom_u16)
|
||||||
|
DEF( make_var_ref, 5, 0, 2, atom)
|
||||||
|
|
||||||
|
DEF( for_in_start, 1, 1, 1, none)
|
||||||
|
DEF( for_of_start, 1, 1, 3, none)
|
||||||
|
DEF(for_await_of_start, 1, 1, 3, none)
|
||||||
|
DEF( for_in_next, 1, 1, 3, none)
|
||||||
|
DEF( for_of_next, 2, 3, 5, u8)
|
||||||
|
DEF(for_await_of_next, 1, 3, 4, none)
|
||||||
|
DEF(iterator_get_value_done, 1, 1, 2, none)
|
||||||
|
DEF( iterator_close, 1, 3, 0, none)
|
||||||
|
DEF(iterator_close_return, 1, 4, 4, none)
|
||||||
|
DEF(async_iterator_close, 1, 3, 2, none)
|
||||||
|
DEF(async_iterator_next, 1, 4, 4, none)
|
||||||
|
DEF(async_iterator_get, 2, 4, 5, u8)
|
||||||
|
DEF( initial_yield, 1, 0, 0, none)
|
||||||
|
DEF( yield, 1, 1, 2, none)
|
||||||
|
DEF( yield_star, 1, 2, 2, none)
|
||||||
|
DEF(async_yield_star, 1, 1, 2, none)
|
||||||
|
DEF( await, 1, 1, 1, none)
|
||||||
|
|
||||||
|
/* arithmetic/logic operations */
|
||||||
|
DEF( neg, 1, 1, 1, none)
|
||||||
|
DEF( plus, 1, 1, 1, none)
|
||||||
|
DEF( dec, 1, 1, 1, none)
|
||||||
|
DEF( inc, 1, 1, 1, none)
|
||||||
|
DEF( post_dec, 1, 1, 2, none)
|
||||||
|
DEF( post_inc, 1, 1, 2, none)
|
||||||
|
DEF( dec_loc, 2, 0, 0, loc8)
|
||||||
|
DEF( inc_loc, 2, 0, 0, loc8)
|
||||||
|
DEF( add_loc, 2, 1, 0, loc8)
|
||||||
|
DEF( not, 1, 1, 1, none)
|
||||||
|
DEF( lnot, 1, 1, 1, none)
|
||||||
|
DEF( typeof, 1, 1, 1, none)
|
||||||
|
DEF( delete, 1, 2, 1, none)
|
||||||
|
DEF( delete_var, 5, 0, 1, atom)
|
||||||
|
|
||||||
|
DEF( mul, 1, 2, 1, none)
|
||||||
|
DEF( div, 1, 2, 1, none)
|
||||||
|
DEF( mod, 1, 2, 1, none)
|
||||||
|
DEF( add, 1, 2, 1, none)
|
||||||
|
DEF( sub, 1, 2, 1, none)
|
||||||
|
DEF( pow, 1, 2, 1, none)
|
||||||
|
DEF( shl, 1, 2, 1, none)
|
||||||
|
DEF( sar, 1, 2, 1, none)
|
||||||
|
DEF( shr, 1, 2, 1, none)
|
||||||
|
DEF( lt, 1, 2, 1, none)
|
||||||
|
DEF( lte, 1, 2, 1, none)
|
||||||
|
DEF( gt, 1, 2, 1, none)
|
||||||
|
DEF( gte, 1, 2, 1, none)
|
||||||
|
DEF( instanceof, 1, 2, 1, none)
|
||||||
|
DEF( in, 1, 2, 1, none)
|
||||||
|
DEF( eq, 1, 2, 1, none)
|
||||||
|
DEF( neq, 1, 2, 1, none)
|
||||||
|
DEF( strict_eq, 1, 2, 1, none)
|
||||||
|
DEF( strict_neq, 1, 2, 1, none)
|
||||||
|
DEF( and, 1, 2, 1, none)
|
||||||
|
DEF( xor, 1, 2, 1, none)
|
||||||
|
DEF( or, 1, 2, 1, none)
|
||||||
|
DEF(is_undefined_or_null, 1, 1, 1, none)
|
||||||
|
#ifdef CONFIG_BIGNUM
|
||||||
|
DEF( mul_pow10, 1, 2, 1, none)
|
||||||
|
DEF( math_mod, 1, 2, 1, none)
|
||||||
|
#endif
|
||||||
|
/* must be the last non short and non temporary opcode */
|
||||||
|
DEF( nop, 1, 0, 0, none)
|
||||||
|
|
||||||
|
/* temporary opcodes: never emitted in the final bytecode */
|
||||||
|
|
||||||
|
def(set_arg_valid_upto, 3, 0, 0, arg) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
|
||||||
|
def( enter_scope, 3, 0, 0, u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
def( leave_scope, 3, 0, 0, u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
|
||||||
|
def( label, 5, 0, 0, label) /* emitted in phase 1, removed in phase 3 */
|
||||||
|
|
||||||
|
def(scope_get_var_undef, 7, 0, 1, atom_u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
def( scope_get_var, 7, 0, 1, atom_u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
def( scope_put_var, 7, 1, 0, atom_u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
def(scope_delete_var, 7, 0, 1, atom_u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
def( scope_make_ref, 11, 0, 2, atom_label_u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
def( scope_get_ref, 7, 0, 2, atom_u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
def(scope_put_var_init, 7, 0, 2, atom_u16) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
def(scope_get_private_field, 7, 1, 1, atom_u16) /* obj -> value, emitted in phase 1, removed in phase 2 */
|
||||||
|
def(scope_get_private_field2, 7, 1, 2, atom_u16) /* obj -> obj value, emitted in phase 1, removed in phase 2 */
|
||||||
|
def(scope_put_private_field, 7, 1, 1, atom_u16) /* obj value ->, emitted in phase 1, removed in phase 2 */
|
||||||
|
|
||||||
|
def( set_class_name, 5, 1, 1, u32) /* emitted in phase 1, removed in phase 2 */
|
||||||
|
|
||||||
|
def( line_num, 5, 0, 0, u32) /* emitted in phase 1, removed in phase 3 */
|
||||||
|
|
||||||
|
#if SHORT_OPCODES
|
||||||
|
DEF( push_minus1, 1, 0, 1, none_int)
|
||||||
|
DEF( push_0, 1, 0, 1, none_int)
|
||||||
|
DEF( push_1, 1, 0, 1, none_int)
|
||||||
|
DEF( push_2, 1, 0, 1, none_int)
|
||||||
|
DEF( push_3, 1, 0, 1, none_int)
|
||||||
|
DEF( push_4, 1, 0, 1, none_int)
|
||||||
|
DEF( push_5, 1, 0, 1, none_int)
|
||||||
|
DEF( push_6, 1, 0, 1, none_int)
|
||||||
|
DEF( push_7, 1, 0, 1, none_int)
|
||||||
|
DEF( push_i8, 2, 0, 1, i8)
|
||||||
|
DEF( push_i16, 3, 0, 1, i16)
|
||||||
|
DEF( push_const8, 2, 0, 1, const8)
|
||||||
|
DEF( fclosure8, 2, 0, 1, const8) /* must follow push_const8 */
|
||||||
|
DEF(push_empty_string, 1, 0, 1, none)
|
||||||
|
|
||||||
|
DEF( get_loc8, 2, 0, 1, loc8)
|
||||||
|
DEF( put_loc8, 2, 1, 0, loc8)
|
||||||
|
DEF( set_loc8, 2, 1, 1, loc8)
|
||||||
|
|
||||||
|
DEF( get_loc0, 1, 0, 1, none_loc)
|
||||||
|
DEF( get_loc1, 1, 0, 1, none_loc)
|
||||||
|
DEF( get_loc2, 1, 0, 1, none_loc)
|
||||||
|
DEF( get_loc3, 1, 0, 1, none_loc)
|
||||||
|
DEF( put_loc0, 1, 1, 0, none_loc)
|
||||||
|
DEF( put_loc1, 1, 1, 0, none_loc)
|
||||||
|
DEF( put_loc2, 1, 1, 0, none_loc)
|
||||||
|
DEF( put_loc3, 1, 1, 0, none_loc)
|
||||||
|
DEF( set_loc0, 1, 1, 1, none_loc)
|
||||||
|
DEF( set_loc1, 1, 1, 1, none_loc)
|
||||||
|
DEF( set_loc2, 1, 1, 1, none_loc)
|
||||||
|
DEF( set_loc3, 1, 1, 1, none_loc)
|
||||||
|
DEF( get_arg0, 1, 0, 1, none_arg)
|
||||||
|
DEF( get_arg1, 1, 0, 1, none_arg)
|
||||||
|
DEF( get_arg2, 1, 0, 1, none_arg)
|
||||||
|
DEF( get_arg3, 1, 0, 1, none_arg)
|
||||||
|
DEF( put_arg0, 1, 1, 0, none_arg)
|
||||||
|
DEF( put_arg1, 1, 1, 0, none_arg)
|
||||||
|
DEF( put_arg2, 1, 1, 0, none_arg)
|
||||||
|
DEF( put_arg3, 1, 1, 0, none_arg)
|
||||||
|
DEF( set_arg0, 1, 1, 1, none_arg)
|
||||||
|
DEF( set_arg1, 1, 1, 1, none_arg)
|
||||||
|
DEF( set_arg2, 1, 1, 1, none_arg)
|
||||||
|
DEF( set_arg3, 1, 1, 1, none_arg)
|
||||||
|
DEF( get_var_ref0, 1, 0, 1, none_var_ref)
|
||||||
|
DEF( get_var_ref1, 1, 0, 1, none_var_ref)
|
||||||
|
DEF( get_var_ref2, 1, 0, 1, none_var_ref)
|
||||||
|
DEF( get_var_ref3, 1, 0, 1, none_var_ref)
|
||||||
|
DEF( put_var_ref0, 1, 1, 0, none_var_ref)
|
||||||
|
DEF( put_var_ref1, 1, 1, 0, none_var_ref)
|
||||||
|
DEF( put_var_ref2, 1, 1, 0, none_var_ref)
|
||||||
|
DEF( put_var_ref3, 1, 1, 0, none_var_ref)
|
||||||
|
DEF( set_var_ref0, 1, 1, 1, none_var_ref)
|
||||||
|
DEF( set_var_ref1, 1, 1, 1, none_var_ref)
|
||||||
|
DEF( set_var_ref2, 1, 1, 1, none_var_ref)
|
||||||
|
DEF( set_var_ref3, 1, 1, 1, none_var_ref)
|
||||||
|
|
||||||
|
DEF( get_length, 1, 1, 1, none)
|
||||||
|
|
||||||
|
DEF( if_false8, 2, 1, 0, label8)
|
||||||
|
DEF( if_true8, 2, 1, 0, label8) /* must come after if_false8 */
|
||||||
|
DEF( goto8, 2, 0, 0, label8) /* must come after if_true8 */
|
||||||
|
DEF( goto16, 3, 0, 0, label16)
|
||||||
|
|
||||||
|
DEF( call0, 1, 1, 1, npopx)
|
||||||
|
DEF( call1, 1, 1, 1, npopx)
|
||||||
|
DEF( call2, 1, 1, 1, npopx)
|
||||||
|
DEF( call3, 1, 1, 1, npopx)
|
||||||
|
|
||||||
|
DEF( is_undefined, 1, 1, 1, none)
|
||||||
|
DEF( is_null, 1, 1, 1, none)
|
||||||
|
DEF( is_function, 1, 1, 1, none)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef DEF
|
||||||
|
#undef def
|
||||||
|
#endif /* DEF */
|
53504
cxx/quickjs/quickjs.c
Normal file
53504
cxx/quickjs/quickjs.c
Normal file
File diff suppressed because it is too large
Load Diff
1054
cxx/quickjs/quickjs.h
Normal file
1054
cxx/quickjs/quickjs.h
Normal file
File diff suppressed because it is too large
Load Diff
1294
cxx/quickjs/quickjspp.hpp
Normal file
1294
cxx/quickjs/quickjspp.hpp
Normal file
File diff suppressed because it is too large
Load Diff
Submodule cxx/quickjspp deleted from 0768b665d5
@@ -3,7 +3,7 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-07-18 23:28:55
|
* @Date: 2020-07-18 23:28:55
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-19 13:26:52
|
* @LastEditTime: 2020-08-20 12:51:21
|
||||||
*/
|
*/
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
@@ -44,17 +44,12 @@ class _TestPageState extends State<TestPage> {
|
|||||||
engine = FlutterJs();
|
engine = FlutterJs();
|
||||||
engine.setMethodHandler((String method, List arg) async {
|
engine.setMethodHandler((String method, List arg) async {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "delay":
|
|
||||||
await Future.delayed(Duration(milliseconds: arg[0]));
|
|
||||||
return;
|
|
||||||
case "http":
|
case "http":
|
||||||
Response response = await Dio()
|
Response response = await Dio()
|
||||||
.get(arg[0], options: Options(responseType: ResponseType.bytes));
|
.get(arg[0], options: Options(responseType: ResponseType.bytes));
|
||||||
return response.data;
|
return response.data;
|
||||||
case "hello":
|
|
||||||
return await arg[0](["hello: "]);
|
|
||||||
case "test":
|
case "test":
|
||||||
return [
|
return await arg[0]([
|
||||||
true,
|
true,
|
||||||
1,
|
1,
|
||||||
0.5,
|
0.5,
|
||||||
@@ -64,7 +59,7 @@ class _TestPageState extends State<TestPage> {
|
|||||||
Int32List(2),
|
Int32List(2),
|
||||||
Int64List(2),
|
Int64List(2),
|
||||||
Float64List(2),
|
Float64List(2),
|
||||||
Float32List(2)];
|
Float32List(2)]);
|
||||||
default:
|
default:
|
||||||
return JsMethodHandlerNotImplement();
|
return JsMethodHandlerNotImplement();
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(runner LANGUAGES CXX)
|
project(runner LANGUAGES CXX)
|
||||||
|
|
||||||
set(BINARY_NAME "flutter_qjs_example")
|
set(BINARY_NAME "example")
|
||||||
set(APPLICATION_ID "soko.ekibun.flutter_qjs")
|
set(APPLICATION_ID "soko.ekibun.example")
|
||||||
|
|
||||||
cmake_policy(SET CMP0063 NEW)
|
cmake_policy(SET CMP0063 NEW)
|
||||||
|
|
||||||
@@ -19,8 +19,7 @@ endif()
|
|||||||
# Compilation settings that should be applied to most targets.
|
# Compilation settings that should be applied to most targets.
|
||||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||||
target_compile_features(${TARGET} PUBLIC cxx_std_17)
|
target_compile_features(${TARGET} PUBLIC cxx_std_17)
|
||||||
# target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
target_compile_options(${TARGET} PRIVATE -Wall -Werror)
|
||||||
target_compile_options(${TARGET} PRIVATE -Wall)
|
|
||||||
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
target_compile_options(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:-O3>")
|
||||||
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
target_compile_definitions(${TARGET} PRIVATE "$<$<NOT:$<CONFIG:Debug>>:NDEBUG>")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@@ -24,6 +24,7 @@ find_package(PkgConfig REQUIRED)
|
|||||||
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0)
|
||||||
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0)
|
||||||
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
|
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
|
||||||
|
pkg_check_modules(BLKID REQUIRED IMPORTED_TARGET blkid)
|
||||||
|
|
||||||
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
|
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so")
|
||||||
|
|
||||||
@@ -65,6 +66,7 @@ target_link_libraries(flutter INTERFACE
|
|||||||
PkgConfig::GTK
|
PkgConfig::GTK
|
||||||
PkgConfig::GLIB
|
PkgConfig::GLIB
|
||||||
PkgConfig::GIO
|
PkgConfig::GIO
|
||||||
|
PkgConfig::BLKID
|
||||||
)
|
)
|
||||||
add_dependencies(flutter flutter_assemble)
|
add_dependencies(flutter flutter_assemble)
|
||||||
|
|
||||||
|
@@ -14,7 +14,7 @@ G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
|
|||||||
static void my_application_activate(GApplication* application) {
|
static void my_application_activate(GApplication* application) {
|
||||||
GtkWindow* window =
|
GtkWindow* window =
|
||||||
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application)));
|
||||||
gtk_window_set_title(window, "flutter_qjs_example");
|
gtk_window_set_title(window, "example");
|
||||||
gtk_window_set_default_size(window, 1280, 720);
|
gtk_window_set_default_size(window, 1280, 720);
|
||||||
gtk_widget_show(GTK_WIDGET(window));
|
gtk_widget_show(GTK_WIDGET(window));
|
||||||
|
|
||||||
|
@@ -1,27 +0,0 @@
|
|||||||
// This is a basic Flutter widget test.
|
|
||||||
//
|
|
||||||
// To perform an interaction with a widget in your test, use the WidgetTester
|
|
||||||
// utility that Flutter provides. For example, you can send tap and scroll
|
|
||||||
// gestures. You can also use WidgetTester to find child widgets in the widget
|
|
||||||
// tree, read text, and verify that the values of widget properties are correct.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
import 'package:flutter_qjs_example/main.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
testWidgets('Verify Platform version', (WidgetTester tester) async {
|
|
||||||
// Build our app and trigger a frame.
|
|
||||||
await tester.pumpWidget(MyApp());
|
|
||||||
|
|
||||||
// Verify that platform version is retrieved.
|
|
||||||
expect(
|
|
||||||
find.byWidgetPredicate(
|
|
||||||
(Widget widget) => widget is Text &&
|
|
||||||
widget.data.startsWith('Running on:'),
|
|
||||||
),
|
|
||||||
findsOneWidget,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
@@ -3,7 +3,7 @@
|
|||||||
* @Author: ekibun
|
* @Author: ekibun
|
||||||
* @Date: 2020-08-08 08:29:09
|
* @Date: 2020-08-08 08:29:09
|
||||||
* @LastEditors: ekibun
|
* @LastEditors: ekibun
|
||||||
* @LastEditTime: 2020-08-18 23:23:22
|
* @LastEditTime: 2020-08-20 12:49:46
|
||||||
*/
|
*/
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
@@ -65,7 +65,7 @@ class _FlutterJs {
|
|||||||
class FlutterJs {
|
class FlutterJs {
|
||||||
dynamic _engine;
|
dynamic _engine;
|
||||||
|
|
||||||
ensureEngine() async {
|
_ensureEngine() async {
|
||||||
if (_engine == null) {
|
if (_engine == null) {
|
||||||
_engine = await _FlutterJs.instance._channel.invokeMethod("createEngine");
|
_engine = await _FlutterJs.instance._channel.invokeMethod("createEngine");
|
||||||
print(_engine);
|
print(_engine);
|
||||||
@@ -73,7 +73,7 @@ class FlutterJs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setMethodHandler(JsMethodHandler handler) async {
|
setMethodHandler(JsMethodHandler handler) async {
|
||||||
await ensureEngine();
|
await _ensureEngine();
|
||||||
_FlutterJs.instance.methodHandlers[_engine] = handler;
|
_FlutterJs.instance.methodHandlers[_engine] = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ class FlutterJs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> evaluate(String command, String name) async {
|
Future<dynamic> evaluate(String command, String name) async {
|
||||||
ensureEngine();
|
_ensureEngine();
|
||||||
var arguments = {"engine": _engine, "script": command, "name": "<eval>"};
|
var arguments = {"engine": _engine, "script": command, "name": "<eval>"};
|
||||||
return _FlutterJs.instance._wrapFunctionArguments(
|
return _FlutterJs.instance._wrapFunctionArguments(
|
||||||
await _FlutterJs.instance._channel.invokeMethod("evaluate", arguments), _engine);
|
await _FlutterJs.instance._channel.invokeMethod("evaluate", arguments), _engine);
|
||||||
|
@@ -1,16 +1,15 @@
|
|||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
# quickjs
|
# quickjs
|
||||||
set(QUICK_JS_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../cxx/quickjspp)
|
set(QUICK_JS_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../cxx/quickjs)
|
||||||
file (STRINGS "${QUICK_JS_LIB_DIR}/quickjs/VERSION" QUICKJS_VERSION)
|
file (STRINGS "${QUICK_JS_LIB_DIR}/VERSION" QUICKJS_VERSION)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCONFIG_VERSION=\\\"${QUICKJS_VERSION}\\\"")
|
|
||||||
add_library(libquickjs SHARED
|
add_library(libquickjs SHARED
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/cutils.c
|
${QUICK_JS_LIB_DIR}/cutils.c
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/libregexp.c
|
${QUICK_JS_LIB_DIR}/libregexp.c
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/libunicode.c
|
${QUICK_JS_LIB_DIR}/libunicode.c
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/quickjs.h
|
${QUICK_JS_LIB_DIR}/quickjs.c
|
||||||
${QUICK_JS_LIB_DIR}/quickjs/quickjs.c
|
|
||||||
)
|
)
|
||||||
project(libquickjs LANGUAGES C)
|
project(libquickjs LANGUAGES C)
|
||||||
|
target_compile_options(libquickjs PRIVATE "-DCONFIG_VERSION=\"${QUICKJS_VERSION}\"")
|
||||||
|
|
||||||
set(PROJECT_NAME "flutter_qjs")
|
set(PROJECT_NAME "flutter_qjs")
|
||||||
project(${PROJECT_NAME} LANGUAGES CXX)
|
project(${PROJECT_NAME} LANGUAGES CXX)
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
name: flutter_qjs
|
name: flutter_qjs
|
||||||
description: A new flutter plugin project.
|
description: A new flutter plugin project.
|
||||||
version: 0.0.1
|
version: 0.0.1
|
||||||
author:
|
homepage: https://github.com/ekibun/flutter_qjs
|
||||||
homepage:
|
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
@@ -1,19 +0,0 @@
|
|||||||
import 'package:flutter/services.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
const MethodChannel channel = MethodChannel('flutter_qjs');
|
|
||||||
|
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
|
||||||
|
|
||||||
setUp(() {
|
|
||||||
channel.setMockMethodCallHandler((MethodCall methodCall) async {
|
|
||||||
return '42';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
tearDown(() {
|
|
||||||
channel.setMockMethodCallHandler(null);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
@@ -1,4 +1,17 @@
|
|||||||
cmake_minimum_required(VERSION 3.15)
|
cmake_minimum_required(VERSION 3.15)
|
||||||
|
|
||||||
|
# quickjs
|
||||||
|
set(QUICK_JS_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../cxx/quickjs)
|
||||||
|
file (STRINGS "${QUICK_JS_LIB_DIR}/VERSION" QUICKJS_VERSION)
|
||||||
|
add_library(libquickjs STATIC
|
||||||
|
${QUICK_JS_LIB_DIR}/cutils.c
|
||||||
|
${QUICK_JS_LIB_DIR}/libregexp.c
|
||||||
|
${QUICK_JS_LIB_DIR}/libunicode.c
|
||||||
|
${QUICK_JS_LIB_DIR}/quickjs.c
|
||||||
|
)
|
||||||
|
project(libquickjs LANGUAGES C)
|
||||||
|
target_compile_options(libquickjs PRIVATE "-DCONFIG_VERSION=\"${QUICKJS_VERSION}\"")
|
||||||
|
|
||||||
set(PROJECT_NAME "flutter_qjs")
|
set(PROJECT_NAME "flutter_qjs")
|
||||||
project(${PROJECT_NAME} LANGUAGES CXX)
|
project(${PROJECT_NAME} LANGUAGES CXX)
|
||||||
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
|
||||||
@@ -14,12 +27,10 @@ set_target_properties(${PLUGIN_NAME} PROPERTIES
|
|||||||
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
|
target_compile_definitions(${PLUGIN_NAME} PRIVATE FLUTTER_PLUGIN_IMPL)
|
||||||
target_include_directories(${PLUGIN_NAME} INTERFACE
|
target_include_directories(${PLUGIN_NAME} INTERFACE
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include")
|
"${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||||
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin
|
target_link_libraries(${PLUGIN_NAME} PRIVATE flutter flutter_wrapper_plugin libquickjs)
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/quickjs/libquickjs64.a"
|
|
||||||
)
|
|
||||||
|
|
||||||
# List of absolute paths to libraries that should be bundled with the plugin
|
# List of absolute paths to libraries that should be bundled with the plugin
|
||||||
set(flutter_qjs_bundled_libraries
|
set(flutter_qjs_bundled_libraries
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/quickjs/libquickjs64.dll"
|
""
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
@@ -151,7 +151,7 @@ namespace
|
|||||||
{
|
{
|
||||||
callargs[i] = qjs::dartToJs(ctx.ctx, arguments[i]);
|
callargs[i] = qjs::dartToJs(ctx.ctx, arguments[i]);
|
||||||
}
|
}
|
||||||
qjs::JSValue ret = JS_Call(ctx.ctx, *function, qjs::JSValue{qjs::JSValueUnion{0}, qjs::JS_TAG_UNDEFINED}, (int)argscount, callargs);
|
qjs::JSValue ret = JS_Call(ctx.ctx, *function, ctx.global().v, (int)argscount, callargs);
|
||||||
qjs::JS_FreeValue(ctx.ctx, *function);
|
qjs::JS_FreeValue(ctx.ctx, *function);
|
||||||
if (qjs::JS_IsException(ret))
|
if (qjs::JS_IsException(ret))
|
||||||
throw qjs::exception{};
|
throw qjs::exception{};
|
||||||
|
@@ -1,195 +0,0 @@
|
|||||||
EXPORTS
|
|
||||||
JS_AddIntrinsicAtomics
|
|
||||||
JS_AddIntrinsicBaseObjects
|
|
||||||
JS_AddIntrinsicBigDecimal
|
|
||||||
JS_AddIntrinsicBigFloat
|
|
||||||
JS_AddIntrinsicBigInt
|
|
||||||
JS_AddIntrinsicDate
|
|
||||||
JS_AddIntrinsicEval
|
|
||||||
JS_AddIntrinsicJSON
|
|
||||||
JS_AddIntrinsicMapSet
|
|
||||||
JS_AddIntrinsicOperators
|
|
||||||
JS_AddIntrinsicPromise
|
|
||||||
JS_AddIntrinsicProxy
|
|
||||||
JS_AddIntrinsicRegExp
|
|
||||||
JS_AddIntrinsicRegExpCompiler
|
|
||||||
JS_AddIntrinsicStringNormalize
|
|
||||||
JS_AddIntrinsicTypedArrays
|
|
||||||
JS_AddModuleExport
|
|
||||||
JS_AddModuleExportList
|
|
||||||
JS_AtomToCString
|
|
||||||
JS_AtomToString
|
|
||||||
JS_AtomToValue
|
|
||||||
JS_Call
|
|
||||||
JS_CallConstructor
|
|
||||||
JS_CallConstructor2
|
|
||||||
JS_ComputeMemoryUsage
|
|
||||||
JS_DefineProperty
|
|
||||||
JS_DefinePropertyGetSet
|
|
||||||
JS_DefinePropertyValue
|
|
||||||
JS_DefinePropertyValueInt64
|
|
||||||
JS_DefinePropertyValueStr
|
|
||||||
JS_DefinePropertyValueUint32
|
|
||||||
JS_DefinePropertyValueValue
|
|
||||||
JS_DeleteProperty
|
|
||||||
JS_DeletePropertyInt64
|
|
||||||
JS_DetachArrayBuffer
|
|
||||||
JS_DetectModule
|
|
||||||
JS_DumpMemoryUsage
|
|
||||||
JS_DupAtom
|
|
||||||
JS_DupContext
|
|
||||||
JS_EnableBignumExt
|
|
||||||
JS_EnqueueJob
|
|
||||||
JS_Eval
|
|
||||||
JS_EvalFunction
|
|
||||||
JS_ExecutePendingJob
|
|
||||||
JS_FreeAtom
|
|
||||||
JS_FreeAtomRT
|
|
||||||
JS_FreeCString
|
|
||||||
JS_FreeContext
|
|
||||||
JS_FreeRuntime
|
|
||||||
JS_GetArrayBuffer
|
|
||||||
JS_GetClassProto
|
|
||||||
JS_GetContextOpaque
|
|
||||||
JS_GetException
|
|
||||||
JS_GetGlobalObject
|
|
||||||
JS_GetImportMeta
|
|
||||||
JS_GetModuleName
|
|
||||||
JS_GetOpaque
|
|
||||||
JS_GetOpaque2
|
|
||||||
JS_GetOwnProperty
|
|
||||||
JS_GetOwnPropertyNames
|
|
||||||
JS_GetPropertyInternal
|
|
||||||
JS_GetPropertyStr
|
|
||||||
JS_GetPropertyUint32
|
|
||||||
JS_GetPrototype
|
|
||||||
JS_GetRuntime
|
|
||||||
JS_GetRuntimeOpaque
|
|
||||||
JS_GetTypedArrayBuffer
|
|
||||||
JS_HasProperty
|
|
||||||
JS_Invoke
|
|
||||||
JS_IsArray
|
|
||||||
JS_IsCFunction
|
|
||||||
JS_IsConstructor
|
|
||||||
JS_IsError
|
|
||||||
JS_IsExtensible
|
|
||||||
JS_IsFunction
|
|
||||||
JS_IsInstanceOf
|
|
||||||
JS_IsJobPending
|
|
||||||
JS_IsLiveObject
|
|
||||||
JS_IsRegisteredClass
|
|
||||||
JS_IsUncatchableError
|
|
||||||
JS_JSONStringify
|
|
||||||
JS_MarkValue
|
|
||||||
JS_NewArray
|
|
||||||
JS_NewArrayBuffer
|
|
||||||
JS_NewArrayBufferCopy
|
|
||||||
JS_NewAtom
|
|
||||||
JS_NewAtomLen
|
|
||||||
JS_NewAtomString
|
|
||||||
JS_NewAtomUInt32
|
|
||||||
JS_NewBigInt64
|
|
||||||
JS_NewBigInt64_1
|
|
||||||
JS_NewBigUint64
|
|
||||||
JS_NewCFunction2
|
|
||||||
JS_NewCFunctionData
|
|
||||||
JS_NewCModule
|
|
||||||
JS_NewClass
|
|
||||||
JS_NewClassID
|
|
||||||
JS_NewContext
|
|
||||||
JS_NewContextRaw
|
|
||||||
JS_NewError
|
|
||||||
JS_NewObject
|
|
||||||
JS_NewObjectClass
|
|
||||||
JS_NewObjectProto
|
|
||||||
JS_NewObjectProtoClass
|
|
||||||
JS_NewPromiseCapability
|
|
||||||
JS_NewRuntime
|
|
||||||
JS_NewRuntime2
|
|
||||||
JS_NewString
|
|
||||||
JS_NewStringLen
|
|
||||||
JS_ParseJSON
|
|
||||||
JS_ParseJSON2
|
|
||||||
JS_PreventExtensions
|
|
||||||
JS_ReadObject
|
|
||||||
JS_ResetUncatchableError
|
|
||||||
JS_ResolveModule
|
|
||||||
JS_RunGC
|
|
||||||
JS_SetCanBlock
|
|
||||||
JS_SetClassProto
|
|
||||||
JS_SetConstructor
|
|
||||||
JS_SetConstructorBit
|
|
||||||
JS_SetContextOpaque
|
|
||||||
JS_SetGCThreshold
|
|
||||||
JS_SetHostPromiseRejectionTracker
|
|
||||||
JS_SetInterruptHandler
|
|
||||||
JS_SetMaxStackSize
|
|
||||||
JS_SetMemoryLimit
|
|
||||||
JS_SetModuleExport
|
|
||||||
JS_SetModuleExportList
|
|
||||||
JS_SetModuleLoaderFunc
|
|
||||||
JS_SetOpaque
|
|
||||||
JS_SetPropertyFunctionList
|
|
||||||
JS_SetPropertyInt64
|
|
||||||
JS_SetPropertyInternal
|
|
||||||
JS_SetPropertyStr
|
|
||||||
JS_SetPropertyUint32
|
|
||||||
JS_SetPrototype
|
|
||||||
JS_SetRuntimeInfo
|
|
||||||
JS_SetRuntimeOpaque
|
|
||||||
JS_SetSharedArrayBufferFunctions
|
|
||||||
JS_SetUncatchableError
|
|
||||||
JS_Throw
|
|
||||||
JS_ThrowInternalError
|
|
||||||
JS_ThrowOutOfMemory
|
|
||||||
JS_ThrowRangeError
|
|
||||||
JS_ThrowReferenceError
|
|
||||||
JS_ThrowSyntaxError
|
|
||||||
JS_ThrowTypeError
|
|
||||||
JS_ToBigInt64
|
|
||||||
JS_ToBool
|
|
||||||
JS_ToCStringLen2
|
|
||||||
JS_ToFloat64
|
|
||||||
JS_ToIndex
|
|
||||||
JS_ToInt32
|
|
||||||
JS_ToInt32Clamp
|
|
||||||
JS_ToInt32Sat
|
|
||||||
JS_ToInt64
|
|
||||||
JS_ToInt64Clamp
|
|
||||||
JS_ToInt64Ext
|
|
||||||
JS_ToInt64Sat
|
|
||||||
JS_ToPropertyKey
|
|
||||||
JS_ToString
|
|
||||||
JS_ToStringInternal
|
|
||||||
JS_ValueToAtom
|
|
||||||
JS_WriteObject
|
|
||||||
JS_WriteObject2
|
|
||||||
__JS_FreeValue
|
|
||||||
__JS_FreeValueRT
|
|
||||||
js_free
|
|
||||||
js_free_rt
|
|
||||||
js_init_module_os
|
|
||||||
js_init_module_std
|
|
||||||
js_load_file
|
|
||||||
js_malloc
|
|
||||||
js_malloc_rt
|
|
||||||
js_malloc_usable_size
|
|
||||||
js_malloc_usable_size_rt
|
|
||||||
js_mallocz
|
|
||||||
js_mallocz_rt
|
|
||||||
js_module_loader
|
|
||||||
js_module_set_import_meta
|
|
||||||
js_parse_error
|
|
||||||
js_realloc
|
|
||||||
js_realloc2
|
|
||||||
js_realloc_rt
|
|
||||||
js_std_add_helpers
|
|
||||||
js_std_dump_error
|
|
||||||
js_std_eval_binary
|
|
||||||
js_std_free_handlers
|
|
||||||
js_std_init_handlers
|
|
||||||
js_std_loop
|
|
||||||
js_std_promise_rejection_tracker
|
|
||||||
js_strdup
|
|
||||||
js_string_codePointRange
|
|
||||||
js_strndup
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user