Doxygen
Loading...
Searching...
No Matches
declinfo.h File Reference

#include <src/declinfo.h>

Include dependency graph for declinfo.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void parseFuncDecl (const DString &decl, const SrcLangExt lang, DString &clName, DString &type, DString &name, DString &args, DString &funcTempList, DString &exceptions)

Function Documentation

◆ parseFuncDecl()

void parseFuncDecl ( const DString & decl,
const SrcLangExt lang,
DString & clName,
DString & type,
DString & name,
DString & args,
DString & funcTempList,
DString & exceptions )
extern

Definition at line 330 of file declinfo.l.

332{
333 if (decl.empty())
334 {
335 return;
336 }
337 declinfoYYlex_init_extra(&g_declinfo_extra, &g_yyscanner);
338 struct yyguts_t *yyg = (struct yyguts_t*)g_yyscanner;
339
340#ifdef FLEX_DEBUG
341 declinfoYYset_debug(Debug::isFlagSet(Debug::Lex_declinfo)?1:0,g_yyscanner);
342#endif
343
344 DebugLex debugLex(Debug::Lex_declinfo,__FILE__, NULL);
345 yyextra->inputString = decl.data();
346 //printf("Input='%s'\n",yyextra->inputString);
347 yyextra->inputPosition = 0;
348 yyextra->classTempListFound = false;
349 yyextra->funcTempListFound = false;
350 yyextra->insideObjC = lang==SrcLangExt::ObjC;
351 yyextra->insidePHP = lang==SrcLangExt::PHP;
352 yyextra->insidePython = lang==SrcLangExt::Python;
353 yyextra->scope.clear();
354 yyextra->className.clear();
355 yyextra->classTempList.clear();
356 yyextra->funcTempList.clear();
357 yyextra->name.clear();
358 yyextra->type.clear();
359 yyextra->args.clear();
360 yyextra->exceptionString.clear();
361 // first we try to find the yyextra->type, yyextra->scope, yyextra->name and arguments
362 declinfoYYrestart( yyin, g_yyscanner );
363 BEGIN( Start );
364 declinfoYYlex(g_yyscanner);
365
366 //printf("yyextra->type='%s' class='%s' yyextra->name='%s' yyextra->args='%s'\n",
367 // qPrint(yyextra->type),qPrint(yyextra->scope),qPrint(yyextra->name),qPrint(yyextra->args));
368
369 if (size_t nb = yyextra->name.rfind('[') ; nb!=DString::npos && yyextra->args.empty()) // correct for [] in yyextra->name ambiguity (due to Java return yyextra->type allowing [])
370 {
371 yyextra->args.prepend(yyextra->name.mid(nb));
372 yyextra->name=yyextra->name.left(nb);
373 }
374
375 cl=yyextra->scope;
376 n=removeRedundantWhiteSpace(yyextra->name);
377 size_t il=n.find('<'), ir=n.rfind('>');
378 if (il!=DString::npos && ir!=DString::npos && n.at(il+1)!='=')
379 // prevent <=>
380 // TODO: handle cases like where n="operator<< <T>"
381 {
382 ftl=removeRedundantWhiteSpace(n.mid(il));
383 n=n.left(il);
384 }
385
386 //ctl=yyextra->classTempList.copy();
387 //ftl=yyextra->funcTempList.copy();
388 t=removeRedundantWhiteSpace(yyextra->type);
389 a=removeRedundantWhiteSpace(yyextra->args);
390 exc=removeRedundantWhiteSpace(yyextra->exceptionString);
391
392 size_t len = t.length();
393 if (!t.empty() && t.at(len-1)==')') // for function pointers
394 {
395 // check if `)` is from decltype(`
396 size_t pos = t.find("decltype(");
397 if (pos != DString::npos)
398 {
399 size_t cnt = 1;
400 for (size_t i = pos + 9; i < len; i++)
401 {
402 if (t.at(i) == '(') cnt++;
403 else if (t.at(i) == ')')
404 {
405 cnt--;
406 if (cnt == 0)
407 {
408 if (i != len-1)
409 {
410 a.prepend(")");
411 t=t.left(len-1);
412 }
413 }
414 }
415 }
416 }
417 else
418 {
419 a.prepend(")");
420 t=t.left(len-1);
421 }
422 }
423 //printf("yyextra->type='%s' class='%s' yyextra->name='%s' yyextra->args='%s'\n",
424 // qPrint(t),qPrint(cl),qPrint(n),qPrint(a));
425
426 declinfoYYlex_destroy(g_yyscanner);
427 return;
428}
bool empty() const
Returns true iff the string is empty (std::string compatible alias for isEmpty()).
Definition dstring.h:148
static constexpr size_t npos
value used to indicate 'not found' or 'to the end of the string', matching std::string::npos
Definition dstring.h:178
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition dstring.h:157
@ Lex_declinfo
Definition debug.h:59
static bool isFlagSet(const DebugMask mask)
Definition debug.cpp:132
#define yyguts_t
Definition code.l:23
static yyscan_t g_yyscanner
Definition declinfo.l:327
static struct declinfoYY_state g_declinfo_extra
Definition declinfo.l:328
DString removeRedundantWhiteSpace(const DString &s)
Definition util.cpp:427

References DString::at(), DString::data(), DString::empty(), DString::find(), g_declinfo_extra, g_yyscanner, Debug::isFlagSet(), DString::left(), DString::length(), Debug::Lex_declinfo, DString::mid(), DString::npos, DString::prepend(), removeRedundantWhiteSpace(), DString::rfind(), and yyguts_t.

Referenced by findMember().