What is the difference between getLocStart() and getLocation() in clang's Decl? - clang

I guess based on the results of some experiments that getLocStart() points to the first token of declaration while getLocation() points to an identifier token. Does it correct? Is there any documentation on this?

Related

"[[FIRAuth auth] signInWithCredential:credential..." error

"Hi, everybody!"
I have implemented Firebase's SignInWithApple authentication as per the sample in the documentation, but I get an error that the type of argument given to signInWithCredential is different.
How should I handle this?
I am building using Xcode Version 13.3.
Programmatically, it retrieves FIROAuthCredential* credential = ..., which is
[[FIRAuth auth] signInWithCredential:credential ...,
but since the first argument of signInWithCredential must be a FIRAuthCredential*.
I think compiler is correct that it will result in a build error, but I do not know how to get the FIRAuthCredential pointer variable from FIROAuthCredeential* credential.
Please help, if you know.

Slice referring to out of scope data in zig language

The get function below looks to me like it returns a slice referring to data in an array that will be out of scope once the function returns, and therefore is in error. Assuming this is true, is there any way to detect this at compile time or even run time in a debug mode?
I couldn't find any compiler flags that detected this error at compile time or run time and wondered if I'd missed anything that could help or this is just not something zig can detect at this time, which is fine, I'll just have to be more careful :)
This is a cut down example of a real issue I had which took some time to diagnose to demonstrate the problem
const std = #import("std");
fn get() []u8 {
var data : [100]u8 = undefined;
return data[0..99];
}
pub fn main() !void {
const data = get();
std.debug.print("Name: [{}]\n", .{data});
}
I believe that's behaviour that's not currently frowned upon by the compiler (0.6.0 at the time of writing), based on my understanding of the Lifetime and Ownership part of the docs:
It is the Zig programmer's responsibility to ensure that a pointer is
not accessed when the memory pointed to is no longer available. Note
that a slice is a form of pointer, in that it references other memory.
Although it might be addressed with this issue which describes similar behaviour: https://github.com/ziglang/zig/issues/5725

Append coordinate to MapBox MGLPolyline

I am trying to append a coordinate to a line that I am annotating a MapBox map with.
MGLPpoyline has the following function for appending coordinates:
appendCoordinates(_ coords: UnsafePointer<CLLocationCoordinate2D>, count: UInt)
I cannot for the life of me figure out how to pass a single coordinate point to the above function. The UnsafePointer bit has me going bananas. I've been looking all over the net but any solution I tried ends up with the following runtime error:
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
I have just a regular CLLocationCoordinates2D instance at hand, which is verified to contain valid coordinates at the time of the function call.
Here's one of the things I've tried:
let coord = currentLocation!.coordinate // Verified valid
var coords: [CLLocationCoordinate2D] = [coord]
aLine.appendCoordinates(&coords, count:UInt(coords.count)) // Unexpectedly found nil...
btw, the following runs perfectly fine:
var line = MGLPolyline(coordinates:&coords, count:UInt(coords.count))
My apologies if I'm missing the obvious but I'm kinda new to Swift.
Any help or examples of the above function in use would be greatly appreciated.

use parameter type-of id in block iOS

Here is the code
[EvoScrollBarTagView initWithScrollView:self.listTableView
withTagView:[TagView new]
didScroll:
^(id scrollBarTagView, TagView *tagView, CGFloat offset) {
[scrollBarTagView showTagViewAnimation];
........
And my confusion is why the scrollBarTagView(type-of id) can call the method or properties in my EvoScrollBarTagView.h . the parameter scrollBarTagViews type is id, not declared as the EvoScrollBarTagViews instance object, can someone tell me why , Thank you very much...
As mentioned in Objective-C is a dynamic language:
The id type defines a generic object pointer. It’s possible to use id
when declaring a variable, but you lose compile-time information about
the object.
So it doesn't mean that scrollBarTagView can call any method, all it means that it will compile successfully. If the referenced method is not implemented, the app will crash during runtime.
That's part of the point of id -- dynamic typing. You can try to send any message (that the compiler knows about at this point in the code) to an expression of type id without any compiler error or warning.

Conflicting distributed object modifiers on parameter type on Scrollview

I'm using a scrollview, and implementing a delegate method.
-(void) scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(CGPoint *)targetContentOffset{
CGPoint p = *targetContentOffset;
int counter = [self counterForPosition:p];
*targetContentOffset=[self positionForCounter:counter];;
//load month -2;
self.month=counter-2;
}
I get a warning by Xcode.
Conflicting distributed object modifiers on parameter type in implementation of 'scrollViewWillEndDragging:withVelocity:targetContentOffset:'
I've found some hints, that I do not fully understand, and does not solve my issue.
Singleton release method produces warning?
Now it's just a warning, and nothing crashes. I think it's my personal OCD that I want to fix this.
Tx
(CGPoint *)targetContentOffset should read (inout CGPoint *)targetContentOffset, to match the declaration in the protocol that you're trying to implement. See the documentation for the protocol here: http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIScrollViewDelegate_Protocol/Reference/UIScrollViewDelegate.html
FYI: in, out, inout, byref, bycopy, and oneway are collectively known as the "distributed object modifiers". They're sort of like annotations that tell the compiler (or the reader, or the documentation system) how you're going to be using the function parameters. In this case, targetContentOffset points to a CGPoint whose value is used and then modified: it's both an in and an out parameter. Clang wants to be sure you know this, so if you haven't told Clang "yes, I know it's an inout parameter", Clang will show you that warning.

Resources