Coder Social home page Coder Social logo

Comments (18)

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

Reference: when you Quick Look a color in the variables list:

screen shot 2015-07-28 at 5 34 19 pm

from chisel.

kastiglione avatar kastiglione commented on April 18, 2024

Nice. Can I interest you in trying a pull request 😄

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

Definitely interested. I’ll put it on my list for my job’s semi-weekly hack days.

from chisel.

kastiglione avatar kastiglione commented on April 18, 2024

Let me know if you have any questions, happy to answer anything.

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

@kastiglione would it be a faux pas to expr @import CoreFoundation in my command? I'm trying to have it be able to differentiate between UIColor, CIColor, and CGColor (and maybe NSColor?)

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

Specifically:

result = frame.EvaluateExpression('(CFTypeID)CFGetTypeID({color}) == (CFTypeID)CGColorGetTypeID()'.format(color=color))

from chisel.

kastiglione avatar kastiglione commented on April 18, 2024

would it be a faux pas to expr @import CoreFoundation in my command?

Nah. In fact I think it would be great to do, UIKit too. Thinking aloud, I wonder if it could be done on the first time any breakpoint is hit. Then by using Chisel, you get these for free.

from chisel.

kastiglione avatar kastiglione commented on April 18, 2024

Not to give you scope creep, feel free to put it in your command only. Someone can look to make it more general later.

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

I've seen it advised to always import UIKit on an exception breakpoint. I had put a UIKit import in my ~/.lldbinit, but it seemed to slow down Xcode every time I started a debugging session. I'll try again some time.

Current question: here's an error I'm getting in lldb:

error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')

From a python line like this:

colorToUse = '[UIColor colorWithCGColor:(CGColorRef){}]'.format(color)

Seen anything like this?

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

Or, to simplify the question, what is the right way to call this in lldb?

po [UIColor colorWithCGColor:(CGColorRef)[[UIColor redColor] CGColor]]

from chisel.

kastiglione avatar kastiglione commented on April 18, 2024

Cast the color to void *?

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

Nope:

(lldb) po [UIColor colorWithCGColor:(void *)[[UIColor redColor] CGColor]]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'void *'
error: 1 errors parsing expression

(assuming that's what you meant?)

from chisel.

kastiglione avatar kastiglione commented on April 18, 2024

Yup, that is what I meant. Hmm. Maybe one of:

po [UIColor colorWithCGColor:(id)[[UIColor redColor] CGColor]]
po [UIColor colorWithCGColor:(CGColor *)[[UIColor redColor] CGColor]]
po [UIColor colorWithCGColor:(CGColor *)(void *)[[UIColor redColor] CGColor]]

from chisel.

kastiglione avatar kastiglione commented on April 18, 2024

Oh, I'm curious why you're going from UIColor to CGColor to UIColor?

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

Just a simple test case to reproduce what I’m seeing in the script with a CGColor. I didn’t have a CGColor handy in an app, so I was making one from a UIColor in the debugger. If I can make a CGColor in code and reference it in the script and it works, I guess I will ignore this issue for now as an edge case. I’ll try that, and your suggestions.

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

None of the suggestions worked, but worse, the actual case I'm trying to use also doesn't work. If I'm on a breakpoint and I have a local variable, cgColor, of type CGColorRef:

(lldb) po cgColor
<CGColor 0x7fdfa0546910> [<CGColorSpace 0x7fdfa0643f70> (kCGColorSpaceDeviceRGB)] ( 0 0.478431 1 1 )

(lldb) po [UIColor colorWithCGColor:cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an lvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(id)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'id'
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColorRef)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColor *)cgColor]
error: use of undeclared identifier 'CGColor'
error: expected expression
error: 2 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(struct CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'struct CGColor *'
error: 1 errors parsing expression
(lldb) expr @import CoreGraphics
(lldb) po [UIColor colorWithCGColor:(struct CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'struct CGColor *'
error: 1 errors parsing expression

So I can't use it in my script because it doesn't even work in the real debugger, at least not with the incantations I'm using.

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

It looks like this is maybe already done in chisel? Does this code work? https://github.com/facebook/chisel/blob/master/commands/FBAutoLayoutCommands.py#L44

lldb.debugger.HandleCommand('expr (void)[%s setBorderColor:(CGColorRef)[(id)[UIColor %sColor] CGColor]]' % (layer, color))

from chisel.

ZevEisenberg avatar ZevEisenberg commented on April 18, 2024

@kastiglione alright, I got a workaround thanks to @jvisenti: http://stackoverflow.com/a/31810890/255489

I believe it's related to the UIColor going out of scope, and -CGColor returning an internal pointer:

@property(nonatomic,readonly) CGColorRef CGColor;
- (CGColorRef)CGColor NS_RETURNS_INNER_POINTER CF_RETURNS_NOT_RETAINED;

PR should be in at some point soon-ish

from chisel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.