[Bf-blender-cvs] [59c8f7f41b2] soc-2020-info-editor: Remove clog dependency on ListBase
Mateusz GrzeliÅski
noreply at git.blender.org
Wed Jul 1 11:39:55 CEST 2020
Commit: 59c8f7f41b2910a545b8dfd2e78f552bea2847e9
Author: Mateusz Grzeliński
Date: Wed Jul 1 11:33:15 2020 +0200
Branches: soc-2020-info-editor
https://developer.blender.org/rB59c8f7f41b2910a545b8dfd2e78f552bea2847e9
Remove clog dependency on ListBase
- it was quick hack to get things working, it is causing troubles with includes
- remove accidentally commited in merge struct LogRecord
===================================================================
M intern/clog/CLG_log.h
M intern/clog/CMakeLists.txt
M intern/clog/clog.c
===================================================================
diff --git a/intern/clog/CLG_log.h b/intern/clog/CLG_log.h
index dc9f107d103..7b3e8b77cf6 100644
--- a/intern/clog/CLG_log.h
+++ b/intern/clog/CLG_log.h
@@ -87,7 +87,6 @@ extern "C" {
/* For printing timestamp. */
#define __STDC_FORMAT_MACROS
-#include <DNA_windowmanager_types.h>
#include <inttypes.h>
#define STRINGIFY_ARG(x) "" #x
@@ -125,9 +124,8 @@ typedef struct CLG_LogRef {
CLG_LogType *type;
} CLG_LogRef;
-
typedef struct CLG_LogRecord {
- /** Link for ListBase */
+ /** Link for clog version of ListBase */
struct CLG_LogRecord *next, *prev;
/** track where does the log comes from */
CLG_LogType *type;
@@ -138,6 +136,11 @@ typedef struct CLG_LogRecord {
char *message;
} CLG_LogRecord;
+/** clog version of ListBase */
+typedef struct LogRecordList {
+ struct CLG_LogRecord *first, *last;
+} LogRecordList;
+
void CLG_log_str(CLG_LogType *lg,
enum CLG_Severity severity,
const char *file_line,
@@ -172,7 +175,7 @@ void CLG_type_filter_include(const char *type_filter, int type_filter_len);
void CLG_type_filter_exclude(const char *type_filter, int type_filter_len);
void CLG_level_set(int level);
-struct ListBase *CLG_log_record_get(void );
+struct LogRecordList *CLG_log_record_get(void);
void CLG_logref_init(CLG_LogRef *clg_ref);
diff --git a/intern/clog/CMakeLists.txt b/intern/clog/CMakeLists.txt
index be06d058082..41009642e3f 100644
--- a/intern/clog/CMakeLists.txt
+++ b/intern/clog/CMakeLists.txt
@@ -20,9 +20,6 @@ set(INC
.
../atomic
../guardedalloc
- ../../source/blender/makesdna
- ../../source/blender/blenlib
- ../../source/blender/blenkernel
)
set(INC_SYS
diff --git a/intern/clog/clog.c b/intern/clog/clog.c
index f7f064f3216..c8b729a296b 100644
--- a/intern/clog/clog.c
+++ b/intern/clog/clog.c
@@ -44,14 +44,12 @@
/* For printing timestamp. */
#define __STDC_FORMAT_MACROS
-#include <DNA_windowmanager_types.h>
#include <inttypes.h>
/* Only other dependency (could use regular malloc too). */
#include "MEM_guardedalloc.h"
/* own include. */
-#include "../../source/blender/blenlib/BLI_blenlib.h"
#include "CLG_log.h"
/* Local utility defines */
@@ -74,21 +72,10 @@ typedef struct CLG_IDFilter {
char match[0];
} CLG_IDFilter;
-typedef struct LogRecord {
- /** track where does the log comes from */
- CLG_LogType *type;
- enum CLG_Severity severity;
- uint64_t timestamp;
- const char *file;
- const char *line;
- const char *function;
- char *message;
-} LogRecord;
-
typedef struct CLogContext {
/** Single linked list of types. */
CLG_LogType *types;
- ListBase log_records;
+ LogRecordList log_records;
#ifdef WITH_CLOG_PTHREADS
pthread_mutex_t types_lock;
@@ -515,6 +502,26 @@ void CLG_log_str(CLG_LogType *lg,
}
}
+/** Clog version of BLI_addtail (to avoid making dependency) */
+static void CLG_report_append(LogRecordList *listbase, CLG_LogRecord *link)
+{
+
+ if (link == NULL) {
+ return;
+ }
+
+ link->next = NULL;
+ link->prev = listbase->last;
+
+ if (listbase->last) {
+ listbase->last->next = link;
+ }
+ if (listbase->first == NULL) {
+ listbase->first = link;
+ }
+ listbase->last = link;
+}
+
void CLG_logf(CLG_LogType *lg,
enum CLG_Severity severity,
const char *file_line,
@@ -546,7 +553,7 @@ void CLG_logf(CLG_LogType *lg,
char *message = MEM_callocN(cstr.len - csr_size_before_va + 1, "LogMessage");
memcpy(message, cstr.data + csr_size_before_va, cstr.len - csr_size_before_va);
CLG_LogRecord *log_record = clog_log_record_init(lg, severity, file_line, fn, message);
- BLI_addtail(&(lg->ctx->log_records), log_record);
+ CLG_report_append(&(lg->ctx->log_records), log_record);
clg_str_append(&cstr, "\n");
@@ -640,7 +647,7 @@ static void CLG_ctx_level_set(CLogContext *ctx, int level)
}
}
-static ListBase *CLG_ctx_log_record_get(CLogContext *ctx)
+static LogRecordList *CLG_ctx_log_record_get(CLogContext *ctx)
{
return &ctx->log_records;
}
@@ -666,7 +673,8 @@ static void CLG_ctx_free(CLogContext *ctx)
clog_log_record_free(log);
log = log_next;
}
- BLI_listbase_clear(&ctx->log_records);
+ ctx->log_records.first= NULL;
+ ctx->log_records.last= NULL;
while (ctx->types != NULL) {
CLG_LogType *item = ctx->types;
@@ -750,7 +758,7 @@ void CLG_level_set(int level)
CLG_ctx_level_set(g_ctx, level);
}
-ListBase *CLG_log_record_get()
+LogRecordList *CLG_log_record_get()
{
return CLG_ctx_log_record_get(g_ctx);
}
More information about the Bf-blender-cvs
mailing list