compile error when adding method to add / remove from array

8 views
Skip to first unread message

ashahe...@gmail.com

unread,
Nov 3, 2009, 10:36:50 PM11/3/09
to nixysa-users
hi,

I'm new to nixysa. I'm trying to add a methods to add and remove
bookmarks, but get this compile error. I'm using an example from o3d
so there might be a better way to do this.


glue/manager_glue.cc: In function 'void
glue::class_Manager::userglue_setter_elements_(Manager*, const
BookmarkArray&)':
glue/manager_glue.cc:18: error: no matching function for call to
'Manager::SetBookmarks(const std::vector<Bookmark*,
std::allocator<Bookmark*> >&)'
./manager.h:58: note: candidates are: void Manager::SetBookmarks
(BookmarkArray&)
glue/manager_glue.cc: In function 'bool glue::class_Manager::Invoke
(Manager*, NPP_t*, void*, const NPVariant*, uint32_t, NPVariant*,
const char**)':


Here is the relevant code:
manager.idl
typedef Bookmark[] BookmarkArray;
//typedef std::vector<Bookmark*> BookmarkArray;


[binding_model=by_pointer,marshaled,include="manager.h"] class
Manager {
//[include="manager.h"] class Manager {
Manager();

// [getter, setter] BookmarkArray bookmark_array;
// [getter, setter] int x;
// [getter, setter] int y;

void AddBookmark(Bookmark bookmark);

bool RemoveBookmark(Bookmark bookmark);
[userglue_getter, getter, userglue_setter, setter]

BookmarkArray bookmarks_;

[verbatim=cpp_glue] %{

BookmarkArray userglue_getter_elements_(
Manager *self) {
return self->GetBookmarks();
}
void userglue_setter_elements_(
Manager *_this,
const BookmarkArray& elements) {
_this->SetBookmarks(elements);
}
%}


manager.hclass Manager {
public:
Manager () {
}

virtual ~Manager() {
}

void AddBookmark(Bookmark* bookmark) {
bookmark_array_.push_back(Bookmark::Ref(bookmark));
}


bool RemoveBookmark(Bookmark* bookmark) {
/* BookmarkArray::iterator iter = std::find(bookmark_array_.begin
(),
bookmark_array_.end(),
&bookmark);
if (iter != bookmark_array_.end()) {
bookmark_array_.erase(iter);
return true;
}
*/ return false;

}
}

thanks
Amish

Antoine Labour

unread,
Nov 3, 2009, 10:44:36 PM11/3/09
to nixysa...@googlegroups.com
Your userglue code calls Manager::SetBookmarks, but that function doesn't appear in your Manager class in C++, in manager.h

In any case, the compiler error means it can't figure out that BookmarkArray is std::vector<Bookmark *>, which usually happens if BookmarkArray is forward declared, but not actually declared, that is, your typedef is missing.

Antoine

ashahe...@gmail.com

unread,
Nov 4, 2009, 1:17:24 PM11/4/09
to nixysa-users
thanks for the help. hmm.

Get this compile error now -
glue/manager_glue.cc: In function 'bool glue::class_Manager::Invoke
(Manager*, NPP_t*, void*, const NPVariant*, uint32_t, NPVariant*,
const char**)':
glue/manager_glue.cc:458: error: no matching function for call to
'Manager::AddBookmark(Bookmark&)'
./manager.h:33: note: candidates are: void Manager::AddBookmark
(Bookmark*)
glue/manager_glue.cc:487: error: no matching function for call to
'Manager::RemoveBookmark(Bookmark&)'
./manager.h:38: note: candidates are: bool Manager::RemoveBookmark
(Bookmark*)
scons: *** [glue/manager_glue.os] Error 1
scons: building terminated because of errors.


Note sure what I'm doing wrong.

Amish

On Nov 3, 7:44 pm, Antoine Labour <pi...@google.com> wrote:
> On Tue, Nov 3, 2009 at 8:36 PM, amishps...@yahoo.com <

Antoine Labour

unread,
Nov 4, 2009, 1:48:13 PM11/4/09
to nixysa...@googlegroups.com
On Wed, Nov 4, 2009 at 11:17 AM, amish...@yahoo.com <ashahe...@gmail.com> wrote:

thanks for the help. hmm.

Get this compile error now -
glue/manager_glue.cc: In function 'bool glue::class_Manager::Invoke
(Manager*, NPP_t*, void*, const NPVariant*, uint32_t, NPVariant*,
const char**)':
glue/manager_glue.cc:458: error: no matching function for call to
'Manager::AddBookmark(Bookmark&)'
./manager.h:33: note: candidates are: void Manager::AddBookmark
(Bookmark*)
glue/manager_glue.cc:487: error: no matching function for call to
'Manager::RemoveBookmark(Bookmark&)'
./manager.h:38: note: candidates are: bool Manager::RemoveBookmark
(Bookmark*)
scons: *** [glue/manager_glue.os] Error 1
scons: building terminated because of errors.


Note sure what I'm doing wrong.

Amish

The compiler tells you !

In your C++, you define a AddBookmark function that takes a Bookmark*, but the glue expects it to take a Bookmark&

Antoine

ashahe...@gmail.com

unread,
Nov 4, 2009, 7:04:47 PM11/4/09
to nixysa-users
Thanks Antoine.

the Manager class compiles but the bookmarks getter always seems to be
undefined. I've tried adding a bookmark (which is probably commented
at this point), but that seems to fail too.

Basically, I'm trying to see how I can add/remove elements to an
array. Could you look at the files? I've posted them to the forum.

thanks
Amish

On Nov 4, 10:48 am, Antoine Labour <pi...@google.com> wrote:
> On Wed, Nov 4, 2009 at 11:17 AM, amishps...@yahoo.com <

Antoine Labour

unread,
Nov 4, 2009, 7:43:54 PM11/4/09
to nixysa...@googlegroups.com
On Wed, Nov 4, 2009 at 5:04 PM, amish...@yahoo.com <ashahe...@gmail.com> wrote:

Thanks Antoine.

the Manager class compiles but the bookmarks getter always seems to be
undefined. I've tried adding a bookmark (which is probably commented
at this point), but that seems to fail too.

Basically, I'm trying to see how I can add/remove elements to an
array. Could you look at the files? I've posted them to the forum.

thanks
Amish

I changed:
  typedef std::vector<Bookmark*> BookmarkArray;
into:
  typedef std::vector<Bookmark> BookmarkArray;
in bookmark.h and it all compiled.

Really, you're just getting errors from the compiler, which means the problems are in the userglue or the C++ code, not directly related to Nixysa.

Antoine

ashahe...@gmail.com

unread,
Nov 4, 2009, 9:00:11 PM11/4/09
to nixysa-users
Thanks. One more problem - the javascript member variable "bookmarks"
of the Manager object is always "undefined". Why doesn't it get
recognised as an array? I uncommented the implementation of
AddBookmark in manager.h and invoked it in the javascript, but the
bookmarks is still "undefined".

Amish

On Nov 4, 4:43 pm, Antoine Labour <pi...@google.com> wrote:
> On Wed, Nov 4, 2009 at 5:04 PM, amishps...@yahoo.com <
Reply all
Reply to author
Forward
0 new messages