I posted this to the dev list but I guess this is the spot to discuss it...
Seeing as there's no docs yet perhaps we can nut this out together. I've found a method of MCObject that I want to expose to speed up something in lcVCS. It's called resolveimage and it takes the id of an image and returns the MCImage according to the context of the MCObject it's called on.
I'm thinking I want a LiveCode function resolveImage(objectRef,imageID)
Here's what I think I need to do:
- add to enum Functions in parsedef.h
Code: Select all
F_RESOLVE_IMAGE
Code: Select all
{"resolveimage", TT_FUNCTION, F_RESOLVE_IMAGE},
Code: Select all
case F_RESOLVE_IMAGE:
return new MCResolveImage;
Code: Select all
// {PE-0524} resolveImage: bad parameters
PE_RESOLVE_IMAGE_BADPARAM,
Code: Select all
class MCResolveImage : public MCFunction
{
MCChunk *object;
MCChunk *image_id;
public:
MCResolveImage()
{
object = image_id = NULL;
}
virtual ~ MCResolveImage();
virtual Parse_stat parse(MCScriptPoint &, Boolean the);
virtual Exec_stat eval(MCExecPoint &);
};
Code: Select all
MCResolveImage::~ MCResolveImage()
{
delete object;
delete image_id;
}
Parse_stat MCResolveImage::parse(MCScriptPoint &sp, Boolean the)
{
if (get2params(sp, & object, & image_id) != PS_NORMAL)
{
MCperror->add
(PE_RESOLVE_IMAGE_BADPARAM, sp);
return PS_ERROR;
}
return PS_NORMAL;
}
Exec_stat MCResolveImage::eval(MCExecPoint &ep)
{
MCObject *optr;
MCImage *imageptr;
uint4 parid;
uint4 img_id;
MCerrorlock++;
if (object->getobj(ep, optr, parid, True) == ES_NORMAL) {
if (image_id->eval(ep) == ES_NORMAL) {
if (MCU_stoi4(ep . getsvalue(),img_id) {
imageptr = optr ->resolveimage(nil,img_id);
return imageptr->getprop(0, P_LONG_ID, ep, False);
}
}
}
MCerrorlock--;
return ES_NORMAL;
}