[PD-dev] trying to understand class_new

Boštjan Jerko bojerko at gmail.com
Sun Mar 22 17:15:39 CET 2020


I’m attaching images from debugger. The strange thing is that type1 is A_DEFFLOAT, but *vp is still A_NULL. Guess I need to work (at least) on that.
That way the loop doesn’t even get started.
So one image shows values of type1 and *vp and the other is stack.

I’m using stm32f429 and Segger programmer with their Ozone debugger.

B.




> On 22 Mar 2020, at 11:52, Christof Ressi <info at christofressi.com> wrote:
> 
>> and then in function class_new vp is empty so while (*vp) doesn’t go through it
> What do you mean by "empty", when exactly is "vp" empty and how did you test?
> 
> "vp" is initially set to "type1", which in the case of pdint_setup() is "A_DEFFLOAT". So it would be very strange if "vp" was initially empty in the case pdint_setup(). The while loop sets "vp" to the next vararg and increments the pointer until it encounters "A_NULL" (= 0). So finally, "*vp" will always be 0, if that is what you mean by empty.
> 
> Or did you mean "vp" itself is NULL? This would be even stranger, because it points to the stack.
> 
> Do your run the code in a debugger? If yes, post the stack trace. If not, well, use a debugger :-)
> 
> BTW, which device are you using?
> 
> Christof
> 
> On 22.03.2020 09:13, Boštjan Jerko wrote:
>> Hi Christof,
>> 
>> the problem is that I don’t really know what happens but it goes something like that:
>> 
>> calling pd_init -> pd_init_systems -> conf_init -> x_connective_setup -> pdint_setup
>> 
>> and then in function class_new vp is empty so while (*vp) doesn’t go through it and after exiting class_new the microcontroller stops with a hard error.
>> So maybe the question is really - should the vp be empty and if not - why is that happening?
>> 
>> B.
>> 
>>> On 21 Mar 2020, at 13:58, Christof Ressi <info at christofressi.com> wrote:
>>> 
>>> Hi,
>>> 
>>>> The code compiles but I get the error when running in the pdint_setup where pdint_new in class_new breaks with an error.
>>>> My idea is to first try to understand the code hence my question:
>>> I think first you should post the error you get ;-) Maybe the problem is trivially solved without having to look at  code for class_new() at all.
>>>> What does class_new do?
>>> It creates a new Pd class (t_pd). The class contains all the methods and some metadata. It also registers a creator function in pd_objectmaker, which is the factory object for all classes.
>>> 
>>> When you type "[foo 0]" you really send a message "obj <x> <y> foo 0" to the canvas, which in turn sends a message "foo 0" to pd_objectmaker, which finally returns a newly created instance (given that it can find a creator method for "foo").
>>> 
>>> But again, I think the problem is likely trivial and those implementation details shouldn't concern you, unless you want to learn about Pd internals, of course :-)
>>> 
>>> Christof
>>> 
>>> On 21.03.2020 13:20, Boštjan Jerko wrote:
>>>> Hi,
>>>> 
>>>> I’m trying to port libpd to stm32. I don’t need gui so working only on connecting pd script to the output (which is DAC from stm32 in my case).
>>>> The code compiles but I get the error when running in the pdint_setup where pdint_new in class_new breaks with an error.
>>>> My idea is to first try to understand the code hence my question:
>>>> What does class_new do?
>>>> 
>>>> My guess is connecting puredata command with a function in C. Am I correct or completely missing the point?
>>>> 
>>>> Thanks.
>>>> 
>>>> B.
>>>> 
>>>> 
>>>> _______________________________________________
>>>> Pd-dev mailing list
>>>> Pd-dev at lists.iem.at
>>>> https://lists.puredata.info/listinfo/pd-dev
>>> 
>>> 
>>> _______________________________________________
>>> Pd-dev mailing list
>>> Pd-dev at lists.iem.at
>>> https://lists.puredata.info/listinfo/pd-dev
> 
> 
> 
> _______________________________________________
> Pd-dev mailing list
> Pd-dev at lists.iem.at
> https://lists.puredata.info/listinfo/pd-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20200322/9d377096/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vp_value.png
Type: image/png
Size: 216070 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20200322/9d377096/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: stack.png
Type: image/png
Size: 163230 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20200322/9d377096/attachment-0003.png>


More information about the Pd-dev mailing list