From 5d23eaa8f462cdace80b8afc2b766068b4630243 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 2 Jan 2009 07:54:38 +0000 Subject: python support for reporting with operators. * errors in python called operators are raised as errors * Python defined operators errors are reported as errors (not full traceback yet) * added BKE_reports_string, same as BKE_reports_print but it returns a string rather then printing it. * WM_operator_name_call optionally takes an initialized report struct --- source/blender/blenkernel/intern/report.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern/report.c') diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index 97bbaf66b3a..5ba21529c5c 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -215,17 +215,37 @@ void BKE_report_store_level_set(ReportList *reports, ReportType level) reports->storelevel= level; } -void BKE_reports_print(ReportList *reports, ReportType level) +char *BKE_reports_string(ReportList *reports, ReportType level) { Report *report; + DynStr *ds; + char *cstring; if(!reports) - return; - + return NULL; + + ds= BLI_dynstr_new(); for(report=reports->list.first; report; report=report->next) if(report->type >= level) - printf("%s: %s\n", report->typestr, report->message); + BLI_dynstr_appendf(ds, "%s: %s\n", report->typestr, report->message); + + if (BLI_dynstr_get_len(ds)) + cstring= BLI_dynstr_get_cstring(ds); + else + cstring= NULL; + BLI_dynstr_free(ds); + return cstring; +} + +void BKE_reports_print(ReportList *reports, ReportType level) +{ + char *cstring = BKE_reports_string(reports, level); + + if (cstring == NULL) + return; + + printf(cstring); fflush(stdout); } -- cgit v1.2.3