get the char * array declared in InitListExpr, e.g., char *[] = {"hello", "world"}
(
&self,
node: &Node,
len: Option<usize>,
)
| 46 | |
| 47 | /// get the char * array declared in InitListExpr, e.g., char *[] = {"hello", "world"} |
| 48 | pub fn get_char_star_array_literal( |
| 49 | &self, |
| 50 | node: &Node, |
| 51 | len: Option<usize>, |
| 52 | ) -> Result<Vec<String>> { |
| 53 | let mut strings: Vec<String> = Vec::new(); |
| 54 | for child in self.get_childs(node) { |
| 55 | if let Clang::StringLiteral(sl) = &child.kind { |
| 56 | strings.push(sl.get_eval_value()); |
| 57 | } else { |
| 58 | eyre::bail!("child should be StringLiteral: {child:?}") |
| 59 | } |
| 60 | } |
| 61 | if let Some(len) = len { |
| 62 | //assert_eq!(strings.len(), len); |
| 63 | if strings.is_empty() { |
| 64 | for _ in 0..len { |
| 65 | strings.push("str".to_string()); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | Ok(strings) |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | /// impl fns to get array of literals for each literal type. |
no test coverage detected