can you help me with understanding the behavior of Reflect.fields?
I have this code:
var obj:Dynamic={arr:["aaa","bbb","ccc"]};
trace(Reflect.fields(obj));
trace(Reflect.fields(obj.arr));
JS target output:
[arr]
[0,1,2]
CPP target output (Android NDK):
[arr]
[]
Why CPP target didn't return [0,1,2]?
As mentioned in the API documentation on Reflect.fields()
This method is only guaranteed to work on anonymous structures.
So the behavior on array is not specified.
Related
I'm using Android Studio 3.0.1. I can hit fix doc comment to insert comment of method quickly in Java, but not effective in Kotlin. How can I solve it?
When you're typing # inside a kdoc, you'll see auto complete for #param, and after #param you'll see all parameters, and currently you cannot complete all parameters within one click.
Mention the /** */ comments are called kdoc in Kotlin, which is not javadoc.
Kotlin and especially KDoc encourage a different documentation style. As stated in this discussion:
The reason is that we found that referring to parameter names from the documentation text allows to write documentation that is more concise and easier to read compared to the traditional javadoc style where every parameter is documented in a separate tag. Therefore, we do not generate the template with parameter names by default. (D. Jemerov, Kotlin in Action Author)
Here’s an example of let, which is part of the standard library:
/**
* Calls the specified function [block] with `this` value as its argument and returns its result.
*/
#kotlin.internal.InlineOnly
public inline fun <T, R> T.let(block: (T) -> R): R
I've had to jump through hoops, but I've almost managed to get ServiceStack working on iOS with Monotouch in my project. One runtime JIT exception is holding out:
System.ExecutionEngineException: Attempting to JIT compile method 'ServiceStack.Text.Json.JsonTypeSerializer:GetWriteFn<int> ()' while running with --aot-only.
The offending code is quite simple:
internal WriteObjectDelegate GetWriteFn<T>()
{
return JsonWriter<T>.WriteFn();
}
As a test, I modified the SS code to make the internal methods and types public and included the following in the startup code of my project (to actually get called).
var ick = ServiceStack.Text.Json.JsonWriter<int>.WriteFn();
var erk = ServiceStack.Text.Json.JsonTypeSerializer.Instance.GetWriteFn<int>();
This still doesn't alert the AOT for some reason, I get the exception when the code above executes! Is this because the generic parameter is a value type? Or is it because these are static classes and methods? How can I force Monotouch to AOT the methods above?
The SS code in question is in JsonTypeSerializer.cs and JsonWriter.Generic.cs at:
https://github.com/ServiceStack/ServiceStack.Text/tree/master/src/ServiceStack.Text/Json
There are some generic limitations in monotouch now. I think you should check your code to one of them.
My app makes use of a shared library, say, mylib.so
This mylib.iso would like to use API from either lib1.so or lib2.so depending on some condition.
Both lib1.so and lib2.so provide the exact same set of API.
I can only calculate the condition once mylib.iso has been loaded. It does not depend on APIs from lib1.so or lib2.so but I can not do from java:
static {
if(nativeHasCondition()) System.loadLibrary("lib1");
else System.loadLibrary("lib2");
}
System.loadLibrary("mylib");
}
because nativeHasCondition() is in mylib.so.
So, I think I shall somehow load either lib1.so or lib2.iso from my native code depending on some calculation in my native code.
How do I do that?
If nativeHasCondition() is the method of mylib.so, then you have to load mylib.so first.
Then you can follow the condition.
Perhaps you should make that code into a separate library and load it first. If you need to test cpu caps, probably you should just do it from java and then load appropriate libs (as long as you manage to load your mylib.so which should reference lib1.so or lib2.so in its import section).
I have a Core Data "List" entity that has an ordered relationship to ListItems.
Core Data itself, generates a method in the .h,
- (void)removeListItemsAtIndexes:(NSIndexSet *)indexes;
However, when I attempt to invoke that method, at runtime the app crashes stating its an unrecognized selector.
Is this method really not implemented? Why would Core Data declare it if its not implemented? Am I supposed to do something else to make this work?
Thanks
You should look at this post:
problems-with-nsorderedset
it's lion app, but i think the problem is same.
How to use the function AutoMapper.Mapper.Map(TSource source, Action opts) in AutoMapper ?
I think the 2nd param (Action opts) is there for declaring mapping options if needed but i can't find any API document for this function.
I would like to map 2 objects without having to creatmap first, if the 2 objects have exactly the same fields then the following command works: AutoMapper.Mapper.Map(TSource source)
Please help.
Mapper.DynamicMap<Model, ModelDto>() should do what you want.
I just tested it out and copied over the values from the source to the destination without requiring any CreateMap calls.
For anyone else coming across this older post, Automapper's docs have improved.
You can see examples of using the 2nd parameter for the Map function here:
https://docs.automapper.org/en/latest/Before-and-after-map-actions.html