Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite37dd39

Browse files
committed
remove opt iface methods + reduce generated boilerplate
1 parentfcb3660 commite37dd39

File tree

5 files changed

+132
-91
lines changed

5 files changed

+132
-91
lines changed

‎src/fu_util/CMakeLists.txt

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@ target_link_libraries(fu_utils PRIVATE Threads::Threads)
1414

1515
# Detect for installed beautiful https://github.com/ianlancetaylor/libbacktrace
1616
include_directories(.)
17-
find_library(LIBBACKTRACE backtrace)
18-
if(LIBBACKTRACE)
19-
set(CMAKE_REQUIRED_LIBRARIES backtrace)
20-
check_c_source_compiles("
21-
#include <backtrace.h>
22-
int main(void) {
23-
struct backtrace_state *st = backtrace_create_state(NULL, 0, NULL, NULL);
24-
return 0;
25-
}
26-
" HAVE_LIBBACKTRACE)
27-
if (HAVE_LIBBACKTRACE)
28-
target_compile_definitions(fu_utilsPRIVATE HAVE_LIBBACKTRACE)
17+
if(NOT CMAKE_C_COMPILERMATCHES tcc)
18+
find_library(LIBBACKTRACE backtrace)
19+
if(LIBBACKTRACE)
20+
set(CMAKE_REQUIRED_LIBRARIES backtrace)
21+
check_c_source_compiles("
22+
#include <backtrace.h>
23+
int main(void) {
24+
struct backtrace_state *st = backtrace_create_state(NULL, 0, NULL, NULL);
25+
return 0;
26+
}
27+
" HAVE_LIBBACKTRACE)
28+
if (HAVE_LIBBACKTRACE)
29+
target_compile_definitions(fu_utilsPRIVATE HAVE_LIBBACKTRACE)
30+
endif()
2931
endif()
3032
endif()
3133

‎src/fu_util/fo_obj.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,6 @@ extern fobj_klass_handle_t fobj_real_klass_of(fobj_t);
347347
#define$ifdef(assignment,meth,self, ...) \
348348
fobj_ifdef(assignment, meth, (self), __VA_ARGS__)
349349

350-
#define$iifdef(assignment,meth,iface, ...) \
351-
fobj_iface_ifdef(assignment, meth, iface, __VA_ARGS__)
352-
353350
#define$bind(iface_type,obj) fobj_bind(iface_type, (obj))
354351
#define$reduce(newiface,iface)fobj_reduce(newiface, (iface))
355352

‎src/fu_util/impl/fo_impl.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fobj_klass_method_search(fobj_klass_handle_t klass, fobj_method_handle_t meth) {
180180

181181

182182
fobj__method_callback_t
183-
fobj_method_search(constfobj_tself,fobj_method_handle_tmeth,fobj_klass_handle_tfor_child) {
183+
fobj_method_search(constfobj_tself,fobj_method_handle_tmeth,fobj_klass_handle_tfor_child,boolvalidate) {
184184
fobj_header_t*h;
185185
fobj_klass_handle_tklass;
186186
fobj__method_callback_tcb= {self,NULL};
@@ -191,10 +191,18 @@ fobj_method_search(const fobj_t self, fobj_method_handle_t meth, fobj_klass_hand
191191
ft_assert(meth!=fobj__nm_mhandle(fobjDispose)());
192192
}
193193

194+
if (self==NULL) {
195+
if (validate)
196+
ft_assert(self!=NULL,"Call '%s' on NULL object",fobj_methods[meth].name);
197+
returncb;
198+
}
199+
194200
h= ((fobj_header_t*)self-1);
195201
assert(h->magic==FOBJ_HEADER_MAGIC);
196202
klass=h->klass;
197203
ft_dbg_assert(klass>0&&klass <=atload(&fobj_klasses_n));
204+
ft_assert((h->flags&FOBJ_DISPOSED)==0,"Call '%s' on disposed object '%s'",
205+
fobj_methods[meth].name,fobj_klasses[klass].name);
198206

199207
if (ft_unlikely(for_child!=0)) {
200208
if (ft_unlikely(ft_dbg_enabled())) {
@@ -224,6 +232,9 @@ fobj_method_implements(const fobj_t self, fobj_method_handle_t meth) {
224232
fobj_header_t*h;
225233
fobj_klass_handle_tklass;
226234

235+
if (self==NULL)
236+
return false;
237+
227238
ft_assert(fobj_global_state!=FOBJ_RT_NOT_INITIALIZED);
228239
if (ft_dbg_enabled()) {
229240
ft_assert(meth>0&&meth <=atload(&fobj_methods_n));
@@ -244,6 +255,34 @@ fobj_method_implements(const fobj_t self, fobj_method_handle_t meth) {
244255
return false;
245256
}
246257

258+
externvoid
259+
fobj__validate_args(fobj_method_handle_tmeth,
260+
fobj_tself,
261+
constchar**paramnames,
262+
constchar*set,
263+
size_tcnt) {
264+
fobj_header_t*h;
265+
fobj_klass_handle_tklass;
266+
size_ti;
267+
268+
ft_assert(fobj_global_state!=FOBJ_RT_NOT_INITIALIZED);
269+
ft_assert(meth>0&&meth <=atload(&fobj_methods_n));
270+
ft_assert(meth!=fobj__nm_mhandle(fobjDispose)());
271+
ft_assert(self!=NULL,"call '%s' on NULL object",fobj_methods[meth].name);
272+
273+
h= ((fobj_header_t*)self-1);
274+
assert(h->magic==FOBJ_HEADER_MAGIC);
275+
klass=h->klass;
276+
ft_dbg_assert(klass>0&&klass <=atload(&fobj_klasses_n));
277+
278+
for (i=0;i<cnt;i++) {
279+
ft_assert(set[i]!=0,"Calling '%s' on '%s' miss argument '%s'",
280+
fobj_methods[meth].name,
281+
fobj_klasses[klass].name,
282+
paramnames[i]);
283+
}
284+
}
285+
247286
constchar*
248287
fobj_klass_name(fobj_klass_handle_tklass) {
249288
fobj_klass_registration_t*reg;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp