I'm using some packages from from Octave Forge. In the API documentation some of the functions are prefixed with #<AnOtherName>/..
As Example:
#lti/c2d
What is the meaning of this prefix with # and the additional name? What is the difference to "normal" functions?
lti is a class, #lti/c2d refers to the c2d method of the lti class.
In old-style class definitions, class methods for a class lti are M-files in a directory called #lti, so the c2d method would be defined in a file #lti/c2d.m.
New-style class definitions use a single classdef file to define all methods, but it is still possible to override functions for a specific class or type by creating M-files in a directory #<class>. For example, you can create an M-file #double/foo.m to create a function foo that exists only on inputs of type double.
Related
How do I modify the C++ class constructor that cython will generate from a Cython extension type that I've defined in a .pyx file wo that I don't incur the penalty of using def __cinit__(self)? Assume I am compiling to C++, not C.
What I would like to do is set the default values as I would in an initialization list in C++, and maybe run some code in the constructor without interacting with Python. It looks like the __cinit__ method runs after the C++ class members are initialized and the C++ constructor finishes running.
In this example, it says
Cython initializes C++ class attributes of a cdef class using the nullary constructor.
I assume this refers to the default constructor since the C++ constructor is a nullary constructor. I also assumes this happens with or without a __cinit__ method.
If the class you’re wrapping does not have a nullary constructor, you must store a pointer to the wrapped class and manually allocate and deallocate it. A convenient and safe place to do so is in the cinit and dealloc methods which are guaranteed to be called exactly once upon creation and deletion of the Python instance.
I have an existing class where I call Py_XDECREF on a member object in a loop inside of __dealloc__. This object holds pointers to Python objects. When I convert to C++ code, the annotated HTML shows no highlighted yellow text in the lines where the __dealloc__ method is defined. This is interesting because __dealloc__ is also defined using def.
When I try to initialize a member that is an instance of a Cython Extension that I defined (and did not create from wrapping C++ code), however, the __cinit__ method is highlighted in yellow.
def __cinit__(self):
self._member = MyCyExt()
I'm wondering if it's because I can't initialize a Cython Extension Type in pure C++. I don't know why that would be the case since Cython calls the nullary constructor by default.
This answer solves the problem, but it incurs the overhead I am trying to avoid. Is there a way to do this without incurring that overhead and actually writing the constructor itself in a .pyx file?
I am developing Haxe code that I convert in C# and insert into a Unity project.
The conversion works fine and I am able to use the generated class when I import it alone in Unity.
To make it work, I have to bring in Unity the whole generated src folder, including the Type.cs file.
However, when I import the "Post Processing Stack" (a basic Unity extension) I get errors due to name Conflicts. The Type class is also a basic C# class and It is used by the Post Processing scripts.
The haxe-Type takes priority and breaks the compilation:
Assets/PostProcessing/Runtime/PostProcessingBehaviour.cs(406,30): error CS1502: The best overloaded method match for `System.Collections.Generic.Dictionary<Type,System.Collections.Generic.KeyValuePair<UnityEngine.Rendering.CameraEvent,UnityEngine.Rendering.CommandBuffer>>.Add(Type, System.Collections.Generic.KeyValuePair<UnityEngine.Rendering.CameraEvent,UnityEngine.Rendering.CommandBuffer>)' has some invalid arguments
Assets/PostProcessing/Runtime/PostProcessingBehaviour.cs(406,34): error CS1503: Argument `#1' cannot convert `System.Type' expression to type `Type'
I don't know if it is possible to solve this issue by playing around with C#/Unity/Mono search paths.
I as wondering wether it is more appropriate to (optionally) wrap all haxe top-level classes into the haxe namespace, or a special haxe-defaultnamespace, or prefix them for example to class HType.
Name conflicts for this basic types are likely to emerge in many other contexts, not only in Unity.
I found the solution in the Haxe documentation for C#:
https://github.com/HaxeFoundation/HaxeManual/wiki/Haxe-C%23
-D no-root generate package-less haxe types in the haxe.root namespace to avoid conflicts with other types in the root namespace
This way, all the classes that were at global level will be generated under namespace haxe.root.
Sometimes in debug mode with Flash Builder, I see something like
__AS3__.vec.Vector.<Object> (#909e219)
but when I try to store this variable in another as3 variable, Flash duplicate this variable. Concretly, I'm trying to exclude some values on dragInitiator.selectedItems property before adding them to a List but when I use splice method on it, values aren't deleted from this vector.
So how can I acces variable with __AS3__ namespace please ?
According to a Tamarin developer:
The namespace "__AS3__.vec" is an artifact of a time when we did not have good API
versioning and could not introduce new top-level names without the risk of breaking
existing code. Today we would probably have made "Vector" public & versioned.
Source: http://hg.mozilla.org/tamarin-redux/rev/817f3e019ba2#l2.30
In other words, __AS3__ is the package where are defined Flash internal classes into Tamarin VM.
To access such variables, you don't need to specify the namespace. You only have to use the FQN declared in playerglobals.swc.
I'm trying to create and instance of an object by reference the class object of the class using
getDefinitionByName()
the problem is that if I don't create at least one instance of the class before when try to use getDefinitionByName() it say
ReferenceError: Error #1065: Variable XXXXXX is not defined.
how can I include the class in the binary without using and instance first??, also I had tried to juts leave in the import but still don't include the class, it could be a compiler param I can pass??
I'm using Flex SDK 4.6 thanks!!!!!
As described in the documentation:
-includes class Links one or more classes to the resulting application SWF file, whether or not those classes are required at compile time
There is a bunch of compiler options which allow you to include classes, but they aren't very scalable / require some manual labour. For example, there's -includes option, but you must know what symbols to include. There's -include-libraries, but again, you'd have to compile a SWC library with the classes you need. -include-namespace - you'd need to write the namespace definition, listing all classes that you want to include.
Since I imagine that the task in the end will get automated one way or another, it would make more sense to just generate an AS file of the following format:
package your.app {
import fully.qualified.class.Name;Name; // it is enough to just mention it
. . .
}
And then include only this this class.
Well I think I found the solution, just add to the compiler the argument -includes like thised
-includes com.example.Myclass
that will include the class object in the binary even though u haven't used and after tried to load it with getDefinitionByName()
hopes this help to someone else, also here is a complete list of arguments for the compiler
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7a92.html
According to documentation (https://developers.google.com/closure/compiler/docs/api-tutorial3#externs), it seems the closure compiler should rename variables when no external declaration exists, including when using functions/variables from an external bit of code. The example they give is
function makeNoteDom(noteTitle, noteContent, noteContainer) {
// Create DOM structure to represent the note.
var headerElement = textDiv(noteTitle);
var contentElement = textDiv(noteContent);
...
}
where the textDiv function is declared in the global scope by a third-party lib of some sort. It says textDiv should be declared external to prevent renaming.
My question is - when I put this code or similar into the Closure Compiler without any extern declarations why is textDiv not renamed (which would break the code), as the documentation indicates?
The compiler assumes that calls to an undefined function are in fact calls to an external functions. Using the command line compiler, you can use --warning_level VERBOSE to have the compiler treat this condition as an error.
The Web Application is primarily built for demos and assumes this by default. While you can set a VERBOSE warning level, it will not change this functionality. See the Additional Web Service Options page for information on options. I've filed a bug report about this.
Due to the renaming algorithm for properties, undeclared properties will be renamed in a breaking way if that same property name isn't declared on an object in externs.