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
15 matches
Mail list logo