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 329 of file declinfo.l.

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

Referenced by findMember().