IRC Log Viewer » #firebreath » 2013-06-12

IRC Nick Time (GMT-7) Message
taxilian 08:06 ... i'm back!
sorry guys that I've been gone for a few days, been having trouble with my ZNC server. I don't know if I've been "here" or not, couldn't connect in and been too busy to fix it
looks like I was technically signed in stil... the logs are there
EBDev I'm around now if you still have questions about adding functions
EBDev 08:06 Hey Taxilian. My IT guy gets in in 10 minutes. I'll get him on here and see if you are still here
EBDev 08:06 Taxilian, Ihab just logged in and we have a few questions about function adding
ihab 08:06 hi Taxilian
taxilian 08:06 okay
ihab 08:06 after we compiled the plugin. now we tried to add function to the plugin and we following the instructions in doing that.
but the problem is when i call the function from JS code is gave "Property 'preset_changed' of object #<HTMLObjectElement> is not a function "
so for some reason it does not recognize the function because i tried a wrong name and it gave the same error.
what could be the reason for that ?? and how we can fix it ?
taxilian 08:06 can you give me the code you used to access it from JS as well as the code used to register it?
in a pastebin or something
also which browser?
ihab 08:06 var pl = plugin();
taxilian 08:06 put it in a pastebin or a gist
ihab 08:06 pl.preset_changed();
taxilian 08:06 okay, and how are you registering it?
EBDev 08:06
taxilian 08:06 and it compiles?
EBDev 08:06 yes
taxilian 08:06 what happens when you do plugin().valid
(not a function call)
ihab 08:06 if i call this particular function .valid it work but if i call my function it gave properties not function
taxilian 08:06 so calling plugin().valid works?
getting the property
ihab 08:06 yes
taxilian 08:06 okay. that's an important piece
where is the registerMethod call?
EBDev 08:06 in ExampleAPI.cpp
taxilian 08:06 right... got that part. *where* in that file? in the constructor?
can I see that file?
EBDev 09:06
taxilian 09:06 do all of the other methods registered there work?
EBDev 09:06 yea, they've been working
taxilian 09:06 then I'm going to guess that you haven't rebuilt correctly
and thus the new function isn't there
or didn't install the new plugin correctly
or something otherwise isn't working right that resulted in the old binary being run
EBDev 09:06 So you think the plugin we are compiling isn't even getting used and an old one is still being referenced?
taxilian 09:06 yes
EBDev 09:06 Oh, ok, funky.
taxilian 09:06 there are a lot of ways a function could not call, but giving you an error that it doesn't exist seems a bit odd
EBDev 09:06 Ahh! Totally right. Ihab just deleted every instance of the plugin from his computer, including one that was giving issues getting deleted because it was "in use by a program" and now the test function works and everything. Weird
cshu 09:06 taxilian, hi, may i ask a quick question?
taxilian, how do i pass a null pointer to FB::JSAPIPtr type? FB::FBNull() does not seem to work.
taxilian 09:06 cshu: just use FB::JSAPIPtr()
I think that works
depends on what you're doing
cshu 09:06 taxilian, great, thx!
taxilian 11:06 anyone willing to do me a huge favor, please upvote
tonikitoo| 12:06 I might need (again!) some help:
FB::variant TestPluginAPI::createContext(const FB::VariantMap& properties)
if (properties.find("vector") != properties.end()) {
FB::variant devicesVariant ="vector");
if (devicesVariant.is_of_type<FB::VariantList>()) { <<- Crash!
I am getting a crash with the above snippet.
on the js side, I have something simple like:
plugin.createContext({vector: [1,2]});
If I simply comment our the is_of_type check and continue my code, I am able to get the vector (with a VariantList), and all is ok.
I was trying to to be less error prone, and do some sanity checks against users' input
any hint?
taxilian 12:06 tonikitoo| why are you using a variant for devicesVariant?
what is contextProperties?
tonikitoo| 12:06 err
taxilian, it is all 'properties'
taxilian 12:06 FB::variant devicesVariant ="vector");
what is contextProperties?
tonikitoo| 12:06 taxilian, it is a typo: read it as 'properties' (see parameter)
taxilian 12:06 next question is what is the crash exception?
tonikitoo| 12:06 for your questions about why I am using a variant for devicesVariant, I thought VariantMap was a "string -> fb::variant" only map
taxilian 12:06 yeah, you're right. that's why I revised my question
tonikitoo| 12:06 so I got the "variant" and cast it to a VariantList (it works fine)
taxilian, about the crash, I so far only see chromium showing a notification at the top ("plugin has crahsed"-like message)
taxilian 12:06 instead of using a is_of_type, just do a variant.convert_cast and wrap it in a try ... catch
to see what is actually going on you need to connect a debugger
tonikitoo| 12:06 taxilian, btw, this is how I am converting the variant to a variantlist (after bypassing the crash):
FB::variant devicesVariant ="devices");
if (devicesVariant.is_of_type<FB::VariantList>()) { // <- Crash!
typedef std::vector<FB::variant> VariantVector;
std::vector<FB::variant> devicesVariantList = FB::convert_variant_list<VariantVector>(devicesVariant.convert_cast<FB::VariantList>());
taxilian 12:06 tonikitoo| a bit of IRC ettiquet: never paste code in a channel. paste it in a pastebin (,,, etc) and paste the link here
tonikitoo| 12:06 I bet there is simpler way, but it works (the cast).
it is only the check that fails
taxilian, sorry about that. You are right.
taxilian 12:06 tonikitoo|: do you realize that a FB::VariantList *is* a std::vector<FB::variant>?
tonikitoo| 12:06 yes
taxilian 12:06 why are you creating a new typedef that means the same thing, then?
tonikitoo| 12:06 taxilian, it is likely unneeded. I got it from here: FireBreath//tests/ScriptingCoreTest/jsapiauto_test.h (line 185, branch 1.7)
taxilian 12:06 yeah, just use FB::VariantList. also, you don't need to use convert_variant_list, because it is already the type you're converting it to
all you're doing is copying the list.
FB::VariantList myList; try { myList = devicesVariant.convert_cast<FB::VariantList>(); } catch (...) { /* do something 'cause it's not an array */ }
gotta go get lunch, I'll be back
tonikitoo| 12:06 ps: I just pasted the rest of the code, to get you some more context. But actually failure is the is_type_of<> check
tonikitoo| 13:06 taxilian (for when you are back): I attached a debugger to my plugin process on chromium, and my code is not actually crashing in is_type_of. It fails the 'if' check there, and crashes afterwards. Out of the 'if' block.
so I change my question: is it expected that is_type_of return false at that line?
taxilian 13:06 oh
what was I thinking
yes, that is expected
it'll be a FB::JSObjectPtr
tonikitoo| 13:06 ah! sorry about the noise, btw.
taxilian 13:06 because this came from javascript, right?
tonikitoo| 13:06 it does.
taxilian 13:06 no worries
yeah; so the conversion to FB::VariantMap is a convenience, but since the subtypes are unknown it can't do it recusively
so it'll be a FB::JSObjectPtr that happens to reference a javascript Array object
not actually a FB::VariantList
you'll have to convert it to a FB::VariantList
but you can probably do that using .convert_cast
tonikitoo| 13:06 Ok. I have done that (with your simpler suggestion, and avoiding the extra) copy round
taxilian, so to be strict at my checks, should I convert it my variant first to a JSObjectPtr, then call getJSAPI (or any other method of it), to somehow ensure the user is passing in a vector?
taxilian 13:06 the user isn't passing in a vector
they are passing in a javascript object
tonikitoo| 14:06 it passes in a [1, 2], right. it is a js object to begin with
taxilian 14:06 yes
it's an Array javascript object, but it's still a javascript object
tonikitoo| 14:06 k, thanks for the guidance again