+static inline bool psi_cpp_tokiter_expand_builtin(struct psi_cpp *cpp,
+ struct psi_token *target, struct psi_builtin *builtin)
+{
+ size_t start = psi_cpp_tokiter_index(cpp), argc = 0;
+ struct psi_plist **arg_tokens_list = NULL;
+
+ if (builtin->decl->sig) {
+ argc = psi_plist_count(builtin->decl->sig);
+ /* read in tokens, until we have balanced parens */
+ arg_tokens_list = psi_cpp_tokiter_read_call_tokens(cpp, argc);
+ if (!arg_tokens_list) {
+ psi_cpp_tokiter_seek(cpp, start);
+ return false;
+ }
+ } else {
+ psi_cpp_tokiter_next(cpp);
+ }
+
+ psi_cpp_tokiter_expand_builtin_tokens(cpp, target, builtin, arg_tokens_list);
+ if (arg_tokens_list) {
+ psi_cpp_tokiter_free_call_tokens(arg_tokens_list, argc, true);
+ }
+
+ psi_token_free(&target);
+ ++cpp->expanded;
+ return true;
+}
+
+
+static inline bool psi_cpp_tokiter_expand_def(struct psi_cpp *cpp,
+ struct psi_token *target, struct psi_cpp_macro_decl *macro)
+{
+ /* delete current token from stream */
+ psi_cpp_tokiter_del_cur(cpp, false);
+ /* replace with tokens from macro */
+ psi_cpp_tokiter_expand_tokens(cpp, target, macro->tokens);
+
+ psi_token_free(&target);