~mrms/regum

eb8c92561efc8c82dcb6e8bae4cd62ec245921a5 — Marek Ma┼íkarinec 6 months ago 470ba6c
add pak.json
7 files changed, 55 insertions(+), 117 deletions(-)

A .build.yml
M .gitignore
A build.sh
A pak.json
M reg.c
D reg_linux.umi
D umka_api.h
A .build.yml => .build.yml +26 -0
@@ 0,0 1,26 @@
image: debian/bullseye
packages:
- python3
- python3-pip
sources:
- https://git.sr.ht/~mrms/regum
- https://git.sr.ht/~mrms/pak
environment:
  project: reg
secrets:
- 0dc4733f-3cd0-4157-81ab-d5f1ba5fabb8
shell: false
tasks:
- setup: |
    cd pak
    python3 -m pip install -r requirements.txt
    ./setup.py install --user
- build: |
    cd $project
    python3 -m pak build
- deploy: |
    cd $project
    set +x
    python3 -m pak upload -t `cat ../.secret` pak.tar
    python3 -m pak upload -t `cat ../.secret` pak.json
    set -x

M .gitignore => .gitignore +3 -0
@@ 1,1 1,4 @@
libumka.a
pak/
pak.tar
reg_linux.umi

A build.sh => build.sh +10 -0
@@ 0,0 1,10 @@
#!/bin/sh

for f in *.c; do
	echo CC $f
	BASENAME=`echo $f | cut -d. -f1`
	cc -fpic -shared -o ${BASENAME}_linux.umi $f \
		-Ipak/umka
	#x86_64-w64-mingw32-gcc -shared -o ${BASENAME}_windows.umi $f \
		#-Ipak/umka
done

A pak.json => pak.json +14 -0
@@ 0,0 1,14 @@
{
    "name": "reg",
    "version": "v0.1.0",
    "author": "Marek Maškarinec <marek@mrms.cz>",
    "license": "unlicense",
    "description": "Regex library",
    "readme": "README.md",
    "link": "https://git.sr.ht/~mrms/regum",
    "dependencies": ["umka"],
    "include": ["reg.um"],
    "run_posix": "./pak/umka/linux/umka test.um",
    "run_windows": "pak\\umka\\windows\\umka.exe test.um",
    "pre_build": "sh build.sh"
}

M reg.c => reg.c +2 -2
@@ 1,7 1,7 @@
#include <regex.h>
#include <stdio.h>

#include "umka_api.h"
#include <umka_api.h>

static int err = 0;



@@ 26,7 26,7 @@ void reg__error(UmkaStackSlot *p, UmkaStackSlot *r) {
	regex_t *prog = p[1].ptrVal;
	UmkaDynArray(char) *buf = p[0].ptrVal;

	regerror(err, prog, buf->data, buf->len);	
	regerror(err, prog, buf->data, umkaGetDynArrayLen(buf));
}

void reg__exec(UmkaStackSlot *p, UmkaStackSlot *r) {

D reg_linux.umi => reg_linux.umi +0 -0
D umka_api.h => umka_api.h +0 -115
@@ 1,115 0,0 @@
#ifndef UMKA_API_H_INCLUDED
#define UMKA_API_H_INCLUDED


#ifdef _WIN32
    #if defined(UMKA_STATIC)
        #define UMKA_EXPORT
        #define UMKA_IMPORT
    #else
        #define UMKA_EXPORT __declspec(dllexport)
        #define UMKA_IMPORT __declspec(dllimport)
    #endif
#else
    #define UMKA_EXPORT __attribute__((visibility("default")))
    #define UMKA_IMPORT __attribute__((visibility("default")))
#endif

#ifdef UMKA_BUILD
    #define UMKA_API UMKA_EXPORT
#else
    #define UMKA_API UMKA_IMPORT
#endif


#include <stdint.h>
#include <stdbool.h>


#if defined(__cplusplus)
extern "C" {
#endif


typedef union
{
    int64_t intVal;
    uint64_t uintVal;
    void *ptrVal;
    double realVal;
    float real32Val;
} UmkaStackSlot;


typedef void (*UmkaExternFunc)(UmkaStackSlot *params, UmkaStackSlot *result);


typedef enum
{
    UMKA_HOOK_CALL,
    UMKA_HOOK_RETURN,
} UmkaHookEvent;


typedef void (*UmkaHookFunc)(const char *fileName, const char *funcName, int line);


#define UmkaDynArray(T) struct \
{ \
    void *internal; \
    int64_t len; \
    int64_t itemSize; \
    T *data; \
}


typedef struct
{
    void *internal1;
    void *internal2;
} UmkaMap;


enum
{
    UMKA_MSG_LEN = 255
};


typedef struct
{
    char fileName[UMKA_MSG_LEN + 1];
    char fnName[UMKA_MSG_LEN + 1];
    int line, pos;
    char msg[UMKA_MSG_LEN + 1];
} UmkaError;


typedef void (*UmkaWarningCallback)(UmkaError *warning);


UMKA_API void *umkaAlloc            (void);
UMKA_API bool umkaInit              (void *umka, const char *fileName, const char *sourceString, int stackSize, const char *locale, int argc, char **argv, bool fileSystemEnabled, bool implLibsEnabled, UmkaWarningCallback warningCallback);
UMKA_API bool umkaCompile           (void *umka);
UMKA_API bool umkaRun               (void *umka);
UMKA_API bool umkaCall              (void *umka, int entryOffset, int numParamSlots, UmkaStackSlot *params, UmkaStackSlot *result);
UMKA_API void umkaFree              (void *umka);
UMKA_API void umkaGetError          (void *umka, UmkaError *err);
UMKA_API void umkaAsm               (void *umka, char *buf, int size);
UMKA_API bool umkaAddModule         (void *umka, const char *fileName, const char *sourceString);
UMKA_API bool umkaAddFunc           (void *umka, const char *name, UmkaExternFunc func);
UMKA_API int  umkaGetFunc           (void *umka, const char *moduleName, const char *funcName);
UMKA_API bool umkaGetCallStack      (void *umka, int depth, int *offset, char *name, int size);
UMKA_API void umkaSetHook           (void *umka, UmkaHookEvent event, UmkaHookFunc hook);
UMKA_API void *umkaAllocData        (void *umka, int size, UmkaExternFunc onFree);
UMKA_API void umkaIncRef            (void *umka, void *ptr);
UMKA_API void umkaDecRef            (void *umka, void *ptr);
UMKA_API void *umkaGetMapItem       (void *umka, UmkaMap *map, UmkaStackSlot key);
UMKA_API const char *umkaGetVersion (void);


#if defined(__cplusplus)
}
#endif

#endif // UMKA_API_H_INCLUDED