mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-19 01:18:40 +03:00
Lots of good stuff
This commit is contained in:
parent
e061eb410e
commit
5542b5a626
4
.gitignore
vendored
4
.gitignore
vendored
@ -26,3 +26,7 @@ a.out
|
||||
/src/TAGS
|
||||
|
||||
sourcetree.license
|
||||
|
||||
.idea/
|
||||
temp/
|
||||
|
||||
|
@ -78,7 +78,7 @@
|
||||
(framework-paths) " "
|
||||
(link-libs total-dependencies))]
|
||||
(do
|
||||
(println cl-command)
|
||||
;;(println cl-command)
|
||||
(def cmd cl-command)
|
||||
(system cl-command))))
|
||||
|
||||
|
@ -108,7 +108,7 @@
|
||||
(do
|
||||
(graph/add-node! :struct struct-name type-definition "" group-name nil '() dependency-level)
|
||||
(let [arg-list-c (join ", " (map2 (fn [t n] (str (type-build t) " " n)) member-types c-member-names))
|
||||
proto (str c-struct-name " *" c-constructor-name "(" arg-list-c ");")
|
||||
proto (str "API " c-struct-name " *" c-constructor-name "(" arg-list-c ");")
|
||||
substs {"STRUCT-NAME" c-struct-name
|
||||
"CONSTRUCTOR-NAME" c-constructor-name
|
||||
"ARG_LIST" arg-list-c
|
||||
@ -126,7 +126,7 @@
|
||||
:src c-program-string
|
||||
:sig constructor-signature}
|
||||
(let [size-signature (list :fn () :int)
|
||||
size-proto (str "int size_" c-struct-name "()")
|
||||
size-proto (str "API int size_" c-struct-name "()")
|
||||
size-c (str size-proto " { return sizeof(" c-struct-name "); } ")]
|
||||
(lens-function (str "size-" struct-name) size-proto size-c size-signature)))
|
||||
(apply concat (map2 (fn [mem-name mem-type]
|
||||
@ -149,21 +149,21 @@
|
||||
c-member-name (c-ify-name member-name)]
|
||||
(list
|
||||
(let [getter-signature (list :fn (list (list :ref struct-type)) member-t-reffed)
|
||||
getter-proto (str member-t " " c-struct-name "_get_" (c-ify-name member-name) "(" struct-t " x)")
|
||||
getter-proto (str "API " member-t " " c-struct-name "_get_" (c-ify-name member-name) "(" struct-t " x)")
|
||||
getter-c (str getter-proto "{ return x->" c-member-name "; }")]
|
||||
(lens-function (str struct-name "-get-" member-name) getter-proto getter-c getter-signature))
|
||||
(let [setter-signature (list :fn (list struct-type member-type) struct-type)
|
||||
setter-proto (str struct-t " " c-struct-name "_set_" (c-ify-name member-name) "(" struct-t " x, " member-t " value)")
|
||||
setter-proto (str "API " struct-t " " c-struct-name "_set_" (c-ify-name member-name) "(" struct-t " x, " member-t " value)")
|
||||
setter-c (str setter-proto "{ x->" c-member-name " = value; return x; }")]
|
||||
(lens-function (str struct-name "-set-" member-name) setter-proto setter-c setter-signature))
|
||||
(let [updater-fn-type (list :fn (list member-type) member-type)
|
||||
updater-fn-t (type-build updater-fn-type)
|
||||
updater-signature (list :fn (list struct-type updater-fn-type) struct-type)
|
||||
updater-proto (str struct-t " " c-struct-name "_update_" (c-ify-name member-name) "(" struct-t " x, " updater-fn-t " f)")
|
||||
updater-proto (str "API " struct-t " " c-struct-name "_update_" (c-ify-name member-name) "(" struct-t " x, " updater-fn-t " f)")
|
||||
updater-c (str updater-proto "{ x->" c-member-name " = f(x->" c-member-name "); return x; }")]
|
||||
(lens-function (str struct-name "-update-" member-name) updater-proto updater-c updater-signature))
|
||||
(let [offset-signature (list :fn () :int)
|
||||
offset-proto (str "int " c-struct-name "_offset_" (c-ify-name member-name) "()")
|
||||
offset-proto (str "API " "int " c-struct-name "_offset_" (c-ify-name member-name) "()")
|
||||
offset-c (str offset-proto "{ return offsetof(" (c-ify-name struct-name) ", " c-member-name "); }")]
|
||||
(lens-function (str struct-name "-offset-" member-name) offset-proto offset-c offset-signature))))))
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Init/shutdown */
|
||||
|
||||
@ -233,7 +234,7 @@ int carp_unload_library(carp_library_t lib) {
|
||||
remove_module_from_list(carp_loaded_modules, lib->module);
|
||||
BOOL result = FreeLibrary(lib->module);
|
||||
free(lib);
|
||||
return (int)result;
|
||||
return !result;
|
||||
}
|
||||
|
||||
void* carp_find_symbol(carp_library_t lib, const char * name) {
|
||||
|
@ -157,14 +157,14 @@ EXPORT string get_console_color(int x) {
|
||||
#endif
|
||||
}
|
||||
|
||||
Array *chars(string s) {
|
||||
EXPORT Array *chars(string s) {
|
||||
Array *a = malloc(sizeof(Array));
|
||||
a->count = strlen(s);
|
||||
a->data = strdup(s);
|
||||
return a;
|
||||
}
|
||||
|
||||
string string_join(string separator, Array *array_of_strings) {
|
||||
EXPORT string string_join(string separator, Array *array_of_strings) {
|
||||
string *casted = (string*)array_of_strings->data;
|
||||
int separator_len = strlen(separator);
|
||||
int total_length = 0;
|
||||
|
1
src/main.c
Normal file → Executable file
1
src/main.c
Normal file → Executable file
@ -2,7 +2,6 @@
|
||||
#include "eval.h"
|
||||
#include "gc.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "../shared/shared.h"
|
||||
#include "../shared/platform.h"
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "primops.h"
|
||||
#include "process.h"
|
||||
|
||||
jmp_buf jumpbuffer;
|
||||
|
||||
#define MAX_INPUT_BUFFER_SIZE (2048 * 32)
|
||||
char input[MAX_INPUT_BUFFER_SIZE];
|
||||
|
||||
|
2
src/repl.h
Normal file → Executable file
2
src/repl.h
Normal file → Executable file
@ -5,4 +5,4 @@
|
||||
|
||||
void repl(Process *process);
|
||||
|
||||
jmp_buf jumpbuffer;
|
||||
extern jmp_buf jumpbuffer;
|
||||
|
Loading…
Reference in New Issue
Block a user