Yep, that’s it. Just for posterity here’s the successful proof of concept.
import objc
from Foundation import NSLog, NSRunLoop
CRApplication = objc.lookUpClass("CRApplication")
objc.registerMetaDataForSelector(
b'CRRouter',
b'get:block:',
{
'arguments': {
> On 9 Jan 2020, at 00:23, Rand Dvorak wrote:
>
> I got it working. Basically I have a main.py file in Resources that get
> loaded and run by PyRun_SimpleFile in applicationDidFinishLaunching. Control
> is then passed to the python interpreter. Notice the infinite loop at the
> bottom whic
I got it working. Basically I have a main.py file in Resources that get loaded
and run by PyRun_SimpleFile in applicationDidFinishLaunching. Control is then
passed to the python interpreter. Notice the infinite loop at the bottom which
is needed because the interpreter finishes executing the
Here’s what I’ve got so far. I don’t know much about the metadata, but I did
try gen_bridge_metadata to try and decipher it, but I think it doesn’t generate
it correctly either.
import objc
CRApplication = objc.lookUpClass("CRApplication")
objc.registerMetaDataForSelector(
b'CRHTTPSer
What is the type of ‘server’?
And I just noticed the metadata block is a bit of, the callable is argument 3
instead of 2.
Ronald
--
On the road, hence brief.
> On 8 Jan 2020, at 17:18, Rand Dvorak wrote:
>
> Same result:
>
> File "main.py", line 40, in
> server.get_block_("/", hel
Same result:
File "main.py", line 40, in
server.get_block_("/", helloHandler)
TypeError: Argument 3 is a block, but no signature available
> On Jan 8, 2020, at 03:20, Ronald Oussoren wrote:
>
> Please change “get_block_” to “get:block:” in the call to
> objc.registerMetadataForSelector
Turns out the instance of server is indeed a CRHTTPServer, but the class that
need the metadata registered is CRRouter.
> On Jan 8, 2020, at 15:41, Ronald Oussoren wrote:
>
> What is the type of ‘server’?
>
> And I just noticed the metadata block is a bit of, the callable is argument 3
> in
Same results with this code:
import objc
CRApplication = objc.lookUpClass("CRApplication")
objc.registerMetaDataForSelector(
b'CRServer',
b'get_block_',
{
'arguments': {
2: {
'callable': {
'arguments':
Please change “get_block_” to “get:block:” in the call to
objc.registerMetadataForSelector.
Ronald
—
Twitter: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/
> On 8 Jan 2020, at 02:04, Rand Dvorak wrote:
>
> Same results with this code:
>
> import objc
> CRApplication = objc.lookUpCl
And given de example on https://criollo.io:
- The class name is CRServer, not CRApplication
- The selector is “get:block:” instead of “get_block:”, which also means the
block is argument 3 instead of 2.
>> objc.registerMetaDataForSelector(
>> b'CRServer',
>> b’get:block:',
>> {
>>
Hi,
You also need to remove the call to objc.selector. With correct metadata
“blocks” are callables in Python code.
Ronald
—
Twitter: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/
> On 6 Jan 2020, at 23:59, Rand Dvorak wrote:
>
> Same result:
>
> Updated code:
>
> import objc
> C
I found the place in the code to try to understand what is happening, but am a
little out of my depth
In libffi_support.m
case _C_ID:
if (argtype[1] == '?') {
/* Argument is a block */
if (argument == Py_None) {
Same result:
Updated code:
import objc
CRApplication = objc.lookUpClass("CRApplication")
objc.registerMetaDataForSelector(
b'CRApplication',
b'get_block_',
{
'arguments': {
2: {
'callable': {
'argumen
So much for typing code in Mail.app…. “Retail” should be “retval”.
Ronald
—
Twitter: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/
> On 6 Jan 2020, at 15:27, Ronald Oussoren via Pythonmac-SIG
> wrote:
>
>
>
>> On 6 Jan 2020, at 00:51, Rand Dvorak wrote:
>>
>>
>> I am trying to
> On 6 Jan 2020, at 00:51, Rand Dvorak wrote:
>
>
> I am trying to implement a simple server in PyObjC for the Criollo HTTP
> server. The server has a method to set route handlers by passing a block to
> setup the route and then when it receives and HTTP request for the route it
> calls th
I am trying to implement a simple server in PyObjC for the Criollo HTTP server.
The server has a method to set route handlers by passing a block to setup the
route and then when it receives and HTTP request for the route it calls the
block. The block has the signature:
typedef void(^CRRouteB
16 matches
Mail list logo