~ubuntu-branches/ubuntu/wily/sip4/wily-proposed

« back to all changes in this revision

Viewing changes to sipgen/gencode.c

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Dmitry Shachnev, Scott Kitterman
  • Date: 2015-07-19 12:17:06 UTC
  • mfrom: (1.5.5)
  • Revision ID: package-import@ubuntu.com-20150719121706-9optmryjgk7scu7k
Tags: 4.16.9+dfsg-1
[ Dmitry Shachnev ]
* More minor simplifications to sipconfig wrappers.

[ Scott Kitterman ]
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
4586
4586
    needsNew = ((atype == class_type || atype == mapped_type) && vd->type.nrderefs == 0 && isConstArg(&vd->type));
4587
4587
    key = ((atype == class_type || atype == mapped_type) && vd->type.nrderefs == 0) ? vd->module->next_key-- : 0;
4588
4588
 
4589
 
    second_arg = (generating_c || key < 0) ? "sipPySelf" : "";
 
4589
    second_arg = (generating_c || (key < 0 && !isStaticVar(vd))) ? "sipPySelf" : "";
4590
4590
 
4591
4591
    prcode(fp,
4592
4592
"\n"
4603
4603
"{\n"
4604
4604
        , vd->fqcname, first_arg, second_arg, last_arg);
4605
4605
 
4606
 
    if (vd->getcode != NULL || key < 0)
 
4606
    if (vd->getcode != NULL)
4607
4607
    {
4608
4608
        prcode(fp,
4609
4609
"    PyObject *sipPy;\n"
4610
4610
            );
4611
4611
    }
 
4612
    else if (key < 0)
 
4613
    {
 
4614
        if (isStaticVar(vd))
 
4615
            prcode(fp,
 
4616
"    static PyObject *sipPy = NULL;\n"
 
4617
                );
 
4618
        else
 
4619
            prcode(fp,
 
4620
"    PyObject *sipPy;\n"
 
4621
                );
 
4622
    }
4612
4623
 
4613
4624
    if (vd->getcode == NULL)
4614
4625
    {
4631
4642
            prcode(fp,
4632
4643
"    %S *sipCpp = reinterpret_cast<%S *>(sipSelf);\n"
4633
4644
                , classFQCName(vd->ecd), classFQCName(vd->ecd));
 
4645
    }
4634
4646
 
4635
 
        prcode(fp,
 
4647
    prcode(fp,
4636
4648
"\n"
4637
 
            );
4638
 
    }
 
4649
        );
4639
4650
 
4640
4651
    /* Handle any handwritten getter. */
4641
4652
    if (vd->getcode != NULL)
4651
4662
        return;
4652
4663
    }
4653
4664
 
 
4665
    if (key < 0)
 
4666
    {
 
4667
        if (isStaticVar(vd))
 
4668
        {
 
4669
            prcode(fp,
 
4670
"    if (sipPy)\n"
 
4671
"    {\n"
 
4672
"        Py_INCREF(sipPy);\n"
 
4673
"        return sipPy;\n"
 
4674
"    }\n"
 
4675
"\n"
 
4676
                );
 
4677
        }
 
4678
        else
 
4679
        {
 
4680
            prcode(fp,
 
4681
"    sipPy = sipGetReference(sipPySelf, %d);\n"
 
4682
"    if (sipPy)\n"
 
4683
"        return sipPy;\n"
 
4684
"\n"
 
4685
                , key);
 
4686
        }
 
4687
    }
 
4688
 
4654
4689
    if (needsNew)
4655
4690
    {
4656
4691
        if (generating_c)
4687
4722
            else
4688
4723
                iff = vd->type.u.cd->iff;
4689
4724
 
4690
 
            if (key < 0)
4691
 
                prcode(fp,
4692
 
"    sipPy = sipGetReference(sipPySelf, %d);\n"
4693
 
"    if (sipPy)\n"
4694
 
"        return sipPy;\n"
4695
 
"\n"
4696
 
                    , key);
4697
 
 
4698
4725
            prcode(fp,
4699
4726
"    %s sipConvertFrom%sType(", (key < 0 ? "sipPy =" : "return"), (needsNew ? "New" : ""));
4700
4727
 
4708
4735
 
4709
4736
            if (key < 0)
4710
4737
            {
 
4738
                if (isStaticVar(vd))
 
4739
                    prcode(fp,
 
4740
"    Py_XINCREF(sipPy);\n"
 
4741
                        );
 
4742
                else
 
4743
                    prcode(fp,
 
4744
"    sipKeepReference(sipPySelf, %d, sipPy);\n"
 
4745
                        , key);
 
4746
 
4711
4747
                prcode(fp,
4712
 
"    sipKeepReference(sipPySelf, %d, sipPy);\n"
4713
4748
"\n"
4714
4749
"    return sipPy;\n"
4715
 
                    , key);
 
4750
                    );
4716
4751
            }
4717
4752
        }
4718
4753