I am developing a custom module for my employer. The my_module.module fill got too big and unmanageable so I decided to separate related code into separate .inc files.
I then included those files in the following code:
function my_module_init(){
module_load_include('inc', 'my_module', 'questionnaire_nodetypes');
module_load_include('inc', 'my_module', 'questionnaire_config');
module_load_include('inc', 'my_module', 'email_friends');
}
My code continued to work for a while but I suddenly got a undefined function error for a function that was definitely present in questionnaire_config.inc. Other similar errors soon followed for other confirmed and existing function in the other included .inc files.
It was suggested to me to run the update.php script but this did not fix the problem. In fact, I got more undefined function errors.
There's no need to put those lines in a hook, just dump them straight into the top of the module file (I've been doing it for years and it's never caused an issue).
hook_init() doesn't get called for cached pages, so it's conceivable your files aren't being included when another (non-cached) part of the system is relying on the existence of those functions.
Related
I have two folders that I want to create bindings for:
Include: - I need everything in this folder
Src: - I only need 3 functions (of many) from one file (of many)
All of the required files are included in wrapper.h.
I can create bindings for the correct functions in src by using:
bindings.allowlist_function("myfunc")
However this then means that bindgen only creates bindings for those functions explicitly mentioned. Not the other files in the wrapper.
Is there a way to create the bindings as I wish?
Note: This code is auto-generated so I can't simply move the function.
Furthermore, there are a lot of custom types that are required by these functions and the allowlist_function method brings all of those over automatically. So I need a way to mix allowlist and the files the wrapper.h. I can't manually transfer the functions over as these files change semi-frequently and I am trying to prevent issues in FFI mismatch that manual copying introduces.
**With further research: **
I have found that in Bindgens source code it shows an allowlist_file which suggests it would allow me to allowlist my wrapper and the specific functions.
if let Some(hidden_files) = matches.values_of("allowlist-file") {
for file in hidden_files {
builder = builder.allowlist_file(file);
}
This is included on the documentation at:
https://rust-lang.github.io/rust-bindgen/allowlisting.html
However, when you follow the links it is not in the builder docs and can't be found when running the code. I am confused as to whether this method really exists?
We have a problem with info frame not giving the correct file-name and line-number.
We are using Tcl 8.6 with some code forked for proc and source, we are overriding source command with some custom code, so that some of the lines can be skipped, After this, info frame isn't working for this forked version.
Is there a solution for this?
Alas, if you override bits and pieces of code like that then you lose the file tracking. It's done by tracing identities of literals and it really doesn't like what you're up to there.
Formally, the file tracking is known to be theoretically flaky, but it doesn't seem to be much of a problem in practice unless you get into the level of processing that you're up to. One possible workaround is to do your preprocessing by changing files into other files (e.g., in a “deploy” directory) so that source and proc can stay conventional. (Doing that sort of copy is also pretty much what you do when you build an application; you've just got a filtering copy instead of a simple one.)
Details
The following two locations in Tcl's source contain the heart of the problem for you:
generic/tclProc.c lines 199–280, Tcl_ProcObjCmd()
generic/tclIOUtil.c, lines 1955–1959, TclNREvalFile() (and probably lines 1819–1823, Tcl_FSEvalFileEx() too, if you want to do file evaluation that's not source)
You want that code in tclProc.c to trigger so that the frame data is built for the procedure, but for that you need the trigger in tclIOUtil.c to set the triggering action. Your changes to proc and source block both of these. The info frame command reads the data that that block in tclProc.c generates.
Perhaps the easiest way — if you're building custom C in the first place — is to insert your processing in those two functions in tclIOUtil.c; I'd do it by calling a shared function that modifies the contents of the buffer in the Tcl_Obj passed in (which will be single-referenced at that point, and hence writable). Just… don't alter the number of newlines if you want the data out of info frame to be sensible.
I am struggling to understand how to include Angular 2, a massive framework, into my content script.
My main concern is that every file needs to be included in the content script / manifest.json file. I have tried different variations, but I fail with obscure error messages every time.
I have tried to find some instructions on the internet, but to no avail. The best resource I found was https://www.devbattles.com/en/sand/post-3072-Build_Your_Own_Chrome_Extension_Using_Angular_2__TypeScript but it does not seem to be about content scripts, rather it is about having an isolated webpage. It is also a bit outdated.
This is me struggling with the manifest.json file.. (partial)
{
"matches": [ "https://hp.my.salesforce.com/console*", "https://hp.my.salesforce.com/ui/support/servicedesk/ServiceDeskPage*" ],
"js": [
"ze_modules/systemjs/dist/system.js",
"ze_modules/rxjs/bundles/Rx.js",
"ze_modules/#angular/core/bundles/core.umd.js",
"ze_modules/#angular/common/bundles/common.umd.js",
"ze_modules/requirejs/require.js",
"settings-ui/test.component.js",
"console/includes/jquery-2.2.3.min.js",
"console/includes/toastr.js",
...
...
Does anyone have any pointers? How do I get require to work? How do I get SystemJS to work? It's all a big blur for me.
I've had no issues developing the extension so far, by manually and hastily including some js libs in the manifest.json, but this is just an extreme amount of files.
Some of the error messages..
Uncaught TypeError: Cannot read property 'Subject' of undefined(anonymous function) # core.umd.js:9194(anonymous function) # core.umd.js:14(anonymous function) # core.umd.js:15
common.umd.js:14 Uncaught TypeError: Cannot read property 'Observable' of undefined(anonymous function) # common.umd.js:14(anonymous function) # common.umd.js:15
require.js:168 Uncaught Error: Module name "#angular/core" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded
So what I learned here is that chrome extensions differ from regular web development in two major ways:
Everything follows CSP policy, meaning dynamic evaluation is more limited and will cause you pain depending on which libraries you want to use (Angular for example, unless you want to utilize AoT which is still beta)
Files you use need to be declared in the manifest.json file.
I'm not going to document everything I've learned in how to do the above, but basically you need to get into using Webpack. If you want to use Angular 2 like in my case, you need to use Webpack 2.x and Angular 2.x along with AoT compilation (using angular cli).
Webpack helps you because it bundles all your work into single files, which are a lot easier to declare in your manifest.json file(s, you can have several using webpack config).
Ok, I feel embarrassed that I wasn't able to figure this out on my own, but after a few wasted hours, I figured it would be easier to simply ask over here:
I have a bunch of .gs-files in my Google Apps Script project. Now, I want to call another file's function from a method (something like AnotherClass.awesomeFunction(), which throws a ReferenceError though). Is this possible in Google Apps Script? If so, how?
Files aren't classes. You can call any functions in any file from any other file. Think of your files as if they were just added together before running. If you want class-like scoping you can use the Libraries feature.
The Above replies are correct above file being appended, make sure the order of the files in the file explorer on the app script project page is correct
The Function definition should be in the first file and the function call in the latter.
You change the option of the each file by clicking the 3 dots next to file name and selecting Move file up or Move file down
The following syntax allows you to call any function from within your Google Apps Script project, regardless of whether the function is defined in the same file that is calling it:
myFunction();
The following code is unnecessary and will throw errors:
google.script.run.myFunction();
It can do.
and Corey is right, files is not class.
I'd just like to add that order of files is not important as experienced by me so far. I'm working on a project where all calls are at the start to get a clear tree and all definitions of functions are at the end. Sometimes they're even mixed without any order within files too. So, I guess, it can call function from anywhere regardless of order within file or within project files. It's working in my case though.
I want to use the cuPrintf function, and I get it from SDK. In the readme file they write the following
Use The cuPrintf package consists of two device functions (i.e. called
from within a CUDA kernel) and three host functions (i.e. called from
within the host application). These are packaged in a single
cuPrintf.cu file, along with declarations included in a separate
cuPrintf.cuh header file. To use cuPrintf in your application, you
must do one of the following:
a) Either: Include the header-file cuPrintf.cuh at the top of your
device code, and add cuPrintf.cu to your makefile or build
command-line so that the file is included in your program.
b) Or: Directly “#include cuPrintf.cu” at the top of your device
code. In this case you should not add this file to your
makefile/build-command, and you should take care to only include it
once in your entire project.
I tried some ways but all of them give me error, ( fatal error C1083: Cannot open include file: 'cuPrintf.cuh': No such file or directory )
I put the 'cuPrintf.cu' in the header folder in the VB 2008, and
include but give me error, and change it to
cuPrintf.cuh but also don't work.
I put both files in the extension of the project , and include them
in the code , and also give me error.
Any suggestions about how to fix it, I need this function for my code.
I solved my error , by this way :
put both files ".cu & .cuh" in the same path of the project , and include "cuPrintf.cu" in the top of the code and delete the .cu file from the header
Hope this will help who face the same error