✨ add framework for subprocess
This commit is contained in:
parent
1205c6d788
commit
7e3c6d06b2
|
@ -30,6 +30,7 @@ set(NASAL_OBJECT_SOURCE_FILE
|
||||||
${CMAKE_SOURCE_DIR}/src/natives/math_lib.cpp
|
${CMAKE_SOURCE_DIR}/src/natives/math_lib.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/natives/dylib_lib.cpp
|
${CMAKE_SOURCE_DIR}/src/natives/dylib_lib.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/natives/regex_lib.cpp
|
${CMAKE_SOURCE_DIR}/src/natives/regex_lib.cpp
|
||||||
|
${CMAKE_SOURCE_DIR}/src/natives/subprocess.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/natives/unix_lib.cpp
|
${CMAKE_SOURCE_DIR}/src/natives/unix_lib.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/repl/repl.cpp
|
${CMAKE_SOURCE_DIR}/src/repl/repl.cpp
|
||||||
${CMAKE_SOURCE_DIR}/src/util/fs.cpp
|
${CMAKE_SOURCE_DIR}/src/util/fs.cpp
|
||||||
|
|
10
makefile
10
makefile
|
@ -37,6 +37,7 @@ NASAL_HEADER = \
|
||||||
src/natives/unix_lib.h\
|
src/natives/unix_lib.h\
|
||||||
src/natives/coroutine.h\
|
src/natives/coroutine.h\
|
||||||
src/natives/regex_lib.h\
|
src/natives/regex_lib.h\
|
||||||
|
src/natives/subprocess.h\
|
||||||
src/repl/repl.h\
|
src/repl/repl.h\
|
||||||
src/util/fs.h\
|
src/util/fs.h\
|
||||||
src/util/util.h
|
src/util/util.h
|
||||||
|
@ -61,6 +62,7 @@ NASAL_OBJECT = \
|
||||||
build/math_lib.o\
|
build/math_lib.o\
|
||||||
build/unix_lib.o\
|
build/unix_lib.o\
|
||||||
build/dylib_lib.o\
|
build/dylib_lib.o\
|
||||||
|
build/subprocess.o\
|
||||||
build/json_lib.o\
|
build/json_lib.o\
|
||||||
build/coroutine.o\
|
build/coroutine.o\
|
||||||
build/nasal_type.o\
|
build/nasal_type.o\
|
||||||
|
@ -212,6 +214,14 @@ build/regex_lib.o: \
|
||||||
src/natives/regex_lib.h src/natives/regex_lib.cpp | build
|
src/natives/regex_lib.h src/natives/regex_lib.cpp | build
|
||||||
$(CXX) $(CXXFLAGS) src/natives/regex_lib.cpp -o build/regex_lib.o
|
$(CXX) $(CXXFLAGS) src/natives/regex_lib.cpp -o build/regex_lib.o
|
||||||
|
|
||||||
|
build/subprocess.o: \
|
||||||
|
src/nasal.h\
|
||||||
|
src/nasal_type.h\
|
||||||
|
src/nasal_gc.h\
|
||||||
|
src/natives/subprocess.h src/natives/subprocess.cpp | build
|
||||||
|
$(CXX) $(CXXFLAGS) src/natives/subprocess.cpp -o build/subprocess.o
|
||||||
|
|
||||||
|
|
||||||
build/fg_props.o: \
|
build/fg_props.o: \
|
||||||
src/nasal.h\
|
src/nasal.h\
|
||||||
src/nasal_type.h\
|
src/nasal_type.h\
|
||||||
|
|
|
@ -39,6 +39,7 @@ void codegen::init_native_function() {
|
||||||
load_native_function_table(unix_lib_native);
|
load_native_function_table(unix_lib_native);
|
||||||
load_native_function_table(json_lib_native);
|
load_native_function_table(json_lib_native);
|
||||||
load_native_function_table(regex_lib_native);
|
load_native_function_table(regex_lib_native);
|
||||||
|
load_native_function_table(subprocess_native);
|
||||||
}
|
}
|
||||||
|
|
||||||
void codegen::check_id_exist(identifier* node) {
|
void codegen::check_id_exist(identifier* node) {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "natives/dylib_lib.h"
|
#include "natives/dylib_lib.h"
|
||||||
#include "natives/regex_lib.h"
|
#include "natives/regex_lib.h"
|
||||||
#include "natives/unix_lib.h"
|
#include "natives/unix_lib.h"
|
||||||
|
#include "natives/subprocess.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -57,7 +58,9 @@ private:
|
||||||
"__dlopen", "__dlclose", "__dlcallv", "__dlcall",
|
"__dlopen", "__dlclose", "__dlcallv", "__dlcall",
|
||||||
// unix
|
// unix
|
||||||
"__pipe", "__fork", "__waitpid", "__chdir",
|
"__pipe", "__fork", "__waitpid", "__chdir",
|
||||||
"__environ", "__getcwd", "__getenv"
|
"__environ", "__getcwd", "__getenv",
|
||||||
|
// subprocess
|
||||||
|
"__subprocess_run"
|
||||||
};
|
};
|
||||||
|
|
||||||
// file mapper for file -> index
|
// file mapper for file -> index
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#include "natives/subprocess.h"
|
||||||
|
|
||||||
|
namespace nasal {
|
||||||
|
|
||||||
|
var builtin_subprocess_run(context* ctx, gc* ngc) {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
nasal_builtin_table subprocess_native[] = {
|
||||||
|
{"__subprocess_run", builtin_subprocess_run},
|
||||||
|
{nullptr, nullptr}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "nasal.h"
|
||||||
|
#include "nasal_gc.h"
|
||||||
|
#include "natives/builtin.h"
|
||||||
|
|
||||||
|
namespace nasal {
|
||||||
|
|
||||||
|
var builtin_subprocess_run(context*, gc*);
|
||||||
|
|
||||||
|
extern nasal_builtin_table subprocess_native[];
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
var run = func() {
|
||||||
|
return __subprocess_run();
|
||||||
|
}
|
Loading…
Reference in New Issue