-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] Character converter skeleton class #143619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-libc Author: Uzair Nawaz (uzairnawaz) ChangesMade CharacterConverter class skeleton Full diff: https://github.com/llvm/llvm-project/pull/143619.diff 5 Files Affected:
diff --git a/libc/src/__support/wchar/CMakeLists.txt b/libc/src/__support/wchar/CMakeLists.txt
new file mode 100644
index 0000000000000..c1f402767235f
--- /dev/null
+++ b/libc/src/__support/wchar/CMakeLists.txt
@@ -0,0 +1,24 @@
+add_header_library(
+ mbstate
+ HDRS
+ mbstate.h
+ DEPENDS
+ libc.hdr.types.wchar_t
+)
+
+add_header_library(
+ character_converter
+ HDRS
+ character_converter.h
+ DEPENDS
+ libc.hdr.types.wchar_t
+ .mbstate
+ .utf_ret
+)
+
+add_header_library(
+ utf_ret
+ HDRS
+ utf_ret.h
+ DEPENDS
+)
diff --git a/libc/src/__support/wchar/character_converter.cpp b/libc/src/__support/wchar/character_converter.cpp
new file mode 100644
index 0000000000000..139597f9cb07c
--- /dev/null
+++ b/libc/src/__support/wchar/character_converter.cpp
@@ -0,0 +1,2 @@
+
+
diff --git a/libc/src/__support/wchar/character_converter.h b/libc/src/__support/wchar/character_converter.h
new file mode 100644
index 0000000000000..1800fe16eb14b
--- /dev/null
+++ b/libc/src/__support/wchar/character_converter.h
@@ -0,0 +1,20 @@
+
+#include "src/__support/wchar/mbstate.h"
+#include "src/__support/wchar/utf_ret.h"
+#include "hdr/types/wchar_t.h"
+
+class CharacterConverter {
+private:
+ mbstate_t* state;
+
+public:
+ CharacterConverter();
+
+ bool isComplete();
+
+ int push(char utf8_byte);
+ int push(wchar_t utf32);
+
+ utf_ret<char> pop_utf8();
+ utf_ret<wchar_t> pop_utf32();
+};
diff --git a/libc/src/__support/wchar/mbstate.h b/libc/src/__support/wchar/mbstate.h
new file mode 100644
index 0000000000000..c0af608c37623
--- /dev/null
+++ b/libc/src/__support/wchar/mbstate.h
@@ -0,0 +1,8 @@
+
+#include "hdr/types/wchar_t.h"
+
+struct mbstate_t {
+ wchar_t partial;
+ unsigned char bits_processed;
+ unsigned char total_bytes;
+};
diff --git a/libc/src/__support/wchar/utf_ret.h b/libc/src/__support/wchar/utf_ret.h
new file mode 100644
index 0000000000000..533f4cb952f4b
--- /dev/null
+++ b/libc/src/__support/wchar/utf_ret.h
@@ -0,0 +1,6 @@
+
+template <typename T>
+struct utf_ret {
+ T out;
+ int error;
+};
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs some changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant that if there are no "DEPENDS" you don't need that line in the cmake rule, you still need a header library target
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Made CharacterConverter class skeleton
Made CharacterConverter class skeleton
Made CharacterConverter class skeleton