Compile error for zxing library - iphone

ZXPDF417Codeword *codeword = [self.detectionResultColumnsInternal[barcodeColumn] codewords][codewordsRow];
/My Projects/in Loyal SVN/new source Inloyal/ProjectCode_Inloyal_21-May/ZBarSDK/ZXingObjC/pdf417/decoder/ZXPDF417DetectionResult.m:144:38: Expected method to read array element not found on object of type 'NSString *'

Replace it with:
ZXPDF417Codeword *codeword = ((NSArray *)[self.detectionResultColumnsInternal[barcodeColumn] codewords])[codewordsRow];
It should work I think.

Related

pybind11, convert std::vector to py::list

According to the pybind11 documentation https://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html:
When including the additional header file pybind11/stl.h, conversions between std::vector<>/std::list<>/std::array<>, std::set<>/std::unordered_set<>, and std::map<>/std::unordered_map<> and the Python list, set and dict data structures are automatically enabled.
However, I cannot for the life of me get this to work. I suppose I am misunderstanding something, so I hope someone can clear it up for me.
Here is what I expected to work:
// Test
std::vector<double> test_vec{1,2,3,4,5};
py::list test_list = test_vec;
py::list test_list2(test_vec);
py::list test_list3 = py::cast<py::list>(test_vec);
And here are the errors:
error: conversion from ‘std::vector<double>’ to non-scalar type ‘pybind11::list’ requested
py::list test_list = test_vec;
error: no matching function for call to ‘pybind11::list::list(std::vector<double>&)’
py::list test_list2(test_vec);
error: no matching function for call to ‘cast(std::vector<double>&)’
py::list test_list3 = py::cast<py::list>(test_vec)
The docs say to look in tests/test_stl.cpp for examples of how this should work, however I'm afraid that I am having trouble deciphering what is happening in that file.
The conversion happens automatically for function arguments and return values that you create bindings for if you include pybind11/stl.h. You can also do it explicitly in C++ code like this:
#include <pybind11/stl.h>
// [...]
std::vector<double> test_vec{1, 2, 3, 4, 5};
py::list test_list3 = py::cast(test_vec);
Please bear in mind that this creates a copy, though.
For a different approach please refer to making-opaque-types and binding-stl-containers.

cairocffi throws an error with pango

context = cairocffi.Context(surface)
# pangocairo.pango_cairo_set_antialias(cairo.ANTIALIAS_SUBPIXEL)
context.translate(movex, movey)
context.rotate(twist)
layout = gobject_ref(pangocairo.pango_cairo_create_layout(context._pointer))
In the last line of this code cairocffi give a weird error
TypeError: initializer for ctype 'cairo_t *' appears indeed to be 'cairo_t *', but the types are different (check that you are not e.g. mixing up different ffi instances)
What could be the problem here?

How to fix error: invalid argument type 'NSString *' to unary expression (xCode4)

I am new to coding, I am teaching myself by watching tutorials and looking at posted papers on Google, I am following the iPhone Application paper posted by Seth Whiting and Mark Dixon from Southern Illinois University and I get an error while following their model and do not know how to fix it. Error: invalid argument type 'NSString *' to unary expression
-(NSString*)pickerView:(UIPickerView*)pickerView titleForRow:(NSInteger)rowforComponent: (NSInteger)component{
if (component==clientComponent){
return [clientName objectAtIndex:row];
}
if (component==bxComponent) {
return [problemBx objectAtIndex:row];
}
if (component==antComponent) {
return [anteCedent objectAtIndex:row];
}
if (component==conComponent){
return [conSequence objectAtIndex:row];
}
}
Probably your code is not malformed, but located at the wrong place. Obviously clang thinks, that "-(NSString*)" is the beginning of an expression with the unary minus sign operator applied on something casted to NSString*. And of course you cannot apply "-" to a reference.
Do the following checks:
Is the method inside a #implementation … #end?
Is the method outside any other method? A simple forgotten } will place the method inside another method, what gives the text a complete different meaning for the compiler.
It is a good idea to reindent the whole source file using Xcode's reindention feature.
Here is a sample for your mistake:
#implementation Subclass
- (void)method
{
id pickerView;
-(NSString*)pickerView:(UIPickerView*)pickerView titleForRow:(NSInteger)rowforComponent: (NSInteger)component{
}
#end
clang:
Invalid argument type 'NSString *' to unary expression

"Cannot convert 'float' to float**" error

I have written samples from microphone input into a Float32 array, and now I want to turn that array of samples into a WAV file.
Apparently a good way to do it is to use a utility class from the DIRAC library, as its EAFWrite class has a writeFloats method that should do the trick.
When I call the EAFWrite's writeFloats method I get a "Cannot convert 'float' to float**" error. Here's the call:
[mWriter writeFloats:128 fromArray:mySession];
The array was initialised thus:
Float32 mySession[10000000] = {0};
What do you think is wrong? Is this a problem about pointers?
A peek at the writeFloats:fromArray: source code (it's included in the library, doncha kno) reveals that the data parameter should actually be an array of array pointers, with one array pointer per channel. Presumably you specified one channel in some previous message to mWriter, so now you can just do this:
Float32 *channelsData[1] = { mySession };
[mWriter writeFloats:128 fromArray:channelsData];
or if you want to get really tricky:
[mWriter writeFloats:128 fromArray:(Float32 *[]){ mySession }];

C++ Conversion Operator Overloading issue

I have my own SmartPointer class.
There are cases where SmartPtr contain a class that inherite from a Base class, and I would like to convert SmartPtr<ClassX> into SmartPtr<BaseClassOfClassX>;
I am trying to overload the SmartPtr Conversion operator to do this.
It work fine for the Class themself, such as:
template<class newType>
operator SmartPtr<newType>() const
{
return SmartPtr<newType>((SmartPtr<newType>*)this);
}
but not for pointer to the Class, I have tried the following, and it never gets call and get the following error:
template<class newType>
operator SmartPtr<newType>*() const
{
return static_cast<SmartPtr<newType>*>(this);
}
Simple code to get the error:
SmartPtr<ClassX> test(pClassX);
SmartPtr<BaseClassOfClassX>* ob = &test;
ERROR:
cannot convert from 'SmartPtr<T> *' to 'SmartPtr<T> *'
Does anyone see what is wrong with my second conversion overload?
Thanks
From the C++ standard: "An operator function shall either be a non-static member function or be a non-member function and have at least one
parameter whose type is a class, a reference to a class, an enumeration, or a reference to an enumeration."
As the type of &test is not a class nor anything implicitly convertible to a class, you cannot overload the typecasts on the pointer directly. Depending on why you need pointers to your smart pointers, maybe you really want to employ references which is much more common.