Crystal Space
Welcome, Guest. Please login or register.
December 20, 2014, 07:00:54 pm

Login with username, password and session length
Search:     Advanced search
9032 Posts in 2046 Topics by 9295 Members
Latest Member: Marioibuch
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Python API iObjectRegistry.Get()
« previous next »
Pages: [1] Print
Author Topic: Python API iObjectRegistry.Get()  (Read 2560 times)
Avinoamr
Newbie
*
Posts: 11


View Profile Email
« on: October 20, 2008, 01:53:27 am »

Hey guys,

I'm trying to setup the python API environment for CS and CEL. I tested CELStart and all seems to go well, but when I try to follow the tutorials found on the website, I get stuck very early on:
Code:
vc = object_reg.Get(iVirtualClock)
According to the interface, the argument should be an instance of scfInterfaceID, which appears to only be obtainable through iSCF, but for the same reason I can't seem to find how to instantiate iSCF.

Is anyone here familiar with this problem? Is it something I'm doing wrong?

Thanks for your time wink
« Last Edit: October 20, 2008, 08:56:53 am by Avinoamr » Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #1 on: October 20, 2008, 10:58:31 am »

Code:
vc = object_reg.Get(iVirtualClock)

Tried that? I think it should already work like that.

According to the interface, the argument should be an instance of scfInterfaceID, which appears to only be obtainable through iSCF, but for the same reason I can't seem to find how to instantiate iSCF.
for your time wink

Well, (an implementation of) iSCF is instantiated when CS starts up. If access to it is needed, in C++ there is a special variable with in. I'm not sure how to access that in Python ... but I don't think it's required anyway. The Python bindings mostly if not completely encapsulate all the iSCF-related goops through some helpers.
Logged
Avinoamr
Newbie
*
Posts: 11


View Profile Email
« Reply #2 on: October 20, 2008, 11:38:08 am »

Thanks for the swift reply res,

This line:
Code:
vc = object_reg.Get(iVirtualClock)

Is producing this error:
Code:
NotImplementedError: Wrong number of arguments for overloaded function 'iObjectRegistry_Get'.
  Possible C/C++ prototypes are:
    Get(iObjectRegistry *,char const *)
    Get(iObjectRegistry *,char const *,scfInterfaceID,int)
    Get(iObjectRegistry *,scfInterfaceID,int)
    Get(iObjectRegistry *)

object_reg is an instance of iObjectRegistry.
iVirtualClock is a python class, not an instance of one. I'm basically trying to pass the class itself as an argument.

And I agree that there's no need to explicitly access the implementation of iSCF, I was just looking for a workaround for my problem. Also, just for my understanding, in C++ what's "iVirtualClock"? It's an interface right? Can you pass an interface/class name as an argument? in contrast of passing an instance?
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #3 on: October 20, 2008, 12:21:57 pm »

The construct vc = object_reg.Get(iVirtualClock) should work fine. That's how I'm doing it in my python apps. Not sure why it isn't working for you.

Greetings,
Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #4 on: October 20, 2008, 03:48:21 pm »

This line:
Code:
vc = object_reg.Get(iVirtualClock)

Is producing this error:

What CS version are you using? I think versions prior to 1.4 did not have the objectRegistry.Get() method. There you would do something like vc = CS_QUERY_REGISTRY(object_reg).

Also, just for my understanding, in C++ what's "iVirtualClock"? It's an interface right?

Yes.

Can you pass an interface/class name as an argument? in contrast of passing an instance?

In C++, no. But this is Python, and there, yes Smiley Classes are first class objects in Python. The bindings take advantage of that by providing a more 'pythonized' Get()
which extracts the interface ID behind the scenes. (In C++, a different approach to hide the interface, involving templates, is used).
Logged
Avinoamr
Newbie
*
Posts: 11


View Profile Email
« Reply #5 on: October 22, 2008, 02:28:05 am »

That's probably it. I'm on 1.2. I'll just go for 1.4.

Thanks alot Jorrit and Res smiley
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 7.406 seconds with 17 queries.