fully removed out context
parent
b3c40ba79b
commit
e5abd6a135
|
@ -60,6 +60,9 @@ internal void fm_copy_file(char *file, char *newname);
|
||||||
internal void fm_copy_all(char *source, char *tag, char *folder);
|
internal void fm_copy_all(char *source, char *tag, char *folder);
|
||||||
internal void fm_copy_folder(char *src_dir, char *dst_dir, char *src_folder);
|
internal void fm_copy_folder(char *src_dir, char *dst_dir, char *src_folder);
|
||||||
|
|
||||||
|
// File Reading and Writing
|
||||||
|
internal void fm_write_file(char *file_name, char *data, u32 size);
|
||||||
|
|
||||||
// Zip
|
// Zip
|
||||||
internal void fm_zip(char *parent, char *folder, char *dest);
|
internal void fm_zip(char *parent, char *folder, char *dest);
|
||||||
|
|
||||||
|
@ -219,6 +222,10 @@ fm_align(){
|
||||||
fm_arena_pos = (fm_arena_pos+7)&(~7);
|
fm_arena_pos = (fm_arena_pos+7)&(~7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Windows implementation
|
||||||
|
//
|
||||||
|
|
||||||
#if defined(IS_WINDOWS)
|
#if defined(IS_WINDOWS)
|
||||||
|
|
||||||
typedef uint32_t DWORD;
|
typedef uint32_t DWORD;
|
||||||
|
@ -239,6 +246,28 @@ typedef union _LARGE_INTEGER {
|
||||||
} u;
|
} u;
|
||||||
LONGLONG QuadPart;
|
LONGLONG QuadPart;
|
||||||
} LARGE_INTEGER, *PLARGE_INTEGER;
|
} LARGE_INTEGER, *PLARGE_INTEGER;
|
||||||
|
typedef void* HANDLE;
|
||||||
|
typedef void* PVOID;
|
||||||
|
typedef void* LPVOID;
|
||||||
|
typedef void* LPCVOID;
|
||||||
|
typedef DWORD* LPDWORD;
|
||||||
|
#if defined(_WIN64)
|
||||||
|
typedef unsigned __int64 ULONG_PTR;
|
||||||
|
#else
|
||||||
|
typedef unsigned long ULONG_PTR;
|
||||||
|
#endif
|
||||||
|
typedef struct _OVERLAPPED {
|
||||||
|
ULONG_PTR Internal;
|
||||||
|
ULONG_PTR InternalHigh;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
DWORD Offset;
|
||||||
|
DWORD OffsetHigh;
|
||||||
|
};
|
||||||
|
PVOID Pointer;
|
||||||
|
};
|
||||||
|
HANDLE hEvent;
|
||||||
|
} OVERLAPPED, *LPOVERLAPPED;
|
||||||
|
|
||||||
#define WINAPI
|
#define WINAPI
|
||||||
|
|
||||||
|
@ -249,8 +278,30 @@ extern "C"{
|
||||||
BOOL WINAPI QueryPerformanceFrequency(_Out_ LARGE_INTEGER *lpFrequency);
|
BOOL WINAPI QueryPerformanceFrequency(_Out_ LARGE_INTEGER *lpFrequency);
|
||||||
BOOL WINAPI CreateDirectoryA(_In_ LPCTSTR lpPathName, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
BOOL WINAPI CreateDirectoryA(_In_ LPCTSTR lpPathName, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes);
|
||||||
BOOL WINAPI CopyFileA(_In_ LPCTSTR lpExistingFileName, _In_ LPCTSTR lpNewFileName, _In_ BOOL bFailIfExists);
|
BOOL WINAPI CopyFileA(_In_ LPCTSTR lpExistingFileName, _In_ LPCTSTR lpNewFileName, _In_ BOOL bFailIfExists);
|
||||||
|
|
||||||
|
HANDLE WINAPI CreateFileA(_In_ LPCTSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode,_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, _In_ DWORD dwCreationDisposition, _In_ DWORD dwFlagsAndAttributes, _In_opt_ HANDLE hTemplateFile);
|
||||||
|
BOOL WINAPI WriteFile(_In_ HANDLE hFile, _In_ LPCVOID lpBuffer, _In_ DWORD nNumberOfBytesToWrite, _Out_opt_ LPDWORD lpNumberOfBytesWritten, _Inout_opt_ LPOVERLAPPED lpOverlapped);
|
||||||
|
BOOL WINAPI ReadFile(_In_ HANDLE hFile, _Out_ LPVOID lpBuffer, _In_ DWORD nNumberOfBytesToRead, _Out_opt_ LPDWORD lpNumberOfBytesRead, _Inout_opt_ LPOVERLAPPED lpOverlapped);
|
||||||
|
BOOL WINAPI CloseHandle(_In_ HANDLE hObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define INVALID_HANDLE_VALUE ((HANDLE) -1)
|
||||||
|
|
||||||
|
#define GENERIC_READ 0x80000000
|
||||||
|
#define GENERIC_WRITE 0x40000000
|
||||||
|
#define GENERIC_EXECUTE 0x20000000
|
||||||
|
#define GENERIC_ALL 0x10000000
|
||||||
|
|
||||||
|
#define CREATE_NEW 1
|
||||||
|
#define CREATE_ALWAYS 2
|
||||||
|
#define OPEN_EXISTING 3
|
||||||
|
#define OPEN_ALWAYS 4
|
||||||
|
#define TRUNCATE_EXISTING 5
|
||||||
|
|
||||||
|
#define FILE_ATTRIBUTE_READONLY 0x00000001
|
||||||
|
#define FILE_ATTRIBUTE_NORMAL 0x00000080
|
||||||
|
#define FILE_ATTRIBUTE_TEMPORARY 0x00000100
|
||||||
|
|
||||||
static uint64_t perf_frequency;
|
static uint64_t perf_frequency;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -362,6 +413,23 @@ fm_copy_all(char *source, char *tag, char *folder){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
fm_write_file(char *file_name, char *data, u32 size){
|
||||||
|
HANDLE file = CreateFileA(file_name, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
|
||||||
|
if (file != INVALID_HANDLE_VALUE){
|
||||||
|
DWORD written = 0;
|
||||||
|
for (;written < size;){
|
||||||
|
DWORD newly_written = 0;
|
||||||
|
if (!WriteFile(file, data + written, size - written, &newly_written, 0)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
written += newly_written;
|
||||||
|
}
|
||||||
|
Assert(written == size);
|
||||||
|
CloseHandle(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fm_zip(char *parent, char *folder, char *dest){
|
fm_zip(char *parent, char *folder, char *dest){
|
||||||
char cdir[512];
|
char cdir[512];
|
||||||
|
@ -374,6 +442,10 @@ fm_zip(char *parent, char *folder, char *dest){
|
||||||
systemf("copy %s\\4ed_gobble.zip %s & del %s\\4ed_gobble.zip", cdir, dest, cdir);
|
systemf("copy %s\\4ed_gobble.zip %s & del %s\\4ed_gobble.zip", cdir, dest, cdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Unix implementation
|
||||||
|
//
|
||||||
|
|
||||||
#elif defined(IS_LINUX) || defined(IS_MAC)
|
#elif defined(IS_LINUX) || defined(IS_MAC)
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -478,6 +550,16 @@ fm_copy_all(char *source, char *tag, char *folder){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
fm_write_file(char *file_name, char *data, u32 size){
|
||||||
|
// TODO(allen): Real unix version?
|
||||||
|
FILE *file = fopen(file_name, "wb");
|
||||||
|
if (file != 0){
|
||||||
|
fwrite(data, 1, size, file);
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
fm_zip(char *parent, char *folder, char *file){
|
fm_zip(char *parent, char *folder, char *file){
|
||||||
Temp_Dir temp = fm_pushdir(parent);
|
Temp_Dir temp = fm_pushdir(parent);
|
||||||
|
|
|
@ -115,7 +115,8 @@ generate_keycode_enum(){
|
||||||
"return(result);\n"
|
"return(result);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
|
|
||||||
end_file_out(filename_keycodes, &out);
|
fm_write_file(filename_keycodes, out.str, out.size);
|
||||||
|
out.size = 0;
|
||||||
|
|
||||||
fm_end_temp(temp);
|
fm_end_temp(temp);
|
||||||
}
|
}
|
||||||
|
@ -240,7 +241,8 @@ generate_style(){
|
||||||
}
|
}
|
||||||
append(&out, "};\n");
|
append(&out, "};\n");
|
||||||
|
|
||||||
end_file_out(filename_4coder, &out);
|
fm_write_file(filename_4coder, out.str, out.size);
|
||||||
|
out.size = 0;
|
||||||
|
|
||||||
struct_begin(&out, "Interactive_Style");
|
struct_begin(&out, "Interactive_Style");
|
||||||
{
|
{
|
||||||
|
@ -298,7 +300,8 @@ generate_style(){
|
||||||
"}\n\n");
|
"}\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
end_file_out(filename_4ed, &out);
|
fm_write_file(filename_4ed, out.str, out.size);
|
||||||
|
out.size = 0;
|
||||||
|
|
||||||
fm_end_temp(temp);
|
fm_end_temp(temp);
|
||||||
}
|
}
|
||||||
|
@ -400,11 +403,11 @@ generate_custom_headers(){
|
||||||
String *public_name = &func_4ed_names.names[i].public_name;
|
String *public_name = &func_4ed_names.names[i].public_name;
|
||||||
|
|
||||||
*macro = str_alloc(name_string.size+4);
|
*macro = str_alloc(name_string.size+4);
|
||||||
to_upper_ss(macro, name_string);
|
to_upper(macro, name_string);
|
||||||
append(macro, make_lit_string("_SIG"));
|
append(macro, make_lit_string("_SIG"));
|
||||||
|
|
||||||
*public_name = str_alloc(name_string.size);
|
*public_name = str_alloc(name_string.size);
|
||||||
to_lower_ss(public_name, name_string);
|
to_lower(public_name, name_string);
|
||||||
|
|
||||||
fm_align();
|
fm_align();
|
||||||
}
|
}
|
||||||
|
@ -435,7 +438,8 @@ generate_custom_headers(){
|
||||||
append(&out, "_Function);\n");
|
append(&out, "_Function);\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
end_file_out(OS_API_H, &out);
|
fm_write_file(OS_API_H, out.str, out.size);
|
||||||
|
out.size = 0;
|
||||||
|
|
||||||
append(&out, "struct Application_Links;\n");
|
append(&out, "struct Application_Links;\n");
|
||||||
|
|
||||||
|
@ -518,7 +522,7 @@ generate_custom_headers(){
|
||||||
}
|
}
|
||||||
append(&out, "){");
|
append(&out, "){");
|
||||||
|
|
||||||
if (match_ss(ret, make_lit_string("void"))){
|
if (match(ret, make_lit_string("void"))){
|
||||||
append(&out, "(");
|
append(&out, "(");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -548,7 +552,8 @@ generate_custom_headers(){
|
||||||
}
|
}
|
||||||
append(&out, "#endif\n");
|
append(&out, "#endif\n");
|
||||||
|
|
||||||
end_file_out(API_H, &out);
|
fm_write_file(API_H, out.str, out.size);
|
||||||
|
out.size = 0;
|
||||||
|
|
||||||
fm_end_temp(temp);
|
fm_end_temp(temp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Mr. 4th Dimention - Allen Webster
|
|
||||||
*
|
|
||||||
* 25.02.2016
|
|
||||||
*
|
|
||||||
* File editing view for 4coder
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TOP
|
|
||||||
|
|
||||||
#if !defined(OUT_CONTEXT_4CODER)
|
|
||||||
#define OUT_CONTEXT_4CODER
|
|
||||||
|
|
||||||
internal void
|
|
||||||
end_file_out(char *out_file, String *out_data){
|
|
||||||
FILE *file = fopen(out_file, "wb");
|
|
||||||
if (file != 0){
|
|
||||||
fwrite(out_data->str, 1, out_data->size, file);
|
|
||||||
fclose(file);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
fprintf(stdout, "Could not open output file %s\n", out_file);
|
|
||||||
}
|
|
||||||
out_data->size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// BOTTOM
|
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,8 @@ do_html_output(Document_System *doc_system, char *dst_directory, Abstract_Item *
|
||||||
if (doc_get_link_string(doc, doc_link, sizeof(doc_link))){
|
if (doc_get_link_string(doc, doc_link, sizeof(doc_link))){
|
||||||
generate_document_html(&out, doc_system, doc);
|
generate_document_html(&out, doc_system, doc);
|
||||||
char *name = fm_str(dst_directory, "/", doc_link);
|
char *name = fm_str(dst_directory, "/", doc_link);
|
||||||
end_file_out(name, &out);
|
fm_write_file(name, out.str, out.size);
|
||||||
|
out.size = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
1
|
1
|
||||||
0
|
0
|
||||||
100
|
101
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,8 @@ int main(){
|
||||||
pstr = str_start_end(pcontext.data, start, parse.code.size);
|
pstr = str_start_end(pcontext.data, start, parse.code.size);
|
||||||
append(&out, pstr);
|
append(&out, pstr);
|
||||||
|
|
||||||
end_file_out(GENERATED_FILE, &out);
|
fm_write_file(GENERATED_FILE, out.str, out.size);
|
||||||
|
out.size = 0;
|
||||||
|
|
||||||
// NOTE(allen): Publish the new file. (Would like to be able to automatically test the result before publishing).
|
// NOTE(allen): Publish the new file. (Would like to be able to automatically test the result before publishing).
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue