Develop/nn#13
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the core utilities/hal headers with improved C++ interoperability (via extern "C" guards), hardens several macros by adding missing parentheses, and adds a new dynamic-string API for in-place reversal.
Changes:
- Add
ek_str_reverse()API + a corresponding log-based test snippet. - Add
extern "C"guards to multiple public headers to support inclusion from C++. - Parenthesize macro arguments across utils (vec/mem/log/export/etc.) and rename
ek_listparameters away from C++ keywords.
Reviewed changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| Test/str_test.c | Adds a basic reverse-string exercise in the string test. |
| L2_Core/utils/src/ek_str.c | Adds ek_str_reverse() and refactors/moves _ek_str_ensure_cap. |
| L2_Core/utils/inc/ek_str.h | Declares ek_str_reverse() and adds C++ linkage guards. |
| L2_Core/utils/inc/ek_vec.h | Improves macro safety by parenthesizing vector macro operands. |
| L2_Core/utils/inc/ek_mem.h | Parenthesizes allocator macro arguments. |
| L2_Core/utils/inc/ek_log.h | Parenthesizes EK_LOG_FILE_TAG argument. |
| L2_Core/utils/inc/ek_export.h | Tweaks export macros and adds C++ linkage guards for ek_export_init. |
| L2_Core/utils/inc/ek_def.h | Adds frequency helper macros and minor macro parenthesization/formatting. |
| L2_Core/utils/inc/ek_assert.h | Adds C++ linkage guards for ek_assert_fault. |
| L2_Core/utils/inc/ek_io.h | Adds C++ linkage guards for ek_io_init. |
| L2_Core/utils/inc/ek_list.h | Adjusts include indentation and renames new parameter to new_node. |
| L2_Core/utils/inc/ek_stack.h | Parenthesizes ek_stack_destroy_safely argument. |
| L2_Core/utils/inc/ek_ringbuf.h | Parenthesizes ek_ringbuf_destroy_safely argument and removes stray whitespace. |
| L2_Core/port/inc/st_hal_port.h | Adds C++ linkage guards. |
| L2_Core/port/inc/gd_hal_port.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_uart.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_tim.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_tick.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_spi.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_pwm.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_ltdc.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_i2c.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_gpio.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_dma2d.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_dma.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_dac.h | Adds C++ linkage guards. |
| L2_Core/hal/inc/ek_hal_adc.h | Adds C++ linkage guards and formats the ADC enum declaration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+61
to
+64
| # define EK_EXPORT_HARDWARE(fn) EK_EXPORT((fn), 0) | ||
| # define EK_EXPORT_COMPONENTS(fn) EK_EXPORT((fn), 1) | ||
| # define EK_EXPORT_APP(fn) EK_EXPORT((fn), 2) | ||
| # define EK_EXPORT_USER(fn) EK_EXPORT((fn), 3) |
Comment on lines
+56
to
+59
| EK_LOG_INFO("string:%s", ek_str_get_cstring(s2)); | ||
| EK_LOG_INFO("reverse start"); | ||
| ek_str_reverse(s2); | ||
| EK_LOG_INFO("reverse result:%s", ek_str_get_cstring(s2)); |
| if (_temp_for_new_items_ != NULL) \ | ||
| { \ | ||
| (v).cap = _temp_for_cap_ex_; \ | ||
| (v).items = _temp_for_new_items_; \ |
| ek_assert_param(s != NULL); | ||
|
|
||
| if (s->buf == NULL) return false; | ||
|
|
Comment on lines
+220
to
+236
| uint32_t new_cap = s->cap; | ||
| do | ||
| { | ||
| if (new_cap == 0) new_cap = 2; | ||
| new_cap += new_cap / 2; | ||
| } while (new_cap < len); | ||
|
|
||
| char *buf = NULL; | ||
|
|
||
| if (s->buf == NULL) buf = ek_malloc(len); | ||
| else buf = ek_realloc(s->buf, new_cap); | ||
|
|
||
| if (buf == NULL) return false; | ||
|
|
||
| s->buf = buf; | ||
| s->cap = new_cap; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.